23 lines
541 B
JavaScript
23 lines
541 B
JavaScript
const yearEl = document.getElementById('year');
|
|
if (yearEl) {
|
|
yearEl.textContent = new Date().getFullYear();
|
|
}
|
|
|
|
const navLinks = document.querySelectorAll('a[href^="#"]');
|
|
navLinks.forEach((link) => {
|
|
link.addEventListener('click', (event) => {
|
|
const targetId = link.getAttribute('href');
|
|
if (!targetId || targetId === '#') {
|
|
return;
|
|
}
|
|
|
|
const target = document.querySelector(targetId);
|
|
if (!target) {
|
|
return;
|
|
}
|
|
|
|
event.preventDefault();
|
|
target.scrollIntoView({ behavior: 'smooth' });
|
|
});
|
|
});
|