refactor: extract render utils and polish page shell
Share time/HTML/live helpers across renderers; rename mode to All Active, add footer timezone label and header emoji. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@ 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();
|
||||
@@ -18,7 +19,7 @@ export function renderPage(title: string, bodyContent: string, prefs: Preference
|
||||
|
||||
const modeLinks = [
|
||||
{ key: "vcr", label: "VCR" },
|
||||
{ key: "all", label: "All Shows" },
|
||||
{ key: "all", label: "All Active" },
|
||||
]
|
||||
.map(({ key, label }) => {
|
||||
const isCurrent = key === prefs.mode;
|
||||
@@ -52,7 +53,7 @@ export function renderPage(title: string, bodyContent: string, prefs: Preference
|
||||
</head>
|
||||
<body>
|
||||
<header class="site-header">
|
||||
<h1 class="site-title"><a href="/week">VCR Calendar</a></h1>
|
||||
<h1 class="site-title"><a href="/week">📻 VCR Calendar</a></h1>
|
||||
<nav class="controls-bar">
|
||||
<div class="controls-row">${modeLinks}</div>
|
||||
<div class="controls-row">
|
||||
@@ -66,6 +67,7 @@ export function renderPage(title: string, bodyContent: string, prefs: Preference
|
||||
</header>
|
||||
<main>${bodyContent}</main>
|
||||
<footer class="site-footer">
|
||||
<p>Times shown in ${escapeHtml(TIMEZONE_CONFIG[prefs.tz].label)}</p>
|
||||
<p>voidzero Community Radio</p>
|
||||
</footer>
|
||||
</body>
|
||||
@@ -82,6 +84,3 @@ function buildLink(path: string, prefs: Record<string, string>): string {
|
||||
return qs ? `${path}?${qs}` : path;
|
||||
}
|
||||
|
||||
function escapeHtml(s: string): string {
|
||||
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user