Skip to content

Commit 92f9ccc

Browse files
committed
Refactor highlighting current menu
* Add CSS * Remove not working JS code
1 parent 1a0d4d9 commit 92f9ccc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

_includes/nav.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212
<div class="collapse navbar-collapse flex-grow-0 weight-500">
1313
<div class="navbar-nav align-items-center">
1414
{% for link in site.data.navbar %}
15-
<div class="nav-item ml-2">
16-
<a class="nav-link" href="{% unless link.url contains 'http' %}{{ site.baseurl }}{% endunless %}{{ link.url }}">{% t {{ link.key }} %}</a>
15+
{% assign link_collection = link.url | replace: '/', '' %}
16+
{% assign url_collection = page.url | split: '/' %}
17+
{% assign url_collection = url_collection[1] %}
18+
<div class="nav-item ml-2{% if link_collection == url_collection %} active{% endif %}">
19+
<a class="nav-link"
20+
href="{% unless link.url contains 'http' %}{{ site.baseurl }}{% endunless %}{{ link.url }}">
21+
{% t {{ link.key }} %}
22+
</a>
1723
</div>
1824
{% endfor %}
1925
<div class="nav-item ml-2 ml-sm-1 text-center">
@@ -94,9 +100,3 @@
94100
document.body.scroll = "yes";
95101
}
96102
</script>
97-
98-
<script>
99-
$(document).ready(function ($) {
100-
$('.navbar-nav > .nav-item > a[href="/' + location.pathname.split('/')[1] + '"]').closest(".nav-item").addClass('active');
101-
});
102-
</script>

0 commit comments

Comments
 (0)