Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix(landing): serve the sitemap index at /sitemap.xml too

Mohamed Bassem17a04dc839ea
diff --git a/apps/landing/astro.config.ts b/apps/landing/astro.config.ts
index 13981b9d..810e9803 100644
--- a/apps/landing/astro.config.ts
+++ b/apps/landing/astro.config.ts
@@ -1,3 +1,4 @@
+import { copyFile } from "node:fs/promises";
import react from "@astrojs/react";
import sitemap from "@astrojs/sitemap";
import { defineConfig } from "astro/config";
@@ -9,7 +10,24 @@ export default defineConfig({
trailingSlash: "always",
// Keep HTML whitespace handling from Astro 6.
compressHTML: true,
- integrations: [react(), sitemap()],
+ integrations: [
+ react(),
+ sitemap(),
+ {
+ // @astrojs/sitemap only emits sitemap-index.xml, but crawlers and tools
+ // commonly probe /sitemap.xml, which our host otherwise answers with the
+ // homepage. Serve a copy of the index there too.
+ name: "sitemap-xml-alias",
+ hooks: {
+ "astro:build:done": async ({ dir }) => {
+ await copyFile(
+ new URL("sitemap-index.xml", dir),
+ new URL("sitemap.xml", dir),
+ );
+ },
+ },
+ },
+ ],
vite: {
plugins: [(await import("vite-plugin-svgr")).default()],
environments: {