diff --git a/nuxt.config.ts b/nuxt.config.ts
index 24f47c5..76bec46 100755
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -44,5 +44,11 @@ export default defineNuxtConfig({
}
},
+ nitro: {
+ prerender: {
+ routes: ['/sitemap.xml']
+ }
+ },
+
compatibilityDate: '2024-10-24'
})
\ No newline at end of file
diff --git a/server/routes/sitemap.xml.ts b/server/routes/sitemap.xml.ts
new file mode 100644
index 0000000..905e31b
--- /dev/null
+++ b/server/routes/sitemap.xml.ts
@@ -0,0 +1,23 @@
+import { serverQueryContent } from '#content/server'
+
+// generates /fr/sitemap.xml without @nuxtjs/sitemap (incompatible with baseURL /fr/)
+export default defineEventHandler(async (event) => {
+ const docs = await serverQueryContent(event).find()
+
+ const urls = docs
+ .filter((doc: any) =>
+ doc._path &&
+ !doc._path.startsWith('/_') &&
+ !doc._path.endsWith('/_dir')
+ )
+ .map((doc: any) => ` https://docu.djeex.fr/fr${doc._path}`)
+ .join('\n')
+
+ const sitemap = `
+
+${urls}
+`
+
+ setHeader(event, 'Content-Type', 'application/xml')
+ return sitemap
+})