tailwind-nextjs-blog/lib/remark-extract-frontmatter.ts
Ivan Li 2ed23c4327
Some checks failed
continuous-integration/drone/push Build is failing
fix: js 执行崩溃
- deps and types.
- use pnpm instead of npm.
- fix cpu 100%.
2022-10-08 22:45:31 +08:00

13 lines
323 B
TypeScript

import { VFile } from 'vfile'
import { visit, Parent } from 'unist-util-visit'
import { load } from 'js-yaml'
export default function extractFrontmatter() {
return (tree: Parent, file: VFile) => {
visit(tree, 'yaml', (node: Parent) => {
//@ts-ignore
file.data.frontmatter = load(node.value)
})
}
}