tailwind-nextjs-blog/lib/remark-extract-frontmatter.js

11 lines
258 B
JavaScript
Raw Normal View History

2022-07-17 21:40:41 +08:00
import { visit } from 'unist-util-visit'
import { load } from 'js-yaml'
export default function extractFrontmatter() {
return (tree, file) => {
visit(tree, 'yaml', (node, index, parent) => {
file.data.frontmatter = load(node.value)
})
}
}