New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@sdairs/tinybird-markdoc-ext

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sdairs/tinybird-markdoc-ext

Extended Markdoc parser for Tinybird files

latest
npmnpm
Version
0.1.5
Version published
Maintainers
0
Created
Source

Tinybird Markdoc Extension

A specialized Markdoc parser for Tinybird files that adds support for custom nodes like queries and tables.

Installation

npm install @sdairs/tinybird-markdoc-ext

Usage

import { TinybirdParser } from '@sdairs/tinybird-markdoc-ext'

// Create a parser instance
const parser = new TinybirdParser()

// Parse a file
const content = `
---
type: query
name: my_query
---

This is a query that selects data.

{% query name="my_query" %}
SELECT * FROM my_table
{% /query %}
`

// Get both frontmatter and content
const { frontmatter, content } = parser.parseFile(content)

// Or just render to HTML
const html = parser.renderHtml(content)

Custom Nodes

Query Node

The query node allows you to define SQL queries in your Tinybird files:

{% query name="my_query" %}
SELECT * FROM my_table
{% /query %}

Table Node

The table node allows you to define table schemas:

{% datasource name="my_table" delimiter="|" %}
id|UUID|$.id|User ID
name|String|$.name|Person's full name
age|UInt8|$.age|Person's age
{% /datasource %}

Extending

You can add your own custom nodes when creating a parser instance:

const parser = new TinybirdParser({
  nodes: {
    myCustomNode: {
      render: 'CustomNode',
      attributes: {
        name: { type: String, required: true }
      },
      transform(node, config) {
        // Custom transform logic
      }
    }
  }
})

API

TinybirdParser

The main parser class with the following methods:

  • parse(content: string): Parse content and return AST
  • transform(ast: any): Transform AST into renderable tree
  • renderHtml(content: string): Render content to HTML
  • getFrontmatter(content: string): Get just the frontmatter
  • parseFile(content: string): Get both frontmatter and content

Default Export

The package also exports a default instance with standard configuration:

import tinybirdParser from '@tinylabs/tinybird-file-parser'

const html = tinybirdParser.renderHtml(content)

FAQs

Package last updated on 07 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts