diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100644 index da95c4e..0000000 --- a/public/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -User-agent: Googlebot -Disallow: /nogooglebot/ - -User-agent: * -Allow: / \ No newline at end of file diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 0000000..0475e01 --- /dev/null +++ b/src/pages/robots.txt.ts @@ -0,0 +1,17 @@ +import type { APIRoute } from "astro"; +import { SITE } from "@config"; + +const robots = ` +User-agent: Googlebot +Disallow: /nogooglebot/ + +User-agent: * +Allow: / + +Sitemap: ${new URL("sitemap-index.xml", SITE.website).href} +`.trim(); + +export const GET: APIRoute = () => + new Response(robots, { + headers: { "Content-Type": "text/plain" }, + });