preserving navigation
This commit is contained in:
@@ -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`),
|
||||
|
||||
Reference in New Issue
Block a user