all repos — kushiyaki @ f18c0bbf8c19a3ddc1cc40e4d2e5f38c7b4c7216

🍢 A tiny static site generator for grilling markdown files to perfection

writeComponent.js (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
import { unified } from "unified";
import rehypeStringify from "rehype-stringify";

export async function writeComponent(componentName, data = {}) {
  const fn = await import(`./input/templates/${componentName}.jsx`); //FIX avoid strict filestruct past "input"
  return unified().use(rehypeStringify).stringify(fn.default(data));
}
console.log(await writeComponent("booknav", { page: "1" }));