36 lines
915 B
TypeScript
36 lines
915 B
TypeScript
import { redirect } from 'next/navigation';
|
|
|
|
import Layout from "@/components/Layout";
|
|
|
|
import Video from "@/components/Pages/Video";
|
|
|
|
import { decodeVideoUrlPath } from '@/utils/string';
|
|
|
|
import { useLocale } from 'next-intl';
|
|
import { Platforms } from '@/meta/settings';
|
|
import { VideoAgent } from '@/utils/agent';
|
|
|
|
export default async function VideoPage({ params }: { params: { platform: Platforms, id: string } }) {
|
|
|
|
const { platform, id } = params
|
|
|
|
const locale = useLocale()
|
|
|
|
if (!platform || !Object.keys(Platforms).includes(platform)) {
|
|
redirect(`/${locale}/404`)
|
|
}
|
|
|
|
const decodedId = decodeVideoUrlPath(id)
|
|
|
|
const [data, related] = await new VideoAgent(platform).getVideo(decodedId)
|
|
|
|
//const [data, related] = await fetchVideoData(decodedId)
|
|
|
|
if (!data.lowResUrl) {
|
|
redirect(`/${locale}/404`)
|
|
}
|
|
|
|
return <Layout>
|
|
<Video id={id} data={data} related={related}/>
|
|
</Layout>
|
|
} |