From 9b64f137f1928743820d8cca15108a7cfb0fb7bb Mon Sep 17 00:00:00 2001 From: ner Date: Fri, 7 Aug 2026 17:02:20 +0300 Subject: [PATCH] feat(seo): metadata API migration, canonicals, og images Co-Authored-By: Claude Fable 5 --- app/(site)/(favorites)/favorites/page.tsx | 3 ++- app/(site)/(favorites)/watchlist/page.tsx | 3 ++- app/(site)/(root)/page.tsx | 5 ++++ app/(site)/(show)/showPage.tsx | 14 ++++++---- app/(site)/person/[id]/page.tsx | 6 +++-- app/(site)/popular/page.tsx | 3 ++- app/(site)/top/page.tsx | 3 ++- app/layout.tsx | 27 +++++++++---------- app/opengraph-image.tsx | 32 +++++++++++++++++++++++ 9 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 app/opengraph-image.tsx diff --git a/app/(site)/(favorites)/favorites/page.tsx b/app/(site)/(favorites)/favorites/page.tsx index 241f460..9eb241e 100644 --- a/app/(site)/(favorites)/favorites/page.tsx +++ b/app/(site)/(favorites)/favorites/page.tsx @@ -6,7 +6,8 @@ import UsersList from '../components/UsersLists'; export const metadata: Metadata = { title: `My Favorite Shows | ${TITLE}`, - description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.` + description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.`, + robots: { index: false } }; const Favorites = () => { diff --git a/app/(site)/(favorites)/watchlist/page.tsx b/app/(site)/(favorites)/watchlist/page.tsx index a88e913..b4fa1bd 100644 --- a/app/(site)/(favorites)/watchlist/page.tsx +++ b/app/(site)/(favorites)/watchlist/page.tsx @@ -6,7 +6,8 @@ import UsersList from '../components/UsersLists'; export const metadata: Metadata = { title: `My watchlist | ${TITLE}`, - description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.` + description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.`, + robots: { index: false } }; const WatchList = async () => { diff --git a/app/(site)/(root)/page.tsx b/app/(site)/(root)/page.tsx index 374b72a..bfe2742 100644 --- a/app/(site)/(root)/page.tsx +++ b/app/(site)/(root)/page.tsx @@ -1,10 +1,15 @@ import { dehydrate, HydrationBoundary } from '@tanstack/react-query'; +import { Metadata } from 'next'; import randomQuery, { generatePage } from '@/data/queries/random'; import getQueryClient from '@/lib/queryClient'; import Container from './container'; +export const metadata: Metadata = { + alternates: { canonical: '/' } +}; + const Random = async () => { const queryClient = getQueryClient(); diff --git a/app/(site)/(show)/showPage.tsx b/app/(site)/(show)/showPage.tsx index 296fc79..7e449e9 100644 --- a/app/(site)/(show)/showPage.tsx +++ b/app/(site)/(show)/showPage.tsx @@ -3,7 +3,7 @@ import { Metadata } from 'next'; import { notFound } from 'next/navigation'; import detailsQuery from '@/data/queries/details'; -import { SITE_URL, TITLE } from '@/env'; +import { TITLE } from '@/env'; import getQueryClient from '@/lib/queryClient'; import Container from './container'; @@ -18,17 +18,21 @@ export const createShowMetadata = const queryClient = getQueryClient(); try { - const { title, overview, poster } = await queryClient.fetchQuery(detailsQuery({ showId: Number(id), showType })); + const { title, overview, poster, backdrop } = await queryClient.fetchQuery( + detailsQuery({ showId: Number(id), showType }) + ); return { title: `${title} | ${TITLE}`, description: overview, + alternates: { canonical: `/${showType}/${id}` }, openGraph: { title, description: overview, - images: [poster['2x']], - type: 'website', - url: `${SITE_URL}/${showType}/${id}` + siteName: TITLE, + images: [backdrop || poster['2x']], + type: showType === 'movie' ? 'video.movie' : 'video.tv_show', + url: `/${showType}/${id}` } }; } catch (_) { diff --git a/app/(site)/person/[id]/page.tsx b/app/(site)/person/[id]/page.tsx index a28cc59..cce0e36 100644 --- a/app/(site)/person/[id]/page.tsx +++ b/app/(site)/person/[id]/page.tsx @@ -5,7 +5,7 @@ import { notFound } from 'next/navigation'; import Person from '@/components/Person'; import personQuery from '@/data/queries/person'; -import { SITE_URL, TITLE } from '@/env'; +import { TITLE } from '@/env'; import getQueryClient from '@/lib/queryClient'; interface Props { @@ -23,12 +23,14 @@ export const generateMetadata = async ({ params: { id } }: Props): Promise { diff --git a/app/(site)/top/page.tsx b/app/(site)/top/page.tsx index 677c2d1..d16f063 100644 --- a/app/(site)/top/page.tsx +++ b/app/(site)/top/page.tsx @@ -9,7 +9,8 @@ import Container from './container'; export const metadata: Metadata = { title: `Top Rated Movies | ${TITLE}`, - description: `Discover the top-rated movies on ${TITLE}. Find the highest-rated films and make informed viewing choices.` + description: `Discover the top-rated movies on ${TITLE}. Find the highest-rated films and make informed viewing choices.`, + alternates: { canonical: '/top' } }; const Top = async () => { diff --git a/app/layout.tsx b/app/layout.tsx index 6916ddf..f355c43 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -10,9 +10,21 @@ import Providers from '@/providers'; import '@/styles/index.css'; +const DESCRIPTION = `Explore a diverse selection of movies with ${TITLE}. Get random movie recommendations and find out top-rated, popular, and user-favorite films.`; + export const metadata: Metadata = { + metadataBase: new URL(SITE_URL), title: `${TITLE} | Discover Your Next Favorite Movie`, - description: `Explore a diverse selection of movies with ${TITLE}. Get random movie recommendations and find out top-rated, popular, and user-favorite films.` + description: DESCRIPTION, + openGraph: { + type: 'website', + siteName: TITLE, + title: TITLE, + description: DESCRIPTION + }, + twitter: { + card: 'summary_large_image' + } }; export const viewport: Viewport = { @@ -53,19 +65,6 @@ const RootLayout = ({ children }: { children: ReactNode }) => { - - - - - - - - - - - - - diff --git a/app/opengraph-image.tsx b/app/opengraph-image.tsx new file mode 100644 index 0000000..3f5265e --- /dev/null +++ b/app/opengraph-image.tsx @@ -0,0 +1,32 @@ +import { ImageResponse } from 'next/og'; + +import { TITLE } from '@/env'; + +export const alt = `${TITLE} | Discover Your Next Favorite Movie`; +export const size = { width: 1200, height: 630 }; +export const contentType = 'image/png'; + +const Image = () => + new ImageResponse( + ( +
+
🍿 {TITLE}
+
Discover your next favorite movie
+
+ ), + size + ); + +export default Image;