2025-06-24 18:10:41 +00:00
|
|
|
import { Metadata } from 'next';
|
2025-08-07 18:33:28 +00:00
|
|
|
import { tvShowsAPI } from '@/lib/neoApi';
|
2025-07-08 00:15:55 +03:00
|
|
|
import TVPage from '@/app/tv/[id]/TVPage';
|
2025-06-24 18:10:41 +00:00
|
|
|
|
|
|
|
|
export const dynamic = 'force-dynamic';
|
2024-12-23 18:42:18 +00:00
|
|
|
|
|
|
|
|
interface PageProps {
|
|
|
|
|
params: {
|
|
|
|
|
id: string;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-08 00:15:55 +03:00
|
|
|
export async function generateMetadata(props: Promise<PageProps>): Promise<Metadata> {
|
|
|
|
|
const { params } = await props;
|
2025-06-24 18:10:41 +00:00
|
|
|
try {
|
2025-07-08 00:15:55 +03:00
|
|
|
const showId = params.id;
|
2025-08-07 18:33:28 +00:00
|
|
|
const { data: show } = await tvShowsAPI.getTVShow(showId);
|
2025-07-08 00:15:55 +03:00
|
|
|
|
2025-06-24 18:10:41 +00:00
|
|
|
return {
|
|
|
|
|
title: `${show.name} - NeoMovies`,
|
|
|
|
|
description: show.overview,
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
2025-07-08 00:15:55 +03:00
|
|
|
console.error('Error generating metadata:', error);
|
2025-06-24 18:10:41 +00:00
|
|
|
return {
|
|
|
|
|
title: 'Сериал - NeoMovies',
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-23 18:42:18 +00:00
|
|
|
async function getData(id: string) {
|
|
|
|
|
try {
|
2025-08-07 18:33:28 +00:00
|
|
|
const { data: show } = await tvShowsAPI.getTVShow(id);
|
2025-07-08 00:15:55 +03:00
|
|
|
return { id, show };
|
2024-12-23 18:42:18 +00:00
|
|
|
} catch (error) {
|
2025-07-08 00:15:55 +03:00
|
|
|
throw new Error('Failed to fetch TV show');
|
2024-12-23 18:42:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-08 00:15:55 +03:00
|
|
|
export default async function Page({ params }: PageProps) {
|
|
|
|
|
const { id } = params;
|
|
|
|
|
const data = await getData(id);
|
|
|
|
|
return <TVPage showId={data.id} show={data.show} />;
|
2024-12-23 18:42:18 +00:00
|
|
|
}
|