SPB Git forge

spb/cancerindex

Public
37commits 1branches 0releases
2.9 MBsize
maindefault branch
10 days agolast push
TypeScript 97.2% SQL 1.5% CSS 0.6% JavaScript 0.5%
1.2 KB · 22 lines typescript
Raw Blame History
1import { urlsetXml, type Entry } from '@/lib/sitemap';2import { geographySlugsForSitemap } from '@/lib/queries/geography';3import { SITE_URL } from '@/lib/site';4import { toDate } from '@/lib/format';56export const dynamic = 'force-dynamic';78/**9 * Sitemap chunk for geography routes: /countries, /compare and one /country/<slug> per geography that has10 * epidemiology observations. Static segment, so it takes precedence over /sitemap/[id] without touching it.11 */12export async function GET() {13  const now = new Date();14  const geos = await geographySlugsForSitemap();15  const entries: Entry[] = [16    { url: `${SITE_URL}/countries`, lastModified: geos.map((g) => toDate(g.updated_at)).filter((d): d is Date => !!d).sort((a, b) => b.getTime() - a.getTime())[0] ?? now, changeFrequency: 'weekly', priority: 0.7 },17    { url: `${SITE_URL}/compare`, lastModified: now, changeFrequency: 'weekly', priority: 0.5 },18    ...geos.map((g) => ({ url: `${SITE_URL}/country/${g.slug}`, lastModified: toDate(g.updated_at) ?? now, changeFrequency: 'weekly' as const, priority: 0.7 })),19  ];20  return new Response(urlsetXml(entries), { headers: { 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, max-age=3600' } });21}22