feat(show-type): global movie/series toggle, type-aware pages and search, ?type=tv in URL
This commit is contained in:
1 parent
5b41dbca10
commit
0824090c6d
21 files changed
+415
-174
No files matched your search
+35
-20
@@ -6,34 +6,49 @@ import popularQuery from '@/data/queries/popular';
|
||||
import { TITLE } from '@/env';
|
||||
import { itemList } from '@/lib/jsonLd';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
import { parseShowType } from '@/lib/showType';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
const HEADING = 'Top Rated Movies';
|
||||
interface SearchParams {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
const DESCRIPTION = `Discover the top-rated movies on ${TITLE}. Find the highest-rated films and make informed viewing choices.`;
|
||||
const heading = (type: Show['type']) => (type === 'tv' ? 'Top Rated Series' : 'Top Rated Movies');
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `${HEADING} | ${TITLE}`,
|
||||
description: DESCRIPTION,
|
||||
alternates: { canonical: '/top' },
|
||||
openGraph: {
|
||||
type: 'website',
|
||||
siteName: TITLE,
|
||||
title: HEADING,
|
||||
description: DESCRIPTION,
|
||||
url: '/top'
|
||||
},
|
||||
twitter: {
|
||||
title: HEADING,
|
||||
description: DESCRIPTION
|
||||
}
|
||||
const description = (type: Show['type']) =>
|
||||
type === 'tv'
|
||||
? `Discover the top-rated series on ${TITLE}. Find the highest-rated shows and make informed viewing choices.`
|
||||
: `Discover the top-rated movies on ${TITLE}. Find the highest-rated films and make informed viewing choices.`;
|
||||
|
||||
export const generateMetadata = ({ searchParams }: { searchParams: SearchParams }): Metadata => {
|
||||
const type = parseShowType(searchParams.type);
|
||||
const title = heading(type);
|
||||
const text = description(type);
|
||||
|
||||
return {
|
||||
title: `${title} | ${TITLE}`,
|
||||
description: text,
|
||||
alternates: { canonical: '/top' },
|
||||
openGraph: {
|
||||
type: 'website',
|
||||
siteName: TITLE,
|
||||
title,
|
||||
description: text,
|
||||
url: '/top'
|
||||
},
|
||||
twitter: {
|
||||
title,
|
||||
description: text
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const Top = async () => {
|
||||
const Top = async ({ searchParams }: { searchParams: SearchParams }) => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const query = popularQuery({ sortBy: 'vote_average.desc' });
|
||||
const type = parseShowType(searchParams.type);
|
||||
const query = popularQuery({ sortBy: 'vote_average.desc', type });
|
||||
|
||||
await queryClient.prefetchInfiniteQuery(query);
|
||||
|
||||
@@ -44,7 +59,7 @@ const Top = async () => {
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
{Boolean(shows?.length) && <JsonLd data={itemList(shows!)} />}
|
||||
<h1 className='sr-only'>{HEADING}</h1>
|
||||
<h1 className='sr-only'>{heading(type)}</h1>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user