Saved your changes before starting work
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 5e584ab0-c340-4432-97ef-1972582b60e9 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 6d4dbe7c-69e4-4510-bd62-638ff9c78d5c
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user