Modify router, remove contact pg and use footer

This commit is contained in:
2026-08-11 20:08:39 +03:00
parent 2060a76e0f
commit 31460f7398
5 changed files with 22 additions and 25 deletions

View File

@@ -12,6 +12,13 @@ export function navigate(path, options = {}) {
if (external) {
window.open(path, '_blank', 'noopener,noreferrer');
} else if (path.startsWith('#')) {
const hash = path;
const target = document.getElementById(hash.slice(1));
if (target) {
window.history.pushState({}, '', `${window.location.pathname}${window.location.search}${hash}`);
target.scrollIntoView({ behavior: 'smooth' });
}
} else {
const url = new URL(path, window.location.origin);
if (url.origin !== window.location.origin) {
@@ -29,12 +36,24 @@ export function navigate(path, options = {}) {
}
function commitNavigation(path) {
const hash = new URL(path, window.location.origin).hash;
window.history.pushState({}, '', path);
window.scrollTo(0, 0);
window.dispatchEvent(new PopStateEvent('popstate'));
const lang = getLanguageFromRoute(new URL(path, window.location.origin).pathname);
if (lang) switchLang(lang);
if (hash) {
const scrollToHash = () => {
const target = document.getElementById(hash.slice(1));
if (target) {
target.scrollIntoView({ behavior: 'smooth' });
}
};
requestAnimationFrame(scrollToHash);
} else {
window.scrollTo(0, 0);
}
}
/**