From a195b074a75efbc29044a88449ef4933d006a08e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 23 Apr 2026 15:07:04 +0200 Subject: [PATCH] Preserve Pathname on Lang Change Co-authored-by: Copilot --- src/components/Navbar.svelte | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/Navbar.svelte b/src/components/Navbar.svelte index 0f5a951..c6dd425 100644 --- a/src/components/Navbar.svelte +++ b/src/components/Navbar.svelte @@ -23,6 +23,7 @@ import { t, l } from "astro-i18n"; import { onMount } from "svelte"; import { loggedIn } from "@repo/authv2.ts"; + import { astroI18n } from "astro-i18n"; interface Props { logo?: import("svelte").Snippet; } @@ -34,6 +35,8 @@ let accountBtn = $state(); + let currentPage = $state(astroI18n.route); + $effect(() => { if ($loggedIn) { accountBtn!.href = l("/dashboard"); @@ -44,6 +47,11 @@ onMount(() => { handleScroll(); + + document.addEventListener("astro:page-load", () => { + astroI18n.route = location.pathname; + currentPage = astroI18n.route; + }); }); function handleScroll() { @@ -125,12 +133,12 @@
cookieStore.delete("MANUAL_LANGUAGE")} class="btn btn-gray">Auto - cookieStore.set("MANUAL_LANGUAGE", "TRUE")} class="btn btn-gray">Deutsch - cookieStore.set("MANUAL_LANGUAGE", "TRUE")} class="btn btn-gray">English + cookieStore.set("MANUAL_LANGUAGE", "TRUE")} class="btn btn-gray">Deutsch + cookieStore.set("MANUAL_LANGUAGE", "TRUE")} class="btn btn-gray">English