Skip to content

Commit

Permalink
Refactor sidebarLinks.ts to remove duplicate code and improve link hi…
Browse files Browse the repository at this point in the history
…ghlighting in Layout.astro
  • Loading branch information
Adammatthiesen committed Dec 23, 2024
1 parent 90aec7f commit 15236a5
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions packages/studiocms_dashboard/src/components/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const description = propDescription ?? dbConfig.description;
)}
<slot />
</main>
<script>
<script is:inline data-astro-rerun>
const sidebarLinks = document.querySelectorAll('.sidebar-link');
console.log('sidebarLinks', sidebarLinks);

Expand All @@ -67,19 +67,6 @@ const description = propDescription ?? dbConfig.description;
link.classList.add('active');
}
}

document.addEventListener('astro:page-load', () => {
const sidebarLinks = document.querySelectorAll('.sidebar-link');
console.log('sidebarLinks', sidebarLinks);

for (const link of sidebarLinks) {
link.classList.remove('active');

if (new URL(link.href).pathname === window.location.pathname) {
link.classList.add('active');
}
}
});
</script>
</body>
</html>

0 comments on commit 15236a5

Please sign in to comment.