Skip to content

Commit 31460f7

Browse files
committed
Modify router, remove contact pg and use footer
1 parent 2060a76 commit 31460f7

5 files changed

Lines changed: 22 additions & 25 deletions

File tree

‎src/layout/Footer.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { text } from "../lib/index.js";
1111
</script>
1212

1313
<template>
14-
<Section bg="bg-gray-900" class="text-white">
14+
<Section bg="bg-gray-900" class="text-white" id="kontakt">
1515
<Grid>
1616
<div>
1717
<h3 class="text-3xl font-light pb-4">MTÜ Lapikud</h3>

‎src/layout/Navbar.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function handleResize() {
356356
)
357357
"
358358
:onClick="
359-
() => handleNavigation('/kontakt')
359+
() => handleNavigation('#kontakt')
360360
"
361361
>
362362
{{ text.contact }}

‎src/lib/router/router.js‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export function navigate(path, options = {}) {
1212

1313
if (external) {
1414
window.open(path, '_blank', 'noopener,noreferrer');
15+
} else if (path.startsWith('#')) {
16+
const hash = path;
17+
const target = document.getElementById(hash.slice(1));
18+
if (target) {
19+
window.history.pushState({}, '', `${window.location.pathname}${window.location.search}${hash}`);
20+
target.scrollIntoView({ behavior: 'smooth' });
21+
}
1522
} else {
1623
const url = new URL(path, window.location.origin);
1724
if (url.origin !== window.location.origin) {
@@ -29,12 +36,24 @@ export function navigate(path, options = {}) {
2936
}
3037

3138
function commitNavigation(path) {
39+
const hash = new URL(path, window.location.origin).hash;
3240
window.history.pushState({}, '', path);
33-
window.scrollTo(0, 0);
3441
window.dispatchEvent(new PopStateEvent('popstate'));
3542

3643
const lang = getLanguageFromRoute(new URL(path, window.location.origin).pathname);
3744
if (lang) switchLang(lang);
45+
46+
if (hash) {
47+
const scrollToHash = () => {
48+
const target = document.getElementById(hash.slice(1));
49+
if (target) {
50+
target.scrollIntoView({ behavior: 'smooth' });
51+
}
52+
};
53+
requestAnimationFrame(scrollToHash);
54+
} else {
55+
window.scrollTo(0, 0);
56+
}
3857
}
3958

4059
/**

‎src/routes/Contact.vue‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎src/routes/index.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const loadMentors = () => import('./Mentors.vue');
77
const loadHelpdesk = () => import('./Helpdesk.vue');
88
const loadOurWork = () => import('./OurWork.vue');
99
const loadAboutUs = () => import('./AboutUs.vue');
10-
const loadContact = () => import('./Contact.vue');
1110
const loadManagment = () => import('./Managment.vue');
1211
const loadStriim = () => import('./Striim.vue');
1312
const loadCalendar = () => import('./Calendar.vue');
@@ -101,8 +100,6 @@ export const routes = {
101100
'/ourwork': loadOurWork,
102101
'/lapikutest': loadAboutUs,
103102
'/aboutus': loadAboutUs,
104-
'/kontakt': loadContact,
105-
'/contact': loadContact,
106103
'/juhatus': loadManagment,
107104
'/management': loadManagment,
108105
'/koolitused': loadWorkshops,

0 commit comments

Comments
 (0)