www: use frontmatter parser from std (#621)
This commit is contained in:
@@ -38,11 +38,8 @@ export const handler: Handlers<Data> = {
|
|||||||
}
|
}
|
||||||
const url = new URL(`../../../${entry.file}`, import.meta.url);
|
const url = new URL(`../../../${entry.file}`, import.meta.url);
|
||||||
const fileContent = await Deno.readTextFile(url);
|
const fileContent = await Deno.readTextFile(url);
|
||||||
const { content, data } = frontMatter(fileContent) as {
|
const { body, attrs } = frontMatter<Record<string, unknown>>(fileContent);
|
||||||
data: Record<string, string>;
|
const page = { ...entry, markdown: body, data: attrs ?? {} };
|
||||||
content: string;
|
|
||||||
};
|
|
||||||
const page = { ...entry, markdown: content, data: data ?? {} };
|
|
||||||
const resp = ctx.render({ page });
|
const resp = ctx.render({ page });
|
||||||
return resp;
|
return resp;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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-typescript.js?no-check";
|
||||||
import "https://esm.sh/prismjs@1.27.0/components/prism-tsx.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";
|
||||||
|
|||||||
Reference in New Issue
Block a user