summaryrefslogtreecommitdiff
path: root/docs/src/pages/index.astro
diff options
context:
space:
mode:
Diffstat (limited to 'docs/src/pages/index.astro')
-rw-r--r--docs/src/pages/index.astro48
1 files changed, 33 insertions, 15 deletions
diff --git a/docs/src/pages/index.astro b/docs/src/pages/index.astro
index 74bf80c9c..ed0831cbd 100644
--- a/docs/src/pages/index.astro
+++ b/docs/src/pages/index.astro
@@ -3,19 +3,37 @@ import Layout from '../layouts/MainLayout.astro';
---
<script>
- // WIP: trigger a client-side redirect based on the browser language.
- // A vercel.json redirect is enforced in production, so no user should ever see this page.
- // Remove the vercel.json redirect when this is ready.
- const KNOWN_LANGUAGES = ['bg', 'de','en','es','fi','nl','pt-br','zh-CN','zh-TW', 'fr', 'kr', 'da', 'ja'];
- let newLangWithRegion = (window.navigator.userLanguage || window.navigator.language || 'en-US').substr(0, 5);
- let newLang = newLangWithRegion.substr(0, 2);
- if (newLang === 'en') {
- window.location.pathname = '/getting-started';
- } else if (KNOWN_LANGUAGES.includes(newLangWithRegion)) {
- window.location.pathname = '/' + newLangWithRegion + '/getting-started';
- } else if (KNOWN_LANGUAGES.includes(newLang)) {
- window.location.pathname = '/' + newLang + '/getting-started';
- } else {
- window.location.pathname = '/getting-started';
- }
+ // WIP: trigger a client-side redirect based on the browser language.
+ // A vercel.json redirect is enforced in production, so no user should ever see this page.
+ // Remove the vercel.json redirect when this is ready.
+ const KNOWN_LANGUAGES = [
+ 'bg',
+ 'de',
+ 'en',
+ 'es',
+ 'fi',
+ 'nl',
+ 'pt-br',
+ 'zh-CN',
+ 'zh-TW',
+ 'fr',
+ 'kr',
+ 'da',
+ 'ja',
+ ];
+ let newLangWithRegion = (
+ window.navigator.userLanguage ||
+ window.navigator.language ||
+ 'en-US'
+ ).substr(0, 5);
+ let newLang = newLangWithRegion.substr(0, 2);
+ if (newLang === 'en') {
+ window.location.pathname = '/getting-started';
+ } else if (KNOWN_LANGUAGES.includes(newLangWithRegion)) {
+ window.location.pathname = '/' + newLangWithRegion + '/getting-started';
+ } else if (KNOWN_LANGUAGES.includes(newLang)) {
+ window.location.pathname = '/' + newLang + '/getting-started';
+ } else {
+ window.location.pathname = '/getting-started';
+ }
</script>