buildmymcpserver/apps/web/app/sitemap.ts
Marco Sadjadi cba45402ce fix(seo): canonical self-deindexing on /docs/*, truthful llms.txt, real sitemap dates, RSS feed, breadcrumbs, per-article OG images
- /docs subpages canonicalized to /docs and had no descriptions; each now
  uses pageMetadata with its own path (was: Google could index at most one)
- llms.txt claimed Team EUR 149, RBAC/SLA and BYO-cloud that do not exist;
  regenerated from lib/seo.ts truth + new llms-full.txt with docs content
- sitemap stamped lastModified=now on every request; now real per-route dates
  from new lib/articles.ts registry (single source for guides index/sitemap/RSS)
- new /feed.xml RSS 2.0 route + alternates link in root layout
- articleJsonLd: image (per-guide opengraph-image via lib/og-article.tsx),
  Person author, wordCount; new breadcrumbJsonLd on guides + docs
- GSC verification via NEXT_PUBLIC_GSC_VERIFICATION (documented in .env.example)
- dropped fabricated Enterprise EUR 499 offer from SoftwareApplication JSON-LD
- article-shell: OL/Table/Note primitives for upcoming articles

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXUwmPVRTD8AKQtio6gCN5
2026-07-08 23:00:02 +02:00

74 lines
3.3 KiB
TypeScript

import { ARTICLES } from '@/lib/articles';
import { SITE_URL } from '@/lib/seo';
import { fetchPublicTemplateSlugs } from '@/lib/templates-server';
import type { MetadataRoute } from 'next';
type Entry = {
path: string;
priority: number;
changeFrequency: MetadataRoute.Sitemap[number]['changeFrequency'];
/** Real last-substantive-change date. Bump when the page meaningfully changes. */
lastModified: string;
};
// lastModified must reflect actual content changes — Google discounts sitemaps
// whose lastmod is always "now". Bump a route's date when you edit its page.
const ROUTES: Entry[] = [
{ path: '/', priority: 1.0, changeFrequency: 'weekly', lastModified: '2026-07-08' },
{ path: '/pricing', priority: 0.9, changeFrequency: 'weekly', lastModified: '2026-07-08' },
{ path: '/templates', priority: 0.9, changeFrequency: 'daily', lastModified: '2026-07-08' },
{ path: '/guides', priority: 0.8, changeFrequency: 'weekly', lastModified: '2026-07-08' },
{ path: '/docs', priority: 0.8, changeFrequency: 'weekly', lastModified: '2026-07-08' },
{ path: '/docs/concepts', priority: 0.7, changeFrequency: 'monthly', lastModified: '2026-07-08' },
{ path: '/docs/oauth', priority: 0.7, changeFrequency: 'monthly', lastModified: '2026-07-08' },
{ path: '/docs/authoring', priority: 0.7, changeFrequency: 'monthly', lastModified: '2026-07-08' },
{
path: '/docs/api-reference',
priority: 0.7,
changeFrequency: 'monthly',
lastModified: '2026-07-08',
},
{
path: '/docs/self-hosting',
priority: 0.7,
changeFrequency: 'monthly',
lastModified: '2026-07-08',
},
{ path: '/docs/faq', priority: 0.6, changeFrequency: 'monthly', lastModified: '2026-07-08' },
{ path: '/changelog', priority: 0.6, changeFrequency: 'weekly', lastModified: '2026-06-11' },
{ path: '/security', priority: 0.5, changeFrequency: 'monthly', lastModified: '2026-06-04' },
{ path: '/contact', priority: 0.4, changeFrequency: 'yearly', lastModified: '2026-06-04' },
{ path: '/status', priority: 0.4, changeFrequency: 'weekly', lastModified: '2026-06-04' },
{ path: '/privacy', priority: 0.3, changeFrequency: 'yearly', lastModified: '2026-06-29' },
{ path: '/terms', priority: 0.3, changeFrequency: 'yearly', lastModified: '2026-06-29' },
];
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const staticEntries: MetadataRoute.Sitemap = ROUTES.map((r) => ({
url: `${SITE_URL}${r.path}`,
lastModified: new Date(r.lastModified),
changeFrequency: r.changeFrequency,
priority: r.priority,
}));
// Guide articles come from the single registry, with their true dates.
const guideEntries: MetadataRoute.Sitemap = ARTICLES.map((a) => ({
url: `${SITE_URL}/guides/${a.slug}`,
lastModified: new Date(a.dateModified ?? a.datePublished),
changeFrequency: 'monthly',
priority: 0.8,
}));
// Marketplace templates — each public template is its own indexable page.
// Best-effort: if the API is unreachable the static entries still ship.
const slugs = await fetchPublicTemplateSlugs();
const templateEntries: MetadataRoute.Sitemap = slugs.map((slug) => ({
url: `${SITE_URL}/templates/${slug}`,
lastModified: new Date('2026-07-08'),
changeFrequency: 'weekly',
priority: 0.6,
}));
return [...staticEntries, ...guideEntries, ...templateEntries];
}