|
18 | 18 | <div class="navbar-item has-dropdown is-hoverable {% if site.fixed_navbar == 'bottom' %} has-dropdown-up {% endif %}"> |
19 | 19 | <a href="{{ item.link | relative_url }}" class="navbar-link {% if page.url contains item.link %}is-active{% endif %}"> |
20 | 20 | {{ item.name }} |
21 | | - {% if item.dropdown %}<span class="icon is-small"><i class="fas fa-angle-down"></i></span>{% endif %} |
| 21 | + <span class="icon is-small"><i class="fas fa-angle-down"></i></span> |
22 | 22 | </a> |
23 | 23 | <div class="navbar-dropdown"> |
24 | 24 | {% for subitem in item.dropdown %} |
25 | 25 | {% if subitem.dropdown %} |
26 | 26 | <div class="navbar-item has-dropdown is-hoverable"> |
27 | 27 | <a href="{{ subitem.link | relative_url }}" class="navbar-link {% if page.url contains subitem.link %}is-active{% endif %}"> |
28 | 28 | {{ subitem.name }} |
29 | | - {% if subitem.dropdown %}<span class="icon is-small"><i class="fas fa-angle-right"></i></span>{% endif %} |
| 29 | + <span class="icon is-small"><i class="fas fa-angle-right"></i></span> |
30 | 30 | </a> |
31 | 31 | <div class="navbar-dropdown"> |
32 | 32 | {% for subsubitem in subitem.dropdown %} |
|
55 | 55 | </div> |
56 | 56 | </div> |
57 | 57 | </nav> |
| 58 | + |
| 59 | +<!-- Add this JavaScript to handle the dropdown toggle behavior --> |
| 60 | +<script> |
| 61 | + document.addEventListener('DOMContentLoaded', () => { |
| 62 | + // Dropdowns |
| 63 | + const dropdowns = document.querySelectorAll('.navbar-item.has-dropdown'); |
| 64 | + |
| 65 | + dropdowns.forEach(dropdown => { |
| 66 | + const link = dropdown.querySelector('.navbar-link'); |
| 67 | + const dropdownMenu = dropdown.querySelector('.navbar-dropdown'); |
| 68 | + |
| 69 | + // Add event listener for click or hover |
| 70 | + link.addEventListener('click', (event) => { |
| 71 | + event.preventDefault(); // Prevent default link behavior |
| 72 | + dropdownMenu.classList.toggle('is-active'); |
| 73 | + dropdown.classList.toggle('is-active'); |
| 74 | + }); |
| 75 | + |
| 76 | + // Optional: Add hover behavior for desktop |
| 77 | + dropdown.addEventListener('mouseenter', () => { |
| 78 | + dropdownMenu.classList.add('is-active'); |
| 79 | + }); |
| 80 | + |
| 81 | + dropdown.addEventListener('mouseleave', () => { |
| 82 | + dropdownMenu.classList.remove('is-active'); |
| 83 | + }); |
| 84 | + }); |
| 85 | + }); |
| 86 | +</script> |
0 commit comments