feat(seo): crawlable show links, intercepted preview modal, real 404s
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
919dcf9a42
commit
25a5d535a4
21 files changed
+231
-127
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { FC } from 'react';
|
||||
|
||||
import Preview from '@/components/Preview';
|
||||
import Trending from '@/components/Trending';
|
||||
|
||||
interface Props {
|
||||
showId: Show['id'];
|
||||
showType: Show['type'];
|
||||
}
|
||||
|
||||
const Container: FC<Props> = ({ showId, showType }) => (
|
||||
<div className='flex flex-1 flex-col'>
|
||||
<div className='xs:mb-4'>
|
||||
<Preview
|
||||
showId={showId}
|
||||
showType={showType}
|
||||
className='rounded-lg bg-background'
|
||||
posterClassName='md:rounded-lg'
|
||||
externalLink={false}
|
||||
/>
|
||||
<div className='h-2 w-full' />
|
||||
</div>
|
||||
<div className='hidden w-full rounded-lg xs:block'>
|
||||
<Trending preview showId={showId} showType={showType} />
|
||||
<div className='h-2 w-full' />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default Container;
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createShowMetadata, createShowPage } from '../../showPage';
|
||||
|
||||
export const generateMetadata = createShowMetadata('movie');
|
||||
|
||||
const MoviePage = createShowPage('movie');
|
||||
|
||||
export default MoviePage;
|
||||
@@ -0,0 +1,59 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import detailsQuery from '@/data/queries/details';
|
||||
import { SITE_URL, TITLE } from '@/env';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
interface Props {
|
||||
params: { id: string };
|
||||
}
|
||||
|
||||
export const createShowMetadata =
|
||||
(showType: Show['type']) =>
|
||||
async ({ params: { id } }: Props): Promise<Metadata> => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
try {
|
||||
const { title, overview, poster } = await queryClient.fetchQuery(detailsQuery({ showId: Number(id), showType }));
|
||||
|
||||
return {
|
||||
title: `${title} | ${TITLE}`,
|
||||
description: overview,
|
||||
openGraph: {
|
||||
title,
|
||||
description: overview,
|
||||
images: [poster['2x']],
|
||||
type: 'website',
|
||||
url: `${SITE_URL}/${showType}/${id}`
|
||||
}
|
||||
};
|
||||
} catch (_) {
|
||||
return notFound();
|
||||
}
|
||||
};
|
||||
|
||||
export const createShowPage = (showType: Show['type']) => {
|
||||
const ShowPage = async ({ params: { id } }: Props) => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const showId = Number(id);
|
||||
|
||||
try {
|
||||
await queryClient.fetchQuery(detailsQuery({ showId, showType }));
|
||||
} catch (_) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Container showId={showId} showType={showType} />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
return ShowPage;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createShowMetadata, createShowPage } from '../../showPage';
|
||||
|
||||
export const generateMetadata = createShowMetadata('tv');
|
||||
|
||||
const SeriesPage = createShowPage('tv');
|
||||
|
||||
export default SeriesPage;
|
||||
Reference in new issue
Block a user