diff --git a/docs/src/app/sitemap.xml/route.ts b/docs/src/app/sitemap.xml/route.ts new file mode 100644 index 000000000..2325d32d3 --- /dev/null +++ b/docs/src/app/sitemap.xml/route.ts @@ -0,0 +1,31 @@ +import { apiSource, source } from '../../../lib/source'; + +export const GET = async () => { + const rootUrl = "https://docs.stack-auth.com"; + + // Get pages from both sources + const docsPages = source.getPages(); + const apiPages = apiSource.getPages(); + const allPages = [...docsPages, ...apiPages]; + + const sitemap = ` + +${allPages + .map((page) => { + const url = new URL(page.url, rootUrl); + return ` + ${url.toString()} + weekly + 0.8 + `; + }) + .join("\n")} +`; + + return new Response(sitemap, { + headers: { + "Content-Type": "application/xml", + "Cache-Control": "public, max-age=3600", + }, + }); +};