// WHERE A BUILD SERVES ITS REPORTS — the base path every report path hangs off. // // One renderer (common/components/report/, read through ./reader-server.ts) // serves a report under whichever base its build gives it: a site serves its // own under SITE_REPORTS_BASE, and the homepage's articles will be served under // their own base (plans/reports-on-homepage.md). Every path helper in ./views.ts // and ./revisions.ts takes the base as its last argument and defaults to the // site's, so a caller that names none is a site's. // // Moments (`/m//`) and evidence clips (`/media/clips/…`) are not under a // base: one build serves one set of them, whichever reports cite them. // // Pure, no imports: the export site's pages and the browser can use it. // A base is a site-root path with a leading and a trailing slash: `/pages/`. export type ReportBase = `/${string}/`; // A site's reports: its pages (site.json `pages`), at `/pages//` (release // 26 A5; `/reports/` before it). export const SITE_REPORTS_BASE: ReportBase = "/pages/"; // The homepage's articles (plans/reports-on-homepage.md, A3): `/articles//`. export const ARTICLES_REPORTS_BASE: ReportBase = "/articles/"; // Where a site's reports were published before release 26: compose still // clears it from a public dir an older compose wrote. export const LEGACY_SITE_REPORTS_DIR = "reports"; const BASE_RE = /^\/(?:[a-z0-9][a-z0-9-]*\/)+$/; // Whether `v` is a usable base: lowercase path segments, slashes on both ends. export function isReportBase(v: unknown): v is ReportBase { return typeof v === "string" && BASE_RE.test(v); } // The base's top directory under a public dir or an out dir, `pages` for // `/pages/`. export function reportBaseDir(base: ReportBase): string { return base.split("/").filter(Boolean).join("/"); }