Skip to content

Markdown

The MD class contains several helpers to work with Markdown and frontmatter text.

The parser also support markdown variants like MDX.

frontmatter

Extracts and parses the frontmatter text from a markdown file. Returns undefined if no frontmatter is not found or the parsing failed. Default format is yaml.

const frontmatter = MD.frontmatter(text, "yaml")

content

Extracts the markdown source without the frontmatter.

const content = MD.content(text)

updateFrontmatter

Merges frontmatter values into the existing in a markdown file. Use null value to delete fields.

const updated = MD.updateFrontmatter(text, { title: "New Title" })