feat(seo): add metadata, sitemap, robots, JSON-LD, dynamic OG image
- Centralize brand/keyword config in lib/site.ts (slogan, 22 keywords). - Root layout: metadataBase, title template, OG/Twitter defaults, robots rules. - Per-page metadata: home, trips list (filter-aware), trip detail, profile (noindex). - Layout wrappers add metadata to client-component pages: login, register, create-trip. - Trip detail: generateMetadata + JSON-LD Event + BreadcrumbList (price, availability, rating). - Home page: JSON-LD Organization + WebSite + SearchAction (sitelink search). - app/sitemap.ts: dynamic sitemap pulling OPEN/FULL trips from Prisma. - app/robots.ts: disallow /api/, /profile, /create-trip; references sitemap. - app/trips/[id]/opengraph-image.tsx: dynamic 1200x630 OG image per trip with cover photo, title, mountain, date, price, brand badge. - Seeder: switch trip images from local SVG placeholders to real Unsplash CDN URLs. - Drop 18 obsolete seed SVGs from public/images/seed/. New env: NEXT_PUBLIC_SITE_URL (defaults to localhost:3000) — set to prod domain on deploy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { absoluteUrl } from "@/lib/site";
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const trips = await prisma.trip.findMany({
|
||||
where: { status: { in: ["OPEN", "FULL"] } },
|
||||
select: { id: true, updatedAt: true },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
});
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const staticEntries: MetadataRoute.Sitemap = [
|
||||
{
|
||||
url: absoluteUrl("/"),
|
||||
lastModified: now,
|
||||
changeFrequency: "daily",
|
||||
priority: 1,
|
||||
},
|
||||
{
|
||||
url: absoluteUrl("/trips"),
|
||||
lastModified: now,
|
||||
changeFrequency: "hourly",
|
||||
priority: 0.9,
|
||||
},
|
||||
{
|
||||
url: absoluteUrl("/register"),
|
||||
lastModified: now,
|
||||
changeFrequency: "yearly",
|
||||
priority: 0.3,
|
||||
},
|
||||
];
|
||||
|
||||
const tripEntries: MetadataRoute.Sitemap = trips.map((t) => ({
|
||||
url: absoluteUrl(`/trips/${t.id}`),
|
||||
lastModified: t.updatedAt,
|
||||
changeFrequency: "daily",
|
||||
priority: 0.8,
|
||||
}));
|
||||
|
||||
return [...staticEntries, ...tripEntries];
|
||||
}
|
||||
Reference in New Issue
Block a user