import { unified } from "unified"; import rehypeStringify from "rehype-stringify"; import rehypeFormat from "rehype-format"; import rehypeParse from "rehype-parse"; import rehypeRaw from "rehype-raw"; export async function writeComponent(componentName, data = {}) { const fn = await import(`./input/templates/${componentName}.jsx`); const jsxProcessor = unified() .use(rehypeParse, { fragment: true }) .use(rehypeRaw) .use(rehypeFormat) .use(rehypeStringify); return jsxProcessor.stringify(await jsxProcessor.run(fn.default(data))); }