import { getCSS } from "../style/css"; import { TIMEZONE_CONFIG } from "../time/zones"; import { getWeekBounds, getAdjacentWeeks } from "../time/week"; import type { Preferences, TimezoneKey } from "../types"; import { escapeHtml } from "./utils"; export function renderPage(title: string, bodyContent: string, prefs: Preferences): string { const css = getCSS(); const weekBounds = getWeekBounds(prefs.week, prefs.tz); const { prev, next } = getAdjacentWeeks(prefs.week); const tzLinks = (Object.entries(TIMEZONE_CONFIG) as [TimezoneKey, { iana: string; label: string }][]) .map(([key, config]) => { const isCurrent = key === prefs.tz; const href = buildLink("/week", { ...prefs, tz: key }); return `${config.label}`; }) .join(" ยท "); const modeLinks = [ { key: "vcr", label: "VCR" }, { key: "all", label: "All Active" }, ] .map(({ key, label }) => { const isCurrent = key === prefs.mode; const href = buildLink("/week", { ...prefs, mode: key }); return `${label}`; }) .join(" | "); const themeLinks = [ { key: "light", label: "โ๏ธ Light" }, { key: "dark", label: "๐ Dark" }, { key: "system", label: "โ๏ธ System" }, ] .map(({ key, label }) => { const isCurrent = key === prefs.theme; const href = buildLink("/week", { ...prefs, theme: key }); return `${label}`; }) .join(" ยท "); const prevLink = buildLink("/week", { ...prefs, week: prev }); const nextLink = buildLink("/week", { ...prefs, week: next }); return `
Subject to change, not official