fix: tidy files
trickyni trickyniv56@gmail.com
Thu, 30 Apr 2026 17:15:56 +0300
3 files changed,
4 insertions(+),
42 deletions(-)
M
extractFrontmatter.js
→
extractFrontmatter.js
@@ -13,16 +13,17 @@ export async function extractFrontmatter(filepath) {
let frontmatterObj; const processor = await unified() .use(remarkParse) - .use(remarkStringify) .use(remarkFrontmatter, "yaml") .use(() => (tree) => { frontmatterObj = yaml.load(tree.children[0].value); + //FIX something with vfiles //TODO throw error on invalid frontmatter frontmatterObj.filename = filepath.split("/").pop(); frontmatterObj.filepath = filepath; }) + .use(remarkStringify) .process(await readFile(filepath, "utf-8")); return frontmatterObj; } -// console.log(await extractFrontmatter("./input/index.md")); +// console.log(await extractFrontmatter("./input/content/index.md"));
M
joinComponents.js
→
joinComponents.js
@@ -48,4 +48,4 @@
const output = await processor.process(union); return output.value; } -console.log(await joinComponents("./input/content/cookie.md")); +// console.log(await joinComponents("./input/content/cookie.md"));
D
writePage.js
@@ -1,39 +0,0 @@
-import { readFile } from "fs-extra"; -import { unified } from "unified"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import rehypeStringify from "rehype-stringify"; -import remarkFrontmatter from "remark-frontmatter"; -import rehypeFormat from "rehype-format"; -import rehypeDocument from "rehype-document"; -import rehypeMeta from "rehype-meta"; -import rehypeRaw from "rehype-raw"; -import { extractFrontmatter } from "./extractFrontmatter"; -// -//NOTE input: markdown file. output, HTML document -//TODO does not yet accept before/after JSX components. -//This is using unified's rehypeDocument to create a boilerplate with a few -//inserts (favicon, css, title) -// - -export async function writePage(filepath) { - const frontmatter = await extractFrontmatter(filepath); - let content; - const processor = await unified() - .use(remarkParse) - .use(remarkFrontmatter) - .use(remarkRehype, { allowDangerousHtml: true }) - .use(rehypeRaw) - .use(rehypeFormat) - .use(rehypeDocument, { - css: frontmatter.css ?? "style.css", - title: frontmatter.title ?? frontmater.filename, - link: [{ href: "favicon.png", rel: "icon", type: "image/png" }], - }) - .use(rehypeStringify) - .process(await readFile(filepath, "utf-8")); - return processor.value; -} - -// let input = "./input/cookie.md"; -// console.log(await writePage(input));