Set up the basic layout of the site and greybox its content based on statically generated pages. Content pages uses general base layouts defined centrally to avoid duplicating code.
23 lines
677 B
JavaScript
23 lines
677 B
JavaScript
import { pages } from "./build/node/content/pages.js"
|
|
import { prettify, htmlDocument } from "antihtml";
|
|
import * as fs from "node:fs"
|
|
|
|
const outDir = "build/web";
|
|
if (!fs.existsSync(outDir)) {
|
|
fs.mkdirSync(outDir);
|
|
}
|
|
|
|
for (const page of pages) {
|
|
const dirSep = page.ref.indexOf("/");
|
|
if (dirSep !== -1) {
|
|
const dir = `${outDir}/${page.ref.slice(0, dirSep)}`;
|
|
if (!fs.existsSync(dir)) {
|
|
fs.mkdirSync(dir);
|
|
}
|
|
}
|
|
console.log(`writing ${outDir}/${page.ref}`);
|
|
fs.writeFileSync(`${outDir}/${page.ref}`, htmlDocument(prettify(page.content)));
|
|
}
|
|
|
|
console.log(`writing ${outDir}/style.css`);
|
|
fs.writeFileSync(`${outDir}/style.css`, fs.readFileSync("public/style.css"));
|