-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.html
More file actions
85 lines (77 loc) · 3.87 KB
/
Copy pathheader.html
File metadata and controls
85 lines (77 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<nav class="navbar is-primary {% if site.fixed_navbar %} is-fixed-{{ site.fixed_navbar }} {% endif %}" x-data="{ openNav: false }">
<div class="container">
<div class="navbar-brand">
<a href="{{ site.baseurl }}/" class="navbar-item">
{{ site.title }}
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navMenu" :class="{ 'is-active': openNav }" x-on:click="openNav = !openNav">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div class="navbar-menu" id="navMenu">
<div class="navbar-start">
{% if site.data.navigation %}
{% for item in site.data.navigation %}
{% if item.dropdown %}
<!-- First-level dropdown (open on click) -->
<div class="navbar-item has-dropdown">
<a href="{{ item.link | relative_url }}" class="navbar-link {% if page.url contains item.link %}is-active{% endif %}" onclick="toggleDropdown(event)">
{{ item.name }}
</a>
<div class="navbar-dropdown">
{% for subitem in item.dropdown %}
{% if subitem.dropdown %}
<!-- Second-level dropdown (hoverable) -->
<div class="navbar-item has-dropdown is-hoverable">
<a href="{{ subitem.link | relative_url }}" class="navbar-link">{{ subitem.name }}</a>
<div class="navbar-dropdown">
{% for subsubitem in subitem.dropdown %}
<a href="{{ subsubitem.link | relative_url }}" class="navbar-item">{{ subsubitem.name }}</a>
{% endfor %}
</div>
</div>
{% else %}
<a href="{{ subitem.link | relative_url }}" class="navbar-item {% if subitem.link == page.url %}is-active{% endif %}">{{ subitem.name }}</a>
{% endif %}
{% endfor %}
</div>
</div>
{% else %}
<!-- Non-dropdown first-level link -->
<a href="{{ item.link | relative_url }}" class="navbar-item {% if item.link == page.url %}is-active{% endif %}">{{ item.name }}</a>
{% endif %}
{% endfor %}
{% endif %}
</div>
</div>
</div>
</nav>
<script>
function toggleDropdown(event) {
event.preventDefault();
// Find the parent dropdown container
const parentItem = event.target.closest('.has-dropdown');
// Toggle the active state
if (parentItem.classList.contains('is-active')) {
parentItem.classList.remove('is-active');
} else {
// Close all other dropdowns
document.querySelectorAll('.navbar-item.has-dropdown.is-active').forEach(item => {
item.classList.remove('is-active');
});
// Open the clicked dropdown
parentItem.classList.add('is-active');
}
}
// Close dropdowns when clicking outside
document.addEventListener('click', function (event) {
const target = event.target;
if (!target.closest('.has-dropdown')) {
document.querySelectorAll('.navbar-item.has-dropdown.is-active').forEach(item => {
item.classList.remove('is-active');
});
}
});
</script>