Markdown
Officialv5.20.2@kubb/parser-md
kubb add parser-md
Options
parserMd() takes no options. A plugin controls each Markdown file through its metadata, such as the YAML frontmatter.
Frontmatter
Set meta.frontmatter on a file a plugin creates. Kubb writes any serializable object as a YAML block at the top of the page.
| Field | file.meta.frontmatter |
| Type | Record<string, unknown> | null |
| Required | false |
import { ast } from 'kubb/kit'
const file = ast.factory.createFile({
baseName: 'README.md',
path: './src/gen/README.md',
meta: {
frontmatter: { title: 'API Reference', layout: 'doc' },
},
sources: [ast.factory.createSource({ nodes: [ast.factory.createText('Endpoints generated from the OpenAPI spec.')] })],
})---
title: API Reference
layout: doc
---
Endpoints generated from the OpenAPI spec.nullor an empty object writes no frontmatter.- A file
bannergoes above the frontmatter, and afootergoes below the content. Tools such as Jekyll read frontmatter only at the top of the file, so leavebannerunset on a file with frontmatter.
parserMd().print(...parts) joins Markdown strings with blank lines and skips empty ones. It takes strings only, so frontmatter always comes from meta.frontmatter.
