Persist the show-type filter in the path via a /series prefix: movies keep bare URLs, series use /series across random, popular, top, favorites and watchlist. The path is the single source of truth - the jotai atom is removed and the toggle navigates with router.replace so the server prefetches the target variant. Legacy ?type=tv deep links redirect to the prefixed URLs. Trending and similar/recommendations queries are now paginated and feed useInfiniteList like the main lists. Gallery wires fetchNextPage to a new ScrollNavigation onEndReached callback (fires within two slides of the end, once per approach), so all gallery tabs load more on scroll. The show page prefetches the first similar page with prefetchInfiniteQuery, and trending/similar/recommendations are added to the analytics ListName.
31 lines
847 B
TypeScript
31 lines
847 B
TypeScript
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
|
import { Metadata } from 'next';
|
|
|
|
import Container from '@/app/(site)/(root)/container';
|
|
import randomQuery, { generatePage } from '@/data/queries/random';
|
|
import { TITLE } from '@/env';
|
|
import getQueryClient from '@/lib/queryClient';
|
|
|
|
export const metadata: Metadata = {
|
|
alternates: { canonical: '/series' }
|
|
};
|
|
|
|
const Series = async () => {
|
|
const queryClient = getQueryClient();
|
|
|
|
const page = generatePage('tv');
|
|
|
|
await queryClient.prefetchInfiniteQuery(randomQuery({ page, type: 'tv' }));
|
|
|
|
return (
|
|
<HydrationBoundary state={dehydrate(queryClient)}>
|
|
<h1 className='sr-only'>{TITLE} — Discover Your Next Favorite Series</h1>
|
|
<Container page={page} type='tv' />
|
|
</HydrationBoundary>
|
|
);
|
|
};
|
|
|
|
export const revalidate = 1;
|
|
|
|
export default Series;
|