navigation prev next browser
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user