import { notFound } from "next/navigation"
import { env } from "@/env/server"
import { getLastUpdated, getSitemapIds } from "@/utils/sitemap"
export const dynamic = "force-dynamic"
export async function GET() {
if (env.HIDE_FOR_NEXT_RELEASE) {
notFound()
}
const lastUpdated = await getLastUpdated()
const sitemaps = await getSitemapIds()
const urls = sitemaps.map(
(id) => `
${env.PUBLIC_URL}/sitemap-${id}.xml
${lastUpdated}
`
)
const sitemapIndexXML = `\n${urls.join("")}\n`
return new Response(sitemapIndexXML, {
headers: { "Content-Type": "text/xml" },
})
}