www: use frontmatter parser from std (#621)

This commit is contained in:
Benny Yen
2022-08-23 13:26:44 +00:00
committed by GitHub
parent 67b82d538b
commit d798db2a5f
2 changed files with 3 additions and 6 deletions
+2 -5
View File
@@ -38,11 +38,8 @@ export const handler: Handlers<Data> = {
}
const url = new URL(`../../../${entry.file}`, import.meta.url);
const fileContent = await Deno.readTextFile(url);
const { content, data } = frontMatter(fileContent) as {
data: Record<string, string>;
content: string;
};
const page = { ...entry, markdown: content, data: data ?? {} };
const { body, attrs } = frontMatter<Record<string, unknown>>(fileContent);
const page = { ...entry, markdown: body, data: attrs ?? {} };
const resp = ctx.render({ page });
return resp;
},
+1 -1
View File
@@ -3,4 +3,4 @@ import "https://esm.sh/prismjs@1.27.0/components/prism-jsx.js?no-check";
import "https://esm.sh/prismjs@1.27.0/components/prism-typescript.js?no-check";
import "https://esm.sh/prismjs@1.27.0/components/prism-tsx.js?no-check";
export { parse as frontMatter } from "https://deno.land/x/frontmatter@v0.1.4/mod.ts";
export { extract as frontMatter } from "$std/encoding/front_matter.ts";