From 0186c793f26837560df35f254ca77dae1c9efe4b Mon Sep 17 00:00:00 2001 From: ner Date: Fri, 14 Aug 2026 11:23:00 +0300 Subject: [PATCH] feat(seo): crawlable card links, listing metadata, similar prefetch Following links reached only 37 of 1873 urls and the frontier was exhausted at depth 3, because detail pages rendered no internal links server side. - Prefetch similar shows on detail pages so their links land in the ssr html. Crawl reach goes from 37 pages to 782 and keeps growing. Credits are left client side on purpose: dehydrating aggregate_credits pushed a series page from 52kb to 600kb to surface only ten person links. - Replace the aria-label on poster links with sr-only text, so the anchors carry real anchor text instead of being empty. Text content is also a better accessible name than aria-label. - Give popular and top their own openGraph and twitter tags. They inherited the generic homepage title and description. - Add og:image:alt on movie, tv and person pages. - Add ItemList json-ld to the listing pages. - Drop favorites, watchlist and opengraph-image from the sitemap, and remove the robots.txt disallow that kept crawlers from reading their noindex. - Raise detail revalidate to a week. Cast and release dates barely move, and it cuts regenerations, isr writes and origin transfer sevenfold now that more pages get crawled. Co-Authored-By: Claude Opus 5 (1M context) --- app/(site)/(show)/movie/[id]/page.tsx | 2 +- app/(site)/(show)/showPage.tsx | 5 ++- app/(site)/(show)/tv/[id]/page.tsx | 2 +- app/(site)/person/[id]/page.tsx | 4 +-- app/(site)/popular/page.tsx | 34 ++++++++++++++++--- app/(site)/top/page.tsx | 34 ++++++++++++++++--- .../Poster/components/Handlers/index.tsx | 6 +++- lib/jsonLd.ts | 14 ++++++++ next-sitemap.config.js | 8 ++--- 9 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 lib/jsonLd.ts diff --git a/app/(site)/(show)/movie/[id]/page.tsx b/app/(site)/(show)/movie/[id]/page.tsx index 942663f..0ddc1c2 100644 --- a/app/(site)/(show)/movie/[id]/page.tsx +++ b/app/(site)/(show)/movie/[id]/page.tsx @@ -1,6 +1,6 @@ import { createShowMetadata, createShowPage } from '../../showPage'; -export const revalidate = 86400; +export const revalidate = 604800; export const generateStaticParams = async () => []; diff --git a/app/(site)/(show)/showPage.tsx b/app/(site)/(show)/showPage.tsx index f944657..713d4cc 100644 --- a/app/(site)/(show)/showPage.tsx +++ b/app/(site)/(show)/showPage.tsx @@ -4,6 +4,7 @@ import { notFound, permanentRedirect } from 'next/navigation'; import JsonLd from '@/components/JsonLd'; import detailsQuery from '@/data/queries/details'; +import similarQuery from '@/data/queries/similar'; import { SITE_URL, TITLE } from '@/env'; import getQueryClient from '@/lib/queryClient'; import { isMissing, showPath } from '@/lib/utils'; @@ -36,7 +37,7 @@ export const createShowMetadata = title, description: overview, siteName: TITLE, - images: [backdrop || poster['2x']], + images: [{ url: backdrop || poster['2x'], alt: title }], type: showType === 'movie' ? 'video.movie' : 'video.tv_show', url: path } @@ -68,6 +69,8 @@ export const createShowPage = (showType: Show['type']) => { if (decodeURIComponent(`/${showType}/${id}`) !== path) permanentRedirect(path); + await queryClient.prefetchQuery(similarQuery({ showId, showType, type: 'similar' })); + const jsonLd = { '@context': 'https://schema.org', '@type': showType === 'movie' ? 'Movie' : 'TVSeries', diff --git a/app/(site)/(show)/tv/[id]/page.tsx b/app/(site)/(show)/tv/[id]/page.tsx index 7fe3852..a270f3f 100644 --- a/app/(site)/(show)/tv/[id]/page.tsx +++ b/app/(site)/(show)/tv/[id]/page.tsx @@ -1,6 +1,6 @@ import { createShowMetadata, createShowPage } from '../../showPage'; -export const revalidate = 86400; +export const revalidate = 604800; export const generateStaticParams = async () => []; diff --git a/app/(site)/person/[id]/page.tsx b/app/(site)/person/[id]/page.tsx index 3b07e1e..6014fbf 100644 --- a/app/(site)/person/[id]/page.tsx +++ b/app/(site)/person/[id]/page.tsx @@ -14,7 +14,7 @@ interface Props { params: { id: string }; } -export const revalidate = 86400; +export const revalidate = 604800; export const generateStaticParams = async () => []; @@ -34,7 +34,7 @@ export const generateMetadata = async ({ params: { id } }: Props): Promise { const queryClient = getQueryClient(); - await queryClient.prefetchInfiniteQuery(popularQuery()); + const query = popularQuery(); + + await queryClient.prefetchInfiniteQuery(query); + + const shows = queryClient + .getQueryData<{ pages: Pagination[] }>(query.queryKey) + ?.pages.flatMap(({ results }) => results); return ( -

Popular Movies

+ {Boolean(shows?.length) && } +

{HEADING}

); diff --git a/app/(site)/top/page.tsx b/app/(site)/top/page.tsx index 56fb2ef..7d2af21 100644 --- a/app/(site)/top/page.tsx +++ b/app/(site)/top/page.tsx @@ -1,26 +1,50 @@ import { dehydrate, HydrationBoundary } from '@tanstack/react-query'; import { Metadata } from 'next'; +import JsonLd from '@/components/JsonLd'; import popularQuery from '@/data/queries/popular'; import { TITLE } from '@/env'; +import { itemList } from '@/lib/jsonLd'; import getQueryClient from '@/lib/queryClient'; import Container from './container'; +const HEADING = 'Top Rated Movies'; + +const DESCRIPTION = `Discover the top-rated movies on ${TITLE}. Find the highest-rated films and make informed viewing choices.`; + 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.`, - alternates: { canonical: '/top' } + 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 Top = async () => { const queryClient = getQueryClient(); - await queryClient.prefetchInfiniteQuery(popularQuery({ sortBy: 'vote_average.desc' })); + const query = popularQuery({ sortBy: 'vote_average.desc' }); + + await queryClient.prefetchInfiniteQuery(query); + + const shows = queryClient + .getQueryData<{ pages: Pagination[] }>(query.queryKey) + ?.pages.flatMap(({ results }) => results); return ( -

Top Rated Movies

+ {Boolean(shows?.length) && } +

{HEADING}

); diff --git a/components/Poster/components/Handlers/index.tsx b/components/Poster/components/Handlers/index.tsx index 015561d..3c67c36 100644 --- a/components/Poster/components/Handlers/index.tsx +++ b/components/Poster/components/Handlers/index.tsx @@ -31,7 +31,11 @@ const Handlers: FC = ({ href, onClick, show }) => { if (!href) return
; - return ; + return ( + + {show.title} + + ); }; export default Handlers; diff --git a/lib/jsonLd.ts b/lib/jsonLd.ts new file mode 100644 index 0000000..e43e525 --- /dev/null +++ b/lib/jsonLd.ts @@ -0,0 +1,14 @@ +import { SITE_URL } from '@/env'; + +import { showPath } from './utils'; + +export const itemList = (shows: Show[]) => ({ + '@context': 'https://schema.org', + '@type': 'ItemList', + itemListElement: shows.map((show, index) => ({ + '@type': 'ListItem', + position: index + 1, + url: `${SITE_URL}${showPath(show)}`, + name: show.title + })) +}); diff --git a/next-sitemap.config.js b/next-sitemap.config.js index c5e461f..1346bfb 100644 --- a/next-sitemap.config.js +++ b/next-sitemap.config.js @@ -3,13 +3,9 @@ const siteUrl = `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL module.exports = { siteUrl, generateRobotsTxt: true, - exclude: ['/server-sitemap.xml'], + exclude: ['/server-sitemap.xml', '/opengraph-image', '/favorites', '/watchlist'], robotsTxtOptions: { - policies: [ - { userAgent: '*', allow: '/' }, - { userAgent: '*', disallow: '/favorites' }, - { userAgent: '*', disallow: '/watchlist' } - ], + policies: [{ userAgent: '*', allow: '/' }], additionalSitemaps: [`${siteUrl}/server-sitemap.xml`] } };