From 4ef43534a0f26bc5593258c9cd6a31d62283929d Mon Sep 17 00:00:00 2001 From: Alex Lebens Date: Thu, 12 Mar 2026 15:49:44 -0500 Subject: [PATCH] feat: add robots --- src/pages/robots.txt.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/pages/robots.txt.ts diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 0000000..e49fce0 --- /dev/null +++ b/src/pages/robots.txt.ts @@ -0,0 +1,14 @@ +// https://docs.astro.build/en/guides/integrations-guide/sitemap/#usage +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)); +};