Files
Rami BitarandClaude Opus 5 0263a59c6a Add page metadata across every route
The root layout exported no metadata, so routes without their own export
rendered no title at all, and no route had a description. Add a root
metadata block with a title template, Open Graph and Twitter defaults,
and fill in the routes that were missing tags.

- config/site.ts: description and env-driven absolute url for metadataBase
- home, /collections and /shop/collections: titles and descriptions
- products/[handle] and collections/[handle]: generateMetadata off the
  existing catalog fetchers, with canonical and OG image
- existing titles: drop the hand-written " — Shop" suffix now that the
  root template appends it

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011x5jT4fJJCnqPx3umEvXRk
2026-08-09 09:35:57 -04:00

53 lines
1.3 KiB
TypeScript

import { notFound } from 'next/navigation';
import { getShopPolicy, POLICY_HANDLES } from '@/hooks/use-shopify-policies';
import { site } from '@/config/site';
export function generateStaticParams() {
return POLICY_HANDLES.map((handle) => ({ handle }));
}
export async function generateMetadata({
params,
}: {
params: Promise<{ handle: string }>;
}) {
const { handle } = await params;
const policy = await getShopPolicy(handle);
if (!policy) return { title: 'Policy' };
return {
title: policy.title,
description: `Read the ${policy.title.toLowerCase()} for ${site.storeName}.`,
alternates: { canonical: `/policies/${policy.handle}` },
};
}
export default async function PolicyPage({
params,
}: {
params: Promise<{ handle: string }>;
}) {
const { handle } = await params;
const policy = await getShopPolicy(handle);
if (!policy) {
notFound();
}
return (
<main className="max-w-screen-2xl mx-auto w-full px-5 lg:px-10 py-16">
<div className="max-w-2xl mx-auto">
<h1 className="text-3xl md:text-4xl font-normal text-foreground">
{policy.title}
</h1>
<div
className="policy-body mt-8 text-[15px] leading-7 text-foreground"
dangerouslySetInnerHTML={{ __html: policy.body }}
/>
</div>
</main>
);
}