Files
archicratie-edition/src/pages/robots.txt.ts

23 lines
527 B
TypeScript

import type { APIRoute } from "astro";
export const prerender = true;
const robots = (sitemapURL: URL) => `User-agent: *
Allow: /
Disallow: /api/
Disallow: /pagefind/
Sitemap: ${sitemapURL.href}
`;
export const GET: APIRoute = ({ site }) => {
// site vient de astro.config (option "site")
const base = site ?? new URL("http://localhost:4321/");
const sitemapURL = new URL("sitemap-index.xml", base);
return new Response(robots(sitemapURL), {
headers: { "Content-Type": "text/plain; charset=utf-8" },
});
};