Skip to content

Commit

Permalink
active link
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaythakur8764 committed Nov 18, 2024
1 parent 8f335b6 commit 51f242a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/layout/Nav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ document.addEventListener('DOMContentLoaded', () => {

function addActiveClass() {
if(window.location.hash){
var currentUrl = window.location.pathname + window.location.hash;
var currentUrl = window.location.pathname + window.location.hash.replace(/\/+$/, '');
console.log(currentUrl);
}
else{
Expand All @@ -25,7 +25,7 @@ function addActiveClass() {

menuItems.forEach(item => {
var menuItemUrl = item.getAttribute('href');
// console.log(menuItemUrl);
console.log(menuItemUrl);


if (currentUrl === menuItemUrl || window.location.hash === menuItemUrl) {
Expand Down

0 comments on commit 51f242a

Please sign in to comment.