Files
bookhoard/web/src/series.ts
T
John O'Keefe 3daa834a94 refactor(series): drop the TS rendering twin; library switch navigates SSR
web/src/series.ts carried a full TypeScript twin of the templ page —
cards and paginator rendered via innerHTML from /api/series JSON,
always hardcoded to page 1. Combined with the header restore dispatch
(previous commit) it made every /series load stomp server-rendered
pagination back to page 1, which is the paginator bug reported on prod
(9 pages of series, Next kept landing on page 1, per-library only).

Rendering ownership (AGENTS.md): this page now has NO client renderer.
- grid and paginator are rendered only by templates/series.templ
- a library switch is a plain SSR navigation to
  /series?library_id=...&page=1, keeping the URL the single source of
  truth for both library and page state
- drops the duplicate /api/series fetch that ran on every page load

rendering-allowlist.txt: series.ts baseline entry removed — the file
no longer builds HTML anywhere.
2026-10-19 12:39:09 -04:00

23 lines
881 B
TypeScript

import { Alpine } from "./alpine";
import { initLibrarySwitcher } from "./library-switcher";
// Rendering ownership (AGENTS.md): the series grid and its paginator are
// rendered by templates/series.templ. This page intentionally has NO
// TypeScript renderer — the old one here duplicated the templ markup via
// innerHTML and re-fetched at hardcoded page 1, stomping SSR pagination
// whenever the header's library restore fired. A library switch is a plain
// SSR navigation so the URL stays the single source of truth for
// library_id and page state.
function navigateToSeries(libraryId: string): void {
const param = libraryId ? `library_id=${encodeURIComponent(libraryId)}&` : "";
window.location.href = `/series?${param}page=1`;
}
Alpine.data("seriesPage", () => ({
initSeriesPage() {
initLibrarySwitcher({
onSwitch: navigateToSeries,
});
},
}));