diff --git a/app/sitemap.xml/route.ts b/app/sitemap.xml/route.ts new file mode 100644 index 0000000..262ef86 --- /dev/null +++ b/app/sitemap.xml/route.ts @@ -0,0 +1,27 @@ +import { generateSitemaps } from "@/app/sitemap" +import { getBaseUrl } from "@/lib/sitemap-utils" + +export const revalidate = 3600 + +export async function GET() { + const baseUrl = getBaseUrl() + const sitemaps = await generateSitemaps() + + const entries = sitemaps + .map(({ id }) => ` \n ${baseUrl}/sitemap/${id}.xml\n `) + .join("\n") + + const xml = [ + ``, + ``, + entries, + ``, + ].join("\n") + + return new Response(xml, { + headers: { + "Content-Type": "application/xml", + "Cache-Control": "public, max-age=3600, s-maxage=3600, stale-while-revalidate=86400", + }, + }) +} \ No newline at end of file