Skip to content

Commit

Permalink
fix(wow book): enforce hash navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-berlin committed Oct 21, 2023
1 parent 3571d12 commit d934233
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/BookToc.astro
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,16 @@ const { toc } = Astro.props;
class="c-book-toc__pixel"
/>
</section>

<script is:inline>
// Find all buttons with the `alert` class on the page.
const buttons = document.querySelectorAll(".c-book-toc__menu-link");

// Handle clicks on each button.
buttons.forEach((button) => {
button.addEventListener("click", (event) => {
const hash = event.target.parentElement.getAttribute("href");
window.location.hash = hash;
});
});
</script>

0 comments on commit d934233

Please sign in to comment.