Skip to content

Commit

Permalink
feat: dynamically generate robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqmanuja authored and satnaing committed Oct 3, 2023
1 parent cfcedd1 commit 6352353
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 0 additions & 5 deletions public/robots.txt

This file was deleted.

17 changes: 17 additions & 0 deletions src/pages/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -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" },
});

0 comments on commit 6352353

Please sign in to comment.