Skip to content

Commit f71fdc1

Browse files
committed
chore: update robots.txt implementation
1 parent 172e14b commit f71fdc1

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/pages/robots.txt.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import type { APIRoute } from "astro";
2-
import { SITE } from "@config";
3-
4-
const robots = `
5-
User-agent: Googlebot
6-
Disallow: /nogooglebot/
72

3+
const getRobotsTxt = (sitemapURL: URL) => `
84
User-agent: *
95
Allow: /
106
11-
Sitemap: ${new URL("sitemap-index.xml", SITE.website).href}
12-
`.trim();
7+
Sitemap: ${sitemapURL.href}
8+
`;
139

14-
export const GET: APIRoute = () =>
15-
new Response(robots, {
16-
headers: { "Content-Type": "text/plain" },
17-
});
10+
export const GET: APIRoute = ({ site }) => {
11+
const sitemapURL = new URL("sitemap-index.xml", site);
12+
return new Response(getRobotsTxt(sitemapURL));
13+
};

0 commit comments

Comments
 (0)