navigation prev next browser

This commit is contained in:
Valentin
2024-11-14 04:28:38 +01:00
parent 9bf84290ac
commit 31b577cc8b
5 changed files with 75 additions and 43 deletions

View File

@@ -39,3 +39,24 @@ export function handleClickableElements(clickableElements, store, router, baseUr
}
}
}
export async function handleBrowserNavigation(store, baseUrl, siteName, mapStore) {
let href = window.location.pathname;
if (href.startsWith(baseUrl)) href = href.replace(baseUrl, '');
pageChange(href, store, siteName, mapStore, baseUrl)
}
async function pageChange(href, store, siteName, mapStore, baseUrl ) {
if (href === '/') {
store.resetStore(true);
document.title = siteName;
mapStore.resetMap();
} else {
await store.fetchContentData(baseUrl + href);
document.title = store.pageTitle;
}
setActiveNavItem(store.contentType, href);
const listeEtape = document.querySelector('#etapes-liste');
if (!useLayoutStore().isDesktop) useLayoutStore().collapseEtapeListe(listeEtape);
}