TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { NextResponse } from 'next/server';2import { countAssets } from '@/lib/queries/assets';34export const dynamic = 'force-dynamic';56const SITE = process.env.NEXT_PUBLIC_SITE_URL ?? 'https://www.rareindex.io';7const PAGE = 20_000;89/** Sitemap index: /sitemap/0.xml (static + categories + indices + sets) then paginated asset sitemaps. */10export async function GET() {11 let n = 0;12 try {13 n = await countAssets();14 } catch {15 n = 0;16 }17 const pages = 1 + Math.max(1, Math.ceil(n / PAGE));18 const now = new Date().toISOString();19 const body = `<?xml version="1.0" encoding="UTF-8"?>\n<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${Array.from({ length: pages }, (_, i) => ` <sitemap><loc>${SITE}/sitemap/${i}.xml</loc><lastmod>${now}</lastmod></sitemap>`).join('\n')}\n</sitemapindex>\n`;20 return new NextResponse(body, { headers: { 'content-type': 'application/xml; charset=utf-8', 'cache-control': 'public, max-age=3600' } });21}22