From 97dab1ebc52c84ebb31738e9bd224bd1bb4b0492 Mon Sep 17 00:00:00 2001 From: Anton Pogrebnjak Date: Fri, 31 Jan 2025 22:57:07 +0100 Subject: [PATCH] Added robots.txt --- src/pages/robots.txt.ts | 13 +++++++++++++ 1 file changed, 13 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..1cab558 --- /dev/null +++ b/src/pages/robots.txt.ts @@ -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)); +};