diff options
author | Alan Pearce | 2023-09-22 08:40:59 +0200 |
---|---|---|
committer | Alan Pearce | 2023-09-22 12:03:47 +0200 |
commit | 3a2d198d153efc8a69e7640f7dcde88207268ff3 (patch) | |
tree | 7cec49484a6fbbf96121ff396afe1fd0425c4654 /bin | |
parent | 9c4fd37c97a87b9d1ab9e65b77e4578936b66323 (diff) | |
download | website-3a2d198d153efc8a69e7640f7dcde88207268ff3.tar.lz website-3a2d198d153efc8a69e7640f7dcde88207268ff3.tar.zst website-3a2d198d153efc8a69e7640f7dcde88207268ff3.zip |
Replace zola with DOM-based static site generation code
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/build.ts | 30 |
1 files changed, 30 insertions, 0 deletions
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, + }); +}); |