document.addEventListener('DOMContentLoaded', function() { const currentPath = window.location.pathname; const navLinks = document.querySelectorAll('.nav-item-center, .nav-item-left'); navLinks.forEach(navItem => { const link = navItem.querySelector('a'); if (link) { const linkPath = new URL(link.href).pathname; if (linkPath === currentPath || (currentPath === '/' && linkPath === '/')) { navItem.classList.add('active'); } } }); const sidebarLinks = document.querySelectorAll('.sidebar a'); const hash = window.location.hash; if (hash) { sidebarLinks.forEach(link => { if (link.getAttribute('href') === hash) { link.classList.add('active'); } }); } else if (sidebarLinks.length > 0) { sidebarLinks[0].classList.add('active'); } sidebarLinks.forEach(link => { link.addEventListener('click', function() { sidebarLinks.forEach(l => l.classList.remove('active')); this.classList.add('active'); }); }); });