astro/docs/src/pages/index.astro
Fred K. Schott 7c74496149
Docs site cleanup (#948)
* add language selector

* docs site cleanup

* review feedback

* code review comments
2021-07-30 22:39:15 -07:00

18 lines
No EOL
691 B
Text

---
import Layout from '../layouts/MainLayout.astro';
---
<script>
// This is some wip redirect code 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 = ['en', 'nl'];
let newLang = (window.navigator.userLanguage || window.navigator.language || 'en').substr(0, 2);
if (newLang === 'en') {
window.location.pathname = '/getting-started';
} else if (KNOWN_LANGUAGES.includes(newLang)) {
window.location.pathname = '/' + newLang + '/getting-started';
} else {
window.location.pathname = '/getting-started';
}
</script>