From 063a2494aec1d2aef259f8679726004040991a9e Mon Sep 17 00:00:00 2001 From: ner Date: Sat, 16 Nov 2024 18:50:18 +0200 Subject: [PATCH] feat: show page meta --- app/(site)/[...show]/page.tsx | 28 +++++++++++++++++++ .../components/Actions/index.tsx | 3 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/(site)/[...show]/page.tsx b/app/(site)/[...show]/page.tsx index 482e962..ee3aa1e 100644 --- a/app/(site)/[...show]/page.tsx +++ b/app/(site)/[...show]/page.tsx @@ -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 => { + 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 = async ({ params: { show } }) => { const queryClient = getQueryClient(); diff --git a/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx b/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx index 576d1fb..d8c6563 100644 --- a/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx +++ b/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx @@ -56,12 +56,13 @@ const Actions: FC = ({ torrent, backdrop, title, provider }) => { {supportedForCast && (