From a7b309ff935f5100581fc4dcdf172c62d3bb8ac1 Mon Sep 17 00:00:00 2001 From: egeakman Date: Tue, 25 Mar 2025 16:47:05 -0400 Subject: [PATCH 1/5] Add robots.txt --- public/robots.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 public/robots.txt diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 000000000..d7302aa77 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,6 @@ +User-agent: * +Disallow: /_astro/ +Disallow: /*? +Allow: / + +Sitemap: https://ep2025.europython.eu/sitemap-index.xml From 8127c1f9fd914e7a84c594a57cbb64eba2d64f86 Mon Sep 17 00:00:00 2001 From: egeakman Date: Tue, 25 Mar 2025 17:17:08 -0400 Subject: [PATCH 2/5] Change permissions for previews --- public/robots.txt | 6 ------ src/pages/robots.txt.ts | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) delete mode 100644 public/robots.txt create mode 100644 src/pages/robots.txt.ts diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100644 index d7302aa77..000000000 --- a/public/robots.txt +++ /dev/null @@ -1,6 +0,0 @@ -User-agent: * -Disallow: /_astro/ -Disallow: /*? -Allow: / - -Sitemap: https://ep2025.europython.eu/sitemap-index.xml diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 000000000..fd1818717 --- /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 = import.meta.env.PREVIEW?.toLowerCase() === "true"; +export const GET: APIRoute = () => + new Response(isPreview ? previewRobots : prodRobots); From b3fdc47a5bd9ed0a62cc1f766648efb81294ef42 Mon Sep 17 00:00:00 2001 From: egeakman Date: Tue, 25 Mar 2025 17:17:44 -0400 Subject: [PATCH 3/5] Set env var in GHA for preview --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 040f133ab..f6e5d2eed 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: PREVIEW=true make build - name: Set up SSH key uses: webfactory/ssh-agent@v0.9.1 From 45884d30e831ff225c0f5545611655f09182f742 Mon Sep 17 00:00:00 2001 From: egeakman Date: Tue, 25 Mar 2025 17:20:24 -0400 Subject: [PATCH 4/5] Windows and Linux best friends --- src/pages/robots.txt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts index fd1818717..6ce8b0465 100644 --- a/src/pages/robots.txt.ts +++ b/src/pages/robots.txt.ts @@ -14,6 +14,6 @@ Allow: / Sitemap: https://ep2025.europython.eu/sitemap-index.xml `; -const isPreview = import.meta.env.PREVIEW?.toLowerCase() === "true"; +const isPreview = String(import.meta.env.PREVIEW).toLowerCase() === "true"; export const GET: APIRoute = () => new Response(isPreview ? previewRobots : prodRobots); From a35fb12fd3ffb1233a857d9876d1637aae846516 Mon Sep 17 00:00:00 2001 From: egeakman Date: Tue, 25 Mar 2025 17:27:04 -0400 Subject: [PATCH 5/5] other way around --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index f6e5d2eed..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: PREVIEW=true make build + run: make build PREVIEW=true - name: Set up SSH key uses: webfactory/ssh-agent@v0.9.1