We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 172e14b commit f71fdc1Copy full SHA for f71fdc1
1 file changed
src/pages/robots.txt.ts
@@ -1,17 +1,13 @@
1
import type { APIRoute } from "astro";
2
-import { SITE } from "@config";
3
-
4
-const robots = `
5
-User-agent: Googlebot
6
-Disallow: /nogooglebot/
7
+const getRobotsTxt = (sitemapURL: URL) => `
8
User-agent: *
9
Allow: /
10
11
-Sitemap: ${new URL("sitemap-index.xml", SITE.website).href}
12
-`.trim();
+Sitemap: ${sitemapURL.href}
+`;
13
14
-export const GET: APIRoute = () =>
15
- new Response(robots, {
16
- headers: { "Content-Type": "text/plain" },
17
- });
+export const GET: APIRoute = ({ site }) => {
+ const sitemapURL = new URL("sitemap-index.xml", site);
+ return new Response(getRobotsTxt(sitemapURL));
+};
0 commit comments