Fix ZXDB pagination counters and navigation
Implement URL-driven pagination and correct total counts across ZXDB: - Root /zxdb: SSR reads ?page; client syncs to SSR; Prev/Next as Links. - Sub-index pages (genres, languages, machinetypes): parse ?page on server; use SSR props in clients; Prev/Next via Links. - Labels browse (/zxdb/labels): dynamic SSR, reads ?q & ?page; typed count(*); client syncs to SSR; Prev/Next preserve q. - Label detail (/zxdb/labels/[id]): tab-aware Prev/Next Links; counters from server. - Repo: replace raw counts with typed Drizzle count(*) for reliable totals. Signed-off-by: Junie <Junie@lucy.xalior.com>
This commit is contained in:
@@ -5,12 +5,16 @@ export const metadata = {
|
||||
title: "ZXDB Explorer",
|
||||
};
|
||||
|
||||
export const revalidate = 3600;
|
||||
// This page depends on searchParams (?page=, filters in future). Force dynamic
|
||||
// rendering so ISR doesn’t cache a single HTML for all query strings.
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function Page() {
|
||||
// Server-render initial page (no query) to avoid first client fetch
|
||||
export default async function Page({ searchParams }: { searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) {
|
||||
const sp = await searchParams;
|
||||
const page = Math.max(1, Number(Array.isArray(sp.page) ? sp.page[0] : sp.page) || 1);
|
||||
// Server-render initial page based on URL to avoid first client fetch and keep counter in sync
|
||||
const [initial, genres, langs, machines] = await Promise.all([
|
||||
searchEntries({ page: 1, pageSize: 20, sort: "id_desc" }),
|
||||
searchEntries({ page, pageSize: 20, sort: "id_desc" }),
|
||||
listGenres(),
|
||||
listLanguages(),
|
||||
listMachinetypes(),
|
||||
|
||||
Reference in New Issue
Block a user