From 3a2d198d153efc8a69e7640f7dcde88207268ff3 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 22 Sep 2023 08:40:59 +0200 Subject: Replace zola with DOM-based static site generation code --- bin/build.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 bin/build.ts (limited to 'bin/build.ts') diff --git a/bin/build.ts b/bin/build.ts new file mode 100755 index 0000000..d6b6df9 --- /dev/null +++ b/bin/build.ts @@ -0,0 +1,30 @@ +#!/usr/bin/env bun +import fs from "node:fs"; +import log from "loglevel"; + +import generateSite from "../src/templates"; + +log.setLevel((Bun.env.LOG_LEVEL || "info") as log.LogLevelDesc); + +fs.mkdirSync("public", { recursive: true }); +log.info("Generating site..."); +try { + await generateSite(); +} catch (error) { + log.error("Error generating site", error); + process.exit(1); +} + +log.info("Copying static files..."); +if (!fs.existsSync("static")) { + log.error("static directory not found"); + process.exit(1); +} +fs.readdirSync("static").map((file) => { + log.info(`Copying static/${file}`); + fs.cpSync(`static/${file}`, `public/${file}`, { + dereference: true, + recursive: true, + preserveTimestamps: true, + }); +}); -- cgit 1.4.1