Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
Signed-off-by: Huong Nguyen <huongg1409@gmail>
  • Loading branch information
Huong Nguyen committed Jun 25, 2024
1 parent 3623873 commit d4213a5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/kedro_sphinx_theme/theme/kedro-sphinx-theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,29 @@
openBtn.classList.add('wy-nav-top-open');
document.querySelector('.wy-nav-top').prepend(openBtn);

// Get the current URL
const currentUrl = window.location.href;

// Select all navigation links within the .wy-main-nav container
var navLinks = document.querySelectorAll('.wy-main-nav .wy-main-nav-link');

// Iterate over each link
// Function to remove 'active' class from all links
function removeActiveClass() {
navLinks.forEach(function(link) {
link.classList.remove('active');
});
}

// Add click event listener to each link
navLinks.forEach(function(link) {
// Check if the link's href matches the current URL
if (link.href === currentUrl) {
// Add the 'active' class to the matching link
link.classList.add('active');
}
link.addEventListener('click', function(event) {
// Prevent the default link action
event.preventDefault();

// Remove 'active' class from all links
removeActiveClass();

// Add 'active' class to the clicked link
event.target.classList.add('active');
});
});
});
</script>
Expand Down

0 comments on commit d4213a5

Please sign in to comment.