summaryrefslogtreecommitdiff
path: root/src/pages/robots.txt.ts
blob: f36bf2b5af0ee4559d47e153c9d3e385acf572ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import type { APIRoute } from "astro";

const getRobotsTxt = (sitemapUrl: URL) => `
User-agent: *
Allow: /

Sitemap: ${sitemapUrl.href}
`;

export const GET: APIRoute = ({ site }) => {
	const sitemapUrl = new URL(`sitemap-index.xml`, site);
	return new Response(getRobotsTxt(sitemapUrl));
};