diff --git a/nuxt.config.ts b/nuxt.config.ts index cf15fb2..37a05bf 100755 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -49,7 +49,8 @@ export default defineNuxtConfig({ sitemap: { autoLastmod: true, - urls: ['https://docu.djeex.fr'] + urls: ['https://docu.djeex.fr'], + sources: ['/api/__sitemap__/urls'] }, compatibilityDate: '2024-10-24' diff --git a/server/api/__sitemap__/urls.ts b/server/api/__sitemap__/urls.ts new file mode 100644 index 0000000..a2e327e --- /dev/null +++ b/server/api/__sitemap__/urls.ts @@ -0,0 +1,10 @@ +// fetches the deployed French sitemap and injects its URLs into the English sitemap +export default defineEventHandler(async () => { + try { + const xml = await $fetch('https://docu.djeex.fr/fr/sitemap.xml') + const urls = [...xml.matchAll(/([^<]+)<\/loc>/g)].map(m => m[1]) + return urls.map(loc => ({ loc })) + } catch { + return [] + } +})