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

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

Sitemap: ${sitemapURL.href}
`;

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