diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 040f133ab..9a5ce6118 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -33,7 +33,7 @@ jobs: run: make install - name: Build the website - run: make build + run: make build PREVIEW=true - name: Set up SSH key uses: webfactory/ssh-agent@v0.9.1 diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 000000000..6ce8b0465 --- /dev/null +++ b/src/pages/robots.txt.ts @@ -0,0 +1,19 @@ +import type { APIRoute } from "astro"; + +const previewRobots = ` +User-agent: * +Disallow: / +`; + +const prodRobots = ` +User-agent: * +Disallow: /_astro/ +Disallow: /*? +Allow: / + +Sitemap: https://ep2025.europython.eu/sitemap-index.xml +`; + +const isPreview = String(import.meta.env.PREVIEW).toLowerCase() === "true"; +export const GET: APIRoute = () => + new Response(isPreview ? previewRobots : prodRobots);