From a0417e0b1989abec69634d311df83e36e299e29a Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 22 Dec 2024 03:08:44 -0600 Subject: [PATCH] Set proper site URL, preact devtools, sitemap, robots.txt --- frontend/astro.config.mjs | 28 +++++++++++++++++++--------- frontend/src/layouts/Base.astro | 31 +++++++++++++++---------------- frontend/src/pages/robots.txt.ts | 13 +++++++++++++ 3 files changed, 47 insertions(+), 25 deletions(-) create mode 100644 frontend/src/pages/robots.txt.ts diff --git a/frontend/astro.config.mjs b/frontend/astro.config.mjs index 9fd5a01..d433561 100644 --- a/frontend/astro.config.mjs +++ b/frontend/astro.config.mjs @@ -1,13 +1,23 @@ // @ts-check -import { defineConfig } from 'astro/config'; - -import tailwind from '@astrojs/tailwind'; - -import sitemap from '@astrojs/sitemap'; - -import preact from '@astrojs/preact'; +import { defineConfig } from "astro/config"; +import tailwind from "@astrojs/tailwind"; +import sitemap from "@astrojs/sitemap"; +import preact from "@astrojs/preact"; // https://astro.build/config export default defineConfig({ - integrations: [tailwind(), sitemap(), preact()] -}); \ No newline at end of file + site: process.env.DEV + ? "https://localhost:4321" + : `https://${process.env.RAILWAY_PUBLIC_DOMAIN}`, + integrations: [ + tailwind(), + sitemap({ + changefreq: "monthly", + priority: 1.0, + // xslURL: "/sitemap.xsl", + }), + preact({ + devtools: process.env.DEV != undefined ? true : false, + }), + ], +}); diff --git a/frontend/src/layouts/Base.astro b/frontend/src/layouts/Base.astro index e455c61..cc718d6 100644 --- a/frontend/src/layouts/Base.astro +++ b/frontend/src/layouts/Base.astro @@ -1,22 +1,21 @@ - - - - - - Astro Basics - - - - + + + + + Dynamic Preauth + + + + diff --git a/frontend/src/pages/robots.txt.ts b/frontend/src/pages/robots.txt.ts new file mode 100644 index 0000000..dfd4840 --- /dev/null +++ b/frontend/src/pages/robots.txt.ts @@ -0,0 +1,13 @@ +import type { APIRoute } from "astro"; + +const getRobotsTxt = (sitemapURL: URL) => ` +User-agent: * +Disallow: /download/ + +Sitemap: ${sitemapURL.href} +`; + +export const GET: APIRoute = ({ site }) => { + const sitemapURL = new URL("sitemap-index.xml", site); + return new Response(getRobotsTxt(sitemapURL)); +};