// 🤖 Shared script for the planet-scale operations guide. // // This file is the single source of truth for the guide's structure. It: // 1. renders the sidebar navigation on every page (from the PAGES list below), // 2. renders the previous / next links at the bottom of every page, // 3. renders the "you are here" system map at the top of every page, // 4. adds a small anchor link to every heading that has an id. // // To add a page: create the HTML file (copy an existing page as a template), // then add one entry to PAGES below, in reading order. Nothing else to update — // every page's sidebar and pager follow this list automatically. // // All markup injected here is built from static, in-code strings only (the // repo rule: never innerHTML untrusted content). "use strict"; const PAGES = [ { file: "index.html", num: "01", short: "Overview", title: "Overview and orientation" }, { file: "router.html", num: "02", short: "The router", title: "The router: the front door of every box" }, { file: "processes.html", num: "03", short: "Processes on a box", title: "Everything that runs on a box" }, { file: "deploys.html", num: "04", short: "Deploys and updates", title: "Installing and updating the software" }, { file: "spaces.html", num: "05", short: "Creating spaces", title: "Creating and removing chat spaces" }, { file: "hibernation.html", num: "06", short: "Hibernation", title: "Hibernation: how idle spaces sleep in object storage" }, { file: "mesh.html", num: "07", short: "The mesh", title: "The mesh: running more than one box" }, { file: "operations.html", num: "08", short: "Day-to-day operations", title: "Day-to-day operations and checks" }, { file: "dev.html", num: "09", short: "The proving ground", title: "The proving ground: the dev mesh" }, { file: "reference.html", num: "10", short: "Reference", title: "Complete reference: commands, files, variables" }, ]; function currentPage() { const explicit = document.body.dataset.page; if (explicit) return explicit; const leaf = location.pathname.split("/").pop(); return leaf === "" ? "index.html" : leaf; } // ---- sidebar ---- function renderSidebar() { const nav = document.querySelector("nav.side"); if (!nav) return; const here = currentPage(); const items = PAGES.map(p => { const current = p.file === here ? ' aria-current="page"' : ""; return `
An operator’s guide to the planet-scale system
` + `docs/planet-scale.md and docs/instance-router.md.`;
wrap.appendChild(colophon);
}
// ---- heading anchors ----
function renderHeadingAnchors() {
document.querySelectorAll("h2[id], h3[id]").forEach(h => {
const a = document.createElement("a");
a.className = "hlink";
a.href = "#" + h.id;
a.textContent = "#";
a.setAttribute("aria-label", "Link to this section");
h.appendChild(a);
});
}
// ---- the system map (the "you are here" diagram) ----
//
// One SVG, drawn identically on every page; the page highlights its own
// component(s) via