Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

utility to strip yaml frontmatter from a md file

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);
}
December 1, 2023