markdown-it-meta-yaml
v0.0.4
Published
Markdown-It plugin for parsing YAML front matter.
Downloads
12
Maintainers
Readme
Parsing YAML-formatted metadata from markdown files and converting it into JSON-formatted data.
🥳 All YAML values are supported - powered by js-yaml
---
title: Hello Markdown
date: 2023-03-25 12:00
score: 1.8
tags:
- frontend
- markdown
---
👇🏻
{
"title": "Hello Markdown",
"date": "2023-03-25 12:00",
"score": 1.8,
"tags": [
"frontend",
"markdown"
]
}
Usage
Use it as a plugin for markdown-it
npm install markdown-it-meta-yaml
import MarkdownIt from 'markdown-it'
import markdownItMetaYaml from 'markdown-it-meta-yaml'
const markdownIt = new MarkdownIt()
markdownIt.use(markdownItMetaYaml, {
cb: (metaJSON, metaRaw) => console.log(metaJSON, metaRaw)
})
// metaJSON =>
// {
// "title": "Hello Markdown",
// "date": "2023-03-25 12:00",
// "score": 1.8,
// "tags": [
// "frontend",
// "markdown"
// ]
// }
// metaRaw =>
// title: Hello Markdown
// date: 2023-03-25 12:00
// score: 1.8
// tags:
// - frontend
// - markdown