From 1995957bcba34b1b6b88803b19a286df5be01d43 Mon Sep 17 00:00:00 2001 From: becarta Date: Wed, 5 Feb 2025 00:33:09 +0100 Subject: [PATCH] update redirect --- src/pages/index.astro | 51 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index 37813ea..378b2de 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,8 +1,5 @@ --- -// List the supported language codes. -const supportedLangs = ['en', 'fr', 'es']; - -// Default language +const supportedLangs = ['en', 'nl', 'de']; let chosenLang = 'en'; // Get the user's Accept-Language header from the incoming request. @@ -10,14 +7,50 @@ const acceptLang = Astro.request.headers.get('accept-language'); if (acceptLang) { // The header may look like: "fr-CH,fr;q=0.9,en-US;q=0.8,en;q=0.7" - // Extract the first language code and simplify (e.g., "fr-CH" becomes "fr") + // Extract the first language code and simplify it (e.g., "fr-CH" becomes "fr") const preferredLang = acceptLang.split(',')[0].trim().split('-')[0]; if (supportedLangs.includes(preferredLang)) { chosenLang = preferredLang; } } -// Redirect to the language-specific version. -// For example, if chosenLang is 'fr', then redirect to /fr/ -return Astro.redirect(`/${chosenLang}`, 302); ---- \ No newline at end of file +const targetURL = `/${chosenLang}`; +--- + + + + + + + + Redirecting... + + + + +
+

Redirecting...

+

+ You are being redirected to the {chosenLang.toUpperCase()} version of our site. +

+

+ If you are not redirected automatically, please + click here. +

+
+ + \ No newline at end of file