publish the routes a repo has pages for, so the spa loads only those as documents
Signed-off-by: dawn <90008@klbr.net>
15 unmodified lines16171819202021222315 unmodified lines
node verify.mjs <incremental out> <fresh out>
the newest sidebar of each ref is also at `<repo>/_latest/sidebar/<ref>.json`, for a pagethe SPA renders without a prerendered copy to name.the SPA renders without a prerendered copy to name, and the routes the repo has pages for at`<repo>/_latest/routes.json`, so the SPA loads only those as documents.
node --test15 unmodified lines1617181920212223242526275 unmodified lines15 unmodified linesexport const LATEST_DIR = "_latest";
export const latestPath = (name) => `${LATEST_DIR}/${name}.json`;
// the routes a repo has pages for, relative to its url: the SPA loads those as documents and// renders the rest itselfexport const ROUTES = "routes";
const NAMED = /_shared\/[0-9a-f]{16}\.json/g;
// a page kept from an older render names an older copy of the same thing, so an incremental// run matches a fresh one only with the names masked5 unmodified lines8 unmodified lines9101112131314151617537 unmodified linesExpand all55555655755855956056156256356456556656756867 unmodified lines8 unmodified linesimport { gzipSync } from "node:zlib";import { rankOf } from "./budget.mjs";import { atomicJson, fileOf, keyOfUrl, PAGE_QUERY, prefixOf, readJson, RENDERER_FORMAT, tokenOf } from "./common.mjs";import { canonicalHtml, linksOf } from "./html.mjs";import { latestPath, SHARED_DIR, sharedNamed, sharedOf, sharedPath } from "./shared.mjs";import { latestPath, ROUTES, SHARED_DIR, sharedNamed, sharedOf, sharedPath } from "./shared.mjs";
const { values: opts, positionals } = parseArgs({ allowPositionals: true, options: {537 unmodified linesExpand all await ensureDir(path.dirname(file)); await link(empty, file); await link(path.join(sharedDir, hash + ".json.gz"), file + ".gz"); } const routesFile = path.join(tmpDir, latestPath(ROUTES)); const routesGz = gzipSync(JSON.stringify({ routes: Object.keys(pages).map((route) => route.slice(prefix.length)).sort() })); await ensureDir(path.dirname(routesFile)); await link(empty, routesFile); await writeFile(routesFile + ".gz", routesGz); bytes += routesGz.length; stats.kept = Object.keys(pages).filter((route) => !rendered.has(route)).length; for (const route of overBudget) over.add(route); stats.over_budget = over.size; checkCurrent();67 unmodified lines