feat: auto-generate robots.txt

This commit is contained in:
enscribe 2024-09-14 09:31:24 -07:00
parent 773fb7b73e
commit 05daa7025e
No known key found for this signature in database
GPG key ID: 9BBD5C4114E25322
2 changed files with 14 additions and 0 deletions

13
src/pages/robots.txt.ts Normal file
View file

@ -0,0 +1,13 @@
import type { APIRoute } from 'astro'
const getRobotsTxt = (sitemapURL: URL) => `
User-agent: *
Allow: /
Sitemap: ${sitemapURL.href}
`
export const GET: APIRoute = ({ site }) => {
const sitemapURL = new URL('sitemap-index.xml', site)
return new Response(getRobotsTxt(sitemapURL))
}