2025-06-24 18:10:41 +00:00
|
|
|
|
import { Metadata } from 'next';
|
2024-12-23 18:42:18 +00:00
|
|
|
|
import TVShowPage from './TVShowPage';
|
2025-06-24 18:10:41 +00:00
|
|
|
|
|
|
|
|
|
|
export const dynamic = 'force-dynamic';
|
2025-01-05 01:43:34 +00:00
|
|
|
|
import { tvShowsAPI } from '@/lib/neoApi';
|
2024-12-23 18:42:18 +00:00
|
|
|
|
|
|
|
|
|
|
interface PageProps {
|
|
|
|
|
|
params: {
|
|
|
|
|
|
id: string;
|
|
|
|
|
|
};
|
|
|
|
|
|
searchParams: { [key: string]: string | string[] | undefined };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-24 18:10:41 +00:00
|
|
|
|
// 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',
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-23 18:42:18 +00:00
|
|
|
|
async function getData(id: string) {
|
|
|
|
|
|
try {
|
2025-01-05 01:43:34 +00:00
|
|
|
|
const response = await tvShowsAPI.getTVShow(id).then(res => res.data);
|
|
|
|
|
|
return { id, show: response };
|
2024-12-23 18:42:18 +00:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('Error fetching show:', error);
|
|
|
|
|
|
return { id, show: null };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default async function Page(props: PageProps) {
|
2025-05-28 10:24:53 +00:00
|
|
|
|
// В Next.js 14 нужно сначала использовать параметры в асинхронной функции
|
|
|
|
|
|
try {
|
|
|
|
|
|
const tvShowId = props.params.id;
|
|
|
|
|
|
const data = await getData(tvShowId);
|
|
|
|
|
|
return <TVShowPage tvShowId={data.id} show={data.show} />;
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('Error loading TV show page:', error);
|
|
|
|
|
|
return <div>Ошибка загрузки страницы сериала</div>;
|
|
|
|
|
|
}
|
2024-12-23 18:42:18 +00:00
|
|
|
|
}
|