Repository Public
1// Auteur : Simon-Pierre Boucher — contact@spboucher.ai2// Index de sitemaps (protocole sitemaps.org) : le sitemap des pages3// (/sitemap.xml) + les ~84 sitemaps des fiches (/estimation/sitemap/N.xml).4// C'est l'URL à soumettre dans Google Search Console.5import { getDb } from "@/lib/db";6import { SITE_URL } from "@/lib/seo";78export const dynamic = "force-dynamic";910const CHUNK = 45_000;1112export async function GET(): Promise<Response> {13 const max = (14 getDb().prepare("SELECT MAX(rowid) AS m FROM units").get() as { m: number }15 ).m;16 const n = Math.ceil(max / CHUNK);17 const locs = [18 `${SITE_URL}/sitemap.xml`,19 ...Array.from({ length: n }, (_, i) => `${SITE_URL}/estimation/sitemap/${i}.xml`),20 ];21 const xml =22 `<?xml version="1.0" encoding="UTF-8"?>\n` +23 `<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` +24 locs.map((l) => ` <sitemap><loc>${l}</loc></sitemap>`).join("\n") +25 `\n</sitemapindex>\n`;26 return new Response(xml, {27 headers: {28 "Content-Type": "application/xml; charset=utf-8",29 "Cache-Control": "public, max-age=3600",30 },31 });32}33