import type { RouteLayoutGroup } from "../../../contracts/routes.ts"; import { TECH_LOG_ROUTE_REGISTRY } from "../contracts/tech-log-route-contract.ts"; /** * The navigation entries for one shell, derived from the route contract. * * Both headers used to carry their own literal list of `{ label, path }`. That * made the route contract and the header two sources for the same three facts — * which routes are navigable, what they are called, and in what order — and * nothing kept them in step: a renamed route or a changed order stayed correct * in one place and silently stale in the other. * * `navigationOrder` is what makes a route navigable; a route with `null` is * reachable but never advertised. */ export type TechLogNavigationEntry = Readonly<{ routeId: string; path: string; label: string; }>; export function techLogNavigation( layoutGroup: RouteLayoutGroup, ): readonly TechLogNavigationEntry[] { return Object.freeze( Object.values(TECH_LOG_ROUTE_REGISTRY) .filter( (definition) => definition.layoutGroup === layoutGroup && definition.navigationOrder !== null && definition.navigationLabel !== null, ) .sort( (left, right) => (left.navigationOrder ?? 0) - (right.navigationOrder ?? 0), ) .map((definition) => Object.freeze({ routeId: definition.routeId, path: definition.path, label: definition.navigationLabel as string, }), ), ); }