Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for active children in submenus #1869

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@
{%- for p in sorted_pages -%}
{%- if p.nav and p.autogen == nil -%}
{%- if p.dropdown %}
<li class="nav-item dropdown {% if page.title == p.title %}active{% endif %}">
{%- assign has_active_child = false -%}
{%- for child in p.children -%}
{%- if page.title == child.title -%}
{%- assign has_active_child = true -%}
{%- endif -%}
{%- endfor -%}
<li class="nav-item dropdown {% if page.title == p.title or has_active_child %}active{% endif %}">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ p.title }}
{%- if page.title == p.title -%}
{%- if page.title == p.title or has_active_child -%}
<span class="sr-only">(current)</span>
{%- endif -%}
</a>
Expand All @@ -78,7 +84,7 @@
{%- if child.title == 'divider' %}
<div class="dropdown-divider"></div>
{%- else %}
<a class="dropdown-item" href="{{ child.permalink | relative_url }}">{{ child.title }}</a>
<a class="dropdown-item {% if page.title == child.title %}active{% endif %}" href="{{ child.permalink | relative_url }}">{{ child.title }}</a>
{%- endif -%}
{% endfor %}
</div>
Expand Down