feat(seo): JSON-LD for movies, series, persons, website

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
nerandClaude Fable 5 committed 2026-08-07 17:11:50 +03:00
1 parent cd34f4eb5f
commit ce630cd029
4 files changed
+65 -13

No files matched your search

+30 -6
View File
@@ -2,8 +2,9 @@ import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
import { Metadata } from 'next';
import { notFound } from 'next/navigation';
import JsonLd from '@/components/JsonLd';
import detailsQuery from '@/data/queries/details';
import { TITLE } from '@/env';
import { SITE_URL, TITLE } from '@/env';
import getQueryClient from '@/lib/queryClient';
import Container from './container';
@@ -46,14 +47,37 @@ export const createShowPage = (showType: Show['type']) => {
const showId = Number(id);
try {
await queryClient.fetchQuery(detailsQuery({ showId, showType }));
} catch (_) {
return notFound();
}
const details = await queryClient.fetchQuery(detailsQuery({ showId, showType })).catch(() => null);
if (!details) return notFound();
const jsonLd = {
'@context': 'https://schema.org',
'@type': showType === 'movie' ? 'Movie' : 'TVSeries',
name: details.title,
description: details.overview || undefined,
image: details.poster['2x'] || undefined,
datePublished: details.release || undefined,
genre: details.genres?.map(({ name }) => name),
url: `${SITE_URL}/${showType}/${showId}`,
...(showType === 'movie' && details.runtime ? { duration: `PT${details.runtime}M` } : {}),
...(details.imdb_id ? { sameAs: `https://www.imdb.com/title/${details.imdb_id}/` } : {}),
...(details.votes
? {
aggregateRating: {
'@type': 'AggregateRating',
ratingValue: Math.round(details.rating * 10) / 10,
ratingCount: details.votes,
bestRating: 10,
worstRating: 0
}
}
: {})
};
return (
<HydrationBoundary state={dehydrate(queryClient)}>
<JsonLd data={jsonLd} />
<Container showId={showId} showType={showType} />
</HydrationBoundary>
);