feat: show page meta
This commit is contained in:
1 parent
bbae7abaf5
commit
063a2494ae
2 files changed
+30
-1
No files matched your search
@@ -1,8 +1,10 @@
|
||||
import { FC } from 'react';
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { Metadata } from 'next';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import detailsQuery from '@/data/queries/details';
|
||||
import { SITE_URL, TITLE } from '@/env';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
@@ -11,6 +13,32 @@ interface Props {
|
||||
params: { show: [Show['type'], Show['id']] };
|
||||
}
|
||||
|
||||
export const generateMetadata = async ({ params: { show } }: Props): Promise<Metadata> => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const [showType, showId] = show as [Show['type'], Show['id']];
|
||||
|
||||
if (!showType || !showId) return redirect('/');
|
||||
|
||||
try {
|
||||
const { title, overview, poster } = await queryClient.fetchQuery(detailsQuery({ showId, showType }));
|
||||
|
||||
return {
|
||||
title: `${title} | ${TITLE}`,
|
||||
description: overview,
|
||||
openGraph: {
|
||||
title: `${title} | ${TITLE}`,
|
||||
description: overview,
|
||||
images: [poster['2x']],
|
||||
type: 'website',
|
||||
url: `${SITE_URL}/${showType}/${showId}`
|
||||
}
|
||||
};
|
||||
} catch (_) {
|
||||
return redirect('/');
|
||||
}
|
||||
};
|
||||
|
||||
const ShowPage: FC<Props> = async ({ params: { show } }) => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
|
||||
+2
-1
@@ -56,12 +56,13 @@ const Actions: FC<Props> = ({ torrent, backdrop, title, provider }) => {
|
||||
<Button variant='outline' className='relative grow-0 px-3' title='Download m3u playlist'>
|
||||
<a
|
||||
className='absolute left-0 top-0 size-full'
|
||||
target='_blank'
|
||||
href={`${STREAM_URL}?m3u&link=${encodeURIComponent(magnet)}`}
|
||||
/>
|
||||
<ListVideo size={20} />
|
||||
</Button>
|
||||
<Button className='relative grow-0 px-3' variant='outline' title='Download magnet'>
|
||||
<a className='absolute left-0 top-0 size-full' href={magnet} />
|
||||
<a className='absolute left-0 top-0 size-full' target='_blank' href={magnet} />
|
||||
<Magnet size={20} />
|
||||
</Button>
|
||||
{supportedForCast && (
|
||||
|
||||
Reference in new issue
Block a user