use homepage as default page

This commit is contained in:
vcoppe
2024-07-08 15:46:00 +02:00
parent b38ff26a64
commit 5ed0e75427
10 changed files with 273 additions and 283 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation';
import * as Select from '$lib/components/ui/select';
import { languages } from '$lib/languages';
import { getURLForLanguage, languages } from '$lib/languages';
import { Languages } from 'lucide-svelte';
import { _, locale } from 'svelte-i18n';
@@ -16,21 +16,6 @@
label: languages[$locale]
};
}
function getURLForLanguage(lang?: string): string {
let currentPath = window.location.pathname;
let currentPathArray = currentPath.split('/');
if (currentPathArray.length > 1 && languages.hasOwnProperty(currentPathArray[1])) {
currentPathArray.splice(1, 1);
}
if (lang !== undefined && lang !== 'en') {
currentPathArray.splice(1, 0, lang);
}
return currentPathArray.join('/');
}
</script>
<Select.Root bind:selected onSelectedChange={(s) => goto(getURLForLanguage(s?.value))}>