// Builds deck.md into dist/: one HTML page holding every slide, and routes.json listing a URL // per slide for the review pack's screenshots. import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { esc, parseDeck, renderContent } from "./deck-lib.mjs"; const slides = parseDeck(readFileSync("deck.md", "utf8")); const theme = readFileSync("theme.css", "utf8"); const deckTitle = slides[0]?.title ?? "Deck"; const sections = slides .map( (s) => ``, ) .join("\n"); const script = ` const fit = () => document.documentElement.style.setProperty("--fit", Math.min(innerWidth / 1280, innerHeight / 720)); addEventListener("resize", fit); fit(); const slides = [...document.querySelectorAll(".slide")]; const params = new URLSearchParams(location.search); if (params.has("print")) document.body.classList.add("print"); let at = 0; function show(i, push) { at = Math.max(0, Math.min(slides.length - 1, i)); slides.forEach((s, j) => s.classList.toggle("on", j === at)); if (push) history.replaceState(null, "", "#" + slides[at].id); } function fromHash() { const i = slides.findIndex((s) => "#" + s.id === location.hash); show(i >= 0 ? i : 0, false); } addEventListener("hashchange", fromHash); addEventListener("keydown", (e) => { if (["ArrowRight", "PageDown", " "].includes(e.key)) { e.preventDefault(); show(at + 1, true); } if (["ArrowLeft", "PageUp"].includes(e.key)) { e.preventDefault(); show(at - 1, true); } if (e.key === "n") document.body.classList.toggle("show-notes"); }); addEventListener("click", (e) => { if (!e.target.closest("a")) show(at + (e.clientX > innerWidth / 3 ? 1 : -1), true); }); fromHash(); (document.fonts ? document.fonts.ready : Promise.resolve()).then(() => { window.atelierReady = true; }); `; rmSync("dist", { recursive: true, force: true }); mkdirSync("dist"); writeFileSync( "dist/index.html", `