1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import rehypeDocument from "https://esm.sh/rehype-document";
import remarkFrontmatter from "https://esm.sh/remark-frontmatter";
import remarkParse from "https://esm.sh/remark-parse";
import remarkStringify from "https://esm.sh/remark-stringify";
import { unified } from "https://esm.sh/unified";
import { matter } from "npm:vfile-matter";
export async function stripMetadata(markdown: string) {
const file = await unified()
.use(remarkParse)
.use(remarkStringify)
.use(remarkFrontmatter)
.process(markdown);
matter(file, { strip: true });
return String(file);
}