tailwind-nextjs-blog/lib/remark-extract-frontmatter.ts
Ivan Li 1536ffa319
Some checks failed
🚀 Build and deploy by ftp / 🎉 Deploy (push) Failing after 44s
chore(deps): update deps.
2023-07-09 06:19:21 +00:00

14 lines
353 B
TypeScript

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