跳至内容

Markdown

MD 类提供了一组实用工具,用于处理 Markdownfrontmatter text

解析器还支持类似MDX这样的markdown变体。

frontmatter

从markdown文件中提取并解析frontmatter文本。如果未找到frontmatter或解析失败,则返回undefined。默认格式为yaml

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

content

提取不含前置元数据的Markdown源代码。

const content = MD.content(text)

updateFrontmatter

将frontmatter值合并到现有的markdown文件中。使用null值来删除字段。

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