Skip to content

Commit

Permalink
prevent changing theme to scroll back home
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarreira committed Jun 2, 2024
1 parent 8637f07 commit dd3b254
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions assets/scripts/custom/navbar-toggle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
document.addEventListener('DOMContentLoaded', function() {
// auto-toggle navbar on items click
// alternative: https://stackoverflow.com/questions/14248194/close-responsive-navbar-automatically/75808063#75808063
const navLinks = document.querySelectorAll('.nav-link:not(.dropdown-toggle)')
const menuToggle = document.getElementById('navbar-toggler')
navLinks.forEach((l) => {
l.addEventListener('click', () => {
menuToggle.checkVisibility() && menuToggle.click()
})
})

//prevent changing theme to scroll back home
const navThemeLinks = document.querySelectorAll('#themeMenu > .nav-link')
navThemeLinks.forEach((l) => {
l.setAttribute("href", "javascript:;")
})

});

0 comments on commit dd3b254

Please sign in to comment.