Add sitemap integration and render robots.txt via ts

This commit is contained in:
thiloho
2025-04-27 03:38:25 +02:00
parent 6a97f847c6
commit f88fe15fe0
12 changed files with 91 additions and 15 deletions

12
src/pages/robots.txt.ts Normal file
View File

@@ -0,0 +1,12 @@
import type { APIRoute } from "astro";
const getRobotsTxt = (sitemapURL: URL) => `User-agent: *
Allow: /
Sitemap: ${sitemapURL.href}
`;
export const GET: APIRoute = (context) => {
const sitemapURL = new URL("sitemap-index.xml", context.url.origin);
return new Response(getRobotsTxt(sitemapURL));
};