tailwind-nextjs-blog/lib/remark-extract-frontmatter.js
2022-07-17 21:40:41 +08:00

11 lines
258 B
JavaScript

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)
})
}
}