Skip to content

Commit

Permalink
try navigate to href manually
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 7050441 commit f7269fe
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/kedro_sphinx_theme/theme/kedro-sphinx-theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,20 @@
// 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
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');

// Manually navigate to the link's href
window.location.href = event.target.getAttribute('href');
});
});
});
</script>
Expand Down

0 comments on commit f7269fe

Please sign in to comment.