website/script.js

27 lines
845 B
JavaScript

// Mobile nav toggle
const toggle = document.querySelector('.nav-toggle');
const links = document.querySelector('#nav-links');
if (toggle && links){
toggle.addEventListener('click', () => {
const isOpen = links.classList.toggle('open');
toggle.setAttribute('aria-expanded', String(isOpen));
});
}
// Smooth scroll for internal anchors
for (const a of document.querySelectorAll('a[href^="#"]')){
a.addEventListener('click', (e) => {
const id = a.getAttribute('href');
const el = document.querySelector(id);
if (el){
e.preventDefault();
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
if (links && links.classList.contains('open')) links.classList.remove('open');
}
});
}
// Set current year
const y = document.getElementById('year');
if (y) y.textContent = new Date().getFullYear();