Files
siftlode/frontend/src/lib/pageMeta.ts
T
peter 2d4ecdb6c5 refactor(api): honest FeedResponse; derive pageTitleKey from the registry (R7 S3a·2-3)
- FeedResponse claimed a required `limit`, but /api/search/youtube never
  returns it (only /api/feed does) and nothing in the app reads it. Drop the
  field so searchYoutube's Promise<FeedResponse> stops lying; documented for
  re-add if a consumer appears.
- pageMeta's hand-written 13-case Page->title switch now derives from the
  ModuleDef registry via a new optional `titleKey` (the longer tab title, e.g.
  "Channel manager"; falls back to the short nav labelKey). A new page is one
  touch (add it to MODULES) instead of also editing a switch. A test pins all
  13 title keys byte-identical to the old switch (suite 74).
2026-07-27 22:45:30 +02:00

13 lines
658 B
TypeScript

import type { Page } from "./urlState";
import { moduleDef } from "./modules";
// The i18n key for a page's human title — shared by the top-bar header and the browser tab title so
// the two never drift. Derived from the single ModuleDef registry (modules.ts): a module's optional
// `titleKey` is the longer, descriptive tab title (e.g. "Channel manager"), falling back to its
// short nav `labelKey` when the two are the same. Registering a new Page is then one touch (add it
// to MODULES) instead of also editing a switch here.
export function pageTitleKey(page: Page): string {
const def = moduleDef(page);
return def.titleKey ?? def.labelKey;
}