fp/services/next/app/vt/[slug]/vods/[page]/page.tsx

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-07-10 22:11:18 +00:00
import VodsList, { VodsListHeading } from '@/app/components/vods-list';
import { getVtuberBySlug, getUrl } from '@/app/lib/vtubers';
import { IVodsResponse, getVodsForVtuber } from '@/app/lib/vods';
import Pager from '@/app/components/pager';
2024-01-20 16:16:14 +00:00
import { notFound } from 'next/navigation';
interface IPageParams {
params: {
slug: string;
page: string;
};
}
export default async function Page({ params }: IPageParams) {
let vtuber, vods;
const pageNumber = parseInt(params.page);
2024-12-12 07:23:46 +00:00
const pageSize = 24
2024-01-20 16:16:14 +00:00
try {
vtuber = await getVtuberBySlug(params.slug);
if (!vtuber) notFound();
vods = await getVodsForVtuber(vtuber.id, pageNumber, 24, true);
} catch (error) {
// Handle the error here (e.g., display an error message)
console.error("An error occurred:", error);
// You might also want to return an error page or message
return <div>Error: {JSON.stringify(error)}</div>;
}
if (!vods) return <p>error</p>
return (
<>
2024-12-12 07:23:46 +00:00
<VodsListHeading slug={vtuber.slug} displayName={vtuber.display_name} />
<VodsList vtuber={vtuber} vods={vods} page={pageNumber} pageSize={pageSize} />
2024-01-20 16:16:14 +00:00
<Pager
baseUrl={`/vt/${params.slug}/vods`}
page={parseInt(params.page)}
2024-12-12 07:23:46 +00:00
pageCount={vods.length/pageSize}
2024-01-20 16:16:14 +00:00
/>
</>
);
}