mirror of
https://github.com/thiloho/thiloho.github.io.git
synced 2025-11-22 10:21:36 +01:00
Add sitemap integration and render robots.txt via ts
This commit is contained in:
12
src/pages/robots.txt.ts
Normal file
12
src/pages/robots.txt.ts
Normal 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));
|
||||
};
|
||||
Reference in New Issue
Block a user