merge with main
This commit is contained in:
@ -37,8 +37,16 @@ const getParams = match => {
|
||||
};
|
||||
|
||||
const navigateTo = async (uri) => {
|
||||
if (await router(uri) === 0)
|
||||
history.pushState(null, null, uri);
|
||||
if (await router(uri) !== 0)
|
||||
return;
|
||||
|
||||
history.pushState(null, null, uri);
|
||||
|
||||
let link = document.querySelector('a[href=\'' + location.pathname + '\']');
|
||||
if (link) {
|
||||
document.querySelector('[data-link].active')?.classList.remove('active');
|
||||
link.classList.add('active');
|
||||
}
|
||||
};
|
||||
|
||||
async function renderView(view)
|
||||
@ -121,8 +129,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
document.body.addEventListener("click", e => {
|
||||
if (e.target.matches("[data-link]")) {
|
||||
e.preventDefault();
|
||||
document.querySelector('[data-link].active').classList.remove('active');
|
||||
e.target.classList.add('active');
|
||||
if (e.target.classList.contains('nav-link')) {
|
||||
document.querySelector('[data-link].active')?.classList.remove('active');
|
||||
e.target.classList.add('active');
|
||||
}
|
||||
navigateTo(e.target.href.slice(location.origin.length));
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user