summaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
authorR-man3000 <rasmus.luha@gmail.com>2026-06-12 17:00:31 +0300
committerR-man3000 <rasmus.luha@gmail.com>2026-06-12 17:00:31 +0300
commit30a19112216e12d19459474f7308ec57cd8aaf9d (patch)
tree6f15108e6afc492d180311460a7a15df9899a8ea /script.js
parentd1f3fa958413c76226c3172a1c12de1732768c69 (diff)
site redo
Diffstat (limited to 'script.js')
-rw-r--r--script.js38
1 files changed, 15 insertions, 23 deletions
diff --git a/script.js b/script.js
index b37a235..7b52657 100644
--- a/script.js
+++ b/script.js
@@ -1,25 +1,17 @@
-const routes = {
- '/': 'page-home',
- '/blog': 'page-blog',
- '/about': 'page-about',
-};
+// Fetch navbar
+fetch('/nav.html')
+ .then(r => r.text())
+ .then(html => {
+ document.getElementById('nav').innerHTML = html;
-function navigate() {
- const hash = location.hash.replace('#', '') || '/';
+ // Mark the current page link as active
+ const current = window.location.pathname;
+ document.querySelectorAll('nav a').forEach(a => {
+ if (a.getAttribute('href') === current) {
+ a.classList.add('active');
+ }
+ })
+ })
- // Hide all pages
- document.querySelectorAll('.page').forEach(el => el.classList.remove('active'));
-
- // Update nav
- document.querySelectorAll('nav a').forEach(a => {
- const path = a.getAttribute('href').replace('#', '');
- a.classList.toggle('active', path === hash);
- });
-
- // Show matching page, fall back to 404
- const pageId = routes[hash] || 'page-404';
- document.getElementById(pageId).classList.add('active');
-}
-
-window.addEventListener('hashchange', navigate);
-navigate(); // run on load
+// Fetch footer
+document.getElementById('footer').innerHTML = '© 2026 Luhamus';