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) <noreply@anthropic.com>
This commit is contained in:
1 parent
01792a9669
commit
0186c793f2
9 files changed
+87
-22
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import { createShowMetadata, createShowPage } from '../../showPage';
|
import { createShowMetadata, createShowPage } from '../../showPage';
|
||||||
|
|
||||||
export const revalidate = 86400;
|
export const revalidate = 604800;
|
||||||
|
|
||||||
export const generateStaticParams = async () => [];
|
export const generateStaticParams = async () => [];
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { notFound, permanentRedirect } from 'next/navigation';
|
|||||||
|
|
||||||
import JsonLd from '@/components/JsonLd';
|
import JsonLd from '@/components/JsonLd';
|
||||||
import detailsQuery from '@/data/queries/details';
|
import detailsQuery from '@/data/queries/details';
|
||||||
|
import similarQuery from '@/data/queries/similar';
|
||||||
import { SITE_URL, TITLE } from '@/env';
|
import { SITE_URL, TITLE } from '@/env';
|
||||||
import getQueryClient from '@/lib/queryClient';
|
import getQueryClient from '@/lib/queryClient';
|
||||||
import { isMissing, showPath } from '@/lib/utils';
|
import { isMissing, showPath } from '@/lib/utils';
|
||||||
@@ -36,7 +37,7 @@ export const createShowMetadata =
|
|||||||
title,
|
title,
|
||||||
description: overview,
|
description: overview,
|
||||||
siteName: TITLE,
|
siteName: TITLE,
|
||||||
images: [backdrop || poster['2x']],
|
images: [{ url: backdrop || poster['2x'], alt: title }],
|
||||||
type: showType === 'movie' ? 'video.movie' : 'video.tv_show',
|
type: showType === 'movie' ? 'video.movie' : 'video.tv_show',
|
||||||
url: path
|
url: path
|
||||||
}
|
}
|
||||||
@@ -68,6 +69,8 @@ export const createShowPage = (showType: Show['type']) => {
|
|||||||
|
|
||||||
if (decodeURIComponent(`/${showType}/${id}`) !== path) permanentRedirect(path);
|
if (decodeURIComponent(`/${showType}/${id}`) !== path) permanentRedirect(path);
|
||||||
|
|
||||||
|
await queryClient.prefetchQuery(similarQuery({ showId, showType, type: 'similar' }));
|
||||||
|
|
||||||
const jsonLd = {
|
const jsonLd = {
|
||||||
'@context': 'https://schema.org',
|
'@context': 'https://schema.org',
|
||||||
'@type': showType === 'movie' ? 'Movie' : 'TVSeries',
|
'@type': showType === 'movie' ? 'Movie' : 'TVSeries',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { createShowMetadata, createShowPage } from '../../showPage';
|
import { createShowMetadata, createShowPage } from '../../showPage';
|
||||||
|
|
||||||
export const revalidate = 86400;
|
export const revalidate = 604800;
|
||||||
|
|
||||||
export const generateStaticParams = async () => [];
|
export const generateStaticParams = async () => [];
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ interface Props {
|
|||||||
params: { id: string };
|
params: { id: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const revalidate = 86400;
|
export const revalidate = 604800;
|
||||||
|
|
||||||
export const generateStaticParams = async () => [];
|
export const generateStaticParams = async () => [];
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ export const generateMetadata = async ({ params: { id } }: Props): Promise<Metad
|
|||||||
title: name,
|
title: name,
|
||||||
description,
|
description,
|
||||||
siteName: TITLE,
|
siteName: TITLE,
|
||||||
images: photo ? [photo] : [],
|
images: photo ? [{ url: photo, alt: name }] : [],
|
||||||
type: 'profile',
|
type: 'profile',
|
||||||
url: `/person/${id}`
|
url: `/person/${id}`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,50 @@
|
|||||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
import JsonLd from '@/components/JsonLd';
|
||||||
import popularQuery from '@/data/queries/popular';
|
import popularQuery from '@/data/queries/popular';
|
||||||
import { TITLE } from '@/env';
|
import { TITLE } from '@/env';
|
||||||
|
import { itemList } from '@/lib/jsonLd';
|
||||||
import getQueryClient from '@/lib/queryClient';
|
import getQueryClient from '@/lib/queryClient';
|
||||||
|
|
||||||
import Container from './container';
|
import Container from './container';
|
||||||
|
|
||||||
|
const HEADING = 'Popular Movies';
|
||||||
|
|
||||||
|
const DESCRIPTION = `Check out the most popular movies right now on ${TITLE}. See what’s trending and don’t miss out on the latest hits.`;
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: `Popular Movies | ${TITLE}`,
|
title: `${HEADING} | ${TITLE}`,
|
||||||
description: `Check out the most popular movies right now on ${TITLE}. See what’s trending and don’t miss out on the latest hits.`,
|
description: DESCRIPTION,
|
||||||
alternates: { canonical: '/popular' }
|
alternates: { canonical: '/popular' },
|
||||||
|
openGraph: {
|
||||||
|
type: 'website',
|
||||||
|
siteName: TITLE,
|
||||||
|
title: HEADING,
|
||||||
|
description: DESCRIPTION,
|
||||||
|
url: '/popular'
|
||||||
|
},
|
||||||
|
twitter: {
|
||||||
|
title: HEADING,
|
||||||
|
description: DESCRIPTION
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Popular = async () => {
|
const Popular = async () => {
|
||||||
const queryClient = getQueryClient();
|
const queryClient = getQueryClient();
|
||||||
|
|
||||||
await queryClient.prefetchInfiniteQuery(popularQuery());
|
const query = popularQuery();
|
||||||
|
|
||||||
|
await queryClient.prefetchInfiniteQuery(query);
|
||||||
|
|
||||||
|
const shows = queryClient
|
||||||
|
.getQueryData<{ pages: Pagination<Show>[] }>(query.queryKey)
|
||||||
|
?.pages.flatMap(({ results }) => results);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||||
<h1 className='sr-only'>Popular Movies</h1>
|
{Boolean(shows?.length) && <JsonLd data={itemList(shows!)} />}
|
||||||
|
<h1 className='sr-only'>{HEADING}</h1>
|
||||||
<Container />
|
<Container />
|
||||||
</HydrationBoundary>
|
</HydrationBoundary>
|
||||||
);
|
);
|
||||||
|
|||||||
+29
-5
@@ -1,26 +1,50 @@
|
|||||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
import JsonLd from '@/components/JsonLd';
|
||||||
import popularQuery from '@/data/queries/popular';
|
import popularQuery from '@/data/queries/popular';
|
||||||
import { TITLE } from '@/env';
|
import { TITLE } from '@/env';
|
||||||
|
import { itemList } from '@/lib/jsonLd';
|
||||||
import getQueryClient from '@/lib/queryClient';
|
import getQueryClient from '@/lib/queryClient';
|
||||||
|
|
||||||
import Container from './container';
|
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 = {
|
export const metadata: Metadata = {
|
||||||
title: `Top Rated Movies | ${TITLE}`,
|
title: `${HEADING} | ${TITLE}`,
|
||||||
description: `Discover the top-rated movies on ${TITLE}. Find the highest-rated films and make informed viewing choices.`,
|
description: DESCRIPTION,
|
||||||
alternates: { canonical: '/top' }
|
alternates: { canonical: '/top' },
|
||||||
|
openGraph: {
|
||||||
|
type: 'website',
|
||||||
|
siteName: TITLE,
|
||||||
|
title: HEADING,
|
||||||
|
description: DESCRIPTION,
|
||||||
|
url: '/top'
|
||||||
|
},
|
||||||
|
twitter: {
|
||||||
|
title: HEADING,
|
||||||
|
description: DESCRIPTION
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Top = async () => {
|
const Top = async () => {
|
||||||
const queryClient = getQueryClient();
|
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<Show>[] }>(query.queryKey)
|
||||||
|
?.pages.flatMap(({ results }) => results);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||||
<h1 className='sr-only'>Top Rated Movies</h1>
|
{Boolean(shows?.length) && <JsonLd data={itemList(shows!)} />}
|
||||||
|
<h1 className='sr-only'>{HEADING}</h1>
|
||||||
<Container />
|
<Container />
|
||||||
</HydrationBoundary>
|
</HydrationBoundary>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ const Handlers: FC<Props> = ({ href, onClick, show }) => {
|
|||||||
|
|
||||||
if (!href) return <div {...handlers} />;
|
if (!href) return <div {...handlers} />;
|
||||||
|
|
||||||
return <Link {...handlers} href={href} prefetch={false} aria-label={show.title} />;
|
return (
|
||||||
|
<Link {...handlers} href={href} prefetch={false}>
|
||||||
|
<span className='sr-only'>{show.title}</span>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Handlers;
|
export default Handlers;
|
||||||
@@ -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
|
||||||
|
}))
|
||||||
|
});
|
||||||
@@ -3,13 +3,9 @@ const siteUrl = `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
siteUrl,
|
siteUrl,
|
||||||
generateRobotsTxt: true,
|
generateRobotsTxt: true,
|
||||||
exclude: ['/server-sitemap.xml'],
|
exclude: ['/server-sitemap.xml', '/opengraph-image', '/favorites', '/watchlist'],
|
||||||
robotsTxtOptions: {
|
robotsTxtOptions: {
|
||||||
policies: [
|
policies: [{ userAgent: '*', allow: '/' }],
|
||||||
{ userAgent: '*', allow: '/' },
|
|
||||||
{ userAgent: '*', disallow: '/favorites' },
|
|
||||||
{ userAgent: '*', disallow: '/watchlist' }
|
|
||||||
],
|
|
||||||
additionalSitemaps: [`${siteUrl}/server-sitemap.xml`]
|
additionalSitemaps: [`${siteUrl}/server-sitemap.xml`]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user