enchance SEO for TV

This commit is contained in:
2025-06-24 18:10:41 +00:00
parent bb07b44490
commit ae85eda411

View File

@@ -1,4 +1,7 @@
import { Metadata } from 'next';
import TVShowPage from './TVShowPage'; import TVShowPage from './TVShowPage';
export const dynamic = 'force-dynamic';
import { tvShowsAPI } from '@/lib/neoApi'; import { tvShowsAPI } from '@/lib/neoApi';
interface PageProps { interface PageProps {
@@ -8,6 +11,25 @@ interface PageProps {
searchParams: { [key: string]: string | string[] | undefined }; searchParams: { [key: string]: string | string[] | undefined };
} }
// Generate SEO metadata
export async function generateMetadata(
props: { params: { id: string } }
): Promise<Metadata> {
try {
const showId = props.params.id;
const { data: show } = await tvShowsAPI.getTVShow(showId);
return {
title: `${show.name} - NeoMovies`,
description: show.overview,
};
} catch (error) {
console.error('Error generating TV metadata', error);
return {
title: 'Сериал - NeoMovies',
};
}
}
async function getData(id: string) { async function getData(id: string) {
try { try {
const response = await tvShowsAPI.getTVShow(id).then(res => res.data); const response = await tvShowsAPI.getTVShow(id).then(res => res.data);