feat(seo): slugged show urls, sr-only homepage intro, ISR detail pages

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
nerandClaude Fable 5 committed 2026-08-07 17:46:01 +03:00
1 parent ce630cd029
commit 735c63471a
11 files changed
+103 -28

No files matched your search

+14 -1
View File
@@ -1,3 +1,4 @@
import { cache } from 'react';
import { isServer, QueryClient } from '@tanstack/react-query';
const makeQueryClient = () => {
@@ -15,8 +16,20 @@ const makeQueryClient = () => {
let browserQueryClient: QueryClient | undefined = undefined;
// One client per server request (React cache is request-scoped), so generateMetadata
// and the page share fetches instead of hitting TMDB twice for the same data.
const getServerQueryClient = cache(makeQueryClient);
const getQueryClient = () => {
if (isServer) return makeQueryClient();
if (isServer) {
try {
return getServerQueryClient();
} catch (_) {
// cache() only works in the RSC runtime; the SSR pass of client components
// (e.g. Providers) lands here and keeps its own per-render client as before
return makeQueryClient();
}
}
if (!browserQueryClient) browserQueryClient = makeQueryClient();
+18
View File
@@ -3,6 +3,24 @@ import { twMerge } from 'tailwind-merge';
export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));
export const slugify = (value: string) =>
value
.toLowerCase()
.normalize('NFKD')
.replace(/[̀-ͯ]/g, '')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '')
.slice(0, 60)
.replace(/-+$/, '');
// Keyword-carrying show URL (/movie/27205-inception); the slug is optional decoration —
// routing only relies on the leading numeric id.
export const showPath = ({ type, id, title }: Pick<Show, 'type' | 'id' | 'title'>) => {
const slug = slugify(title || '');
return `/${type}/${id}${slug ? `-${slug}` : ''}`;
};
export const formatDate = (date: string) =>
new Intl.DateTimeFormat('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric', timeZone: 'UTC' })
.format(new Date(date))