preserving navigation

This commit is contained in:
Davide Scaini
2026-03-30 20:27:34 +02:00
parent 0b9027b4a0
commit cb345c02a1
4 changed files with 45 additions and 0 deletions
+10
View File
@@ -13,10 +13,20 @@
type Tab = 'power' | 'records' | 'profile';
let activeTab: Tab = 'power';
let mounted = false;
const editUrl = import.meta.env.PUBLIC_EDIT_URL ?? '';
$: if (mounted) {
const params = new URLSearchParams(window.location.search);
if (activeTab === 'power') params.delete('tab'); else params.set('tab', activeTab);
const qs = params.toString();
history.replaceState(null, '', qs ? `?${qs}` : window.location.pathname);
}
onMount(async () => {
activeTab = (new URLSearchParams(window.location.search).get('tab') as Tab) ?? 'power';
mounted = true;
try {
const [athleteRes, indexRes] = await Promise.all([
fetch(`${import.meta.env.BASE_URL}data/athlete.json`),