Parses yaml blocks into structured data
npm install remark-parse-yamlThis remark plugin takes markdown with yaml frontmatter and parses the yaml into an object.
``javascript
const unified = require('unified')
const markdown = require('remark-parse')
const frontmatter = require('remark-frontmatter')
const parseFrontmatter = require('remark-parse-yaml');
let processor = unified()
.use(markdown)
.use(frontmatter)
.use(parseFrontmatter)
`
When the processor is run, yaml nodes will now have an additional key, parsedValue, data
attached to its key.
Say that we have this markdown string:
` markdown
---
metadata: this is metadata
tags:
- one
- two
---
When parsed, this will produce a
yaml node with a data object that looks like this:`javascript
data: {
parsedValue: {
metadata: "this is metadata",
tags: ["one", "two"]
}
}
``