import { readFile, mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { md } from "$lib/utils"; export const load = async ({ params, fetch, cookies, locals }) => { const websiteOverviewData = await fetch( `http://localhost:3000/website_overview?id=eq.${params.websiteId}`, { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Bearer ${cookies.get("session_token")}`, Accept: "application/vnd.pgrst.object+json" } } ); const websiteOverview = await websiteOverviewData.json(); const templatePath = join( process.cwd(), "..", "templates", websiteOverview.content_type.toLowerCase() ); const indexFile = await readFile(join(templatePath, "index.html"), { encoding: "utf-8" }); const articleFileContents = await readFile(join(templatePath, "article.html"), { encoding: "utf-8" }); const indexFileContents = indexFile .replace("{{title}}", `