Skip to content

Commit

Permalink
[fix navbar]
Browse files Browse the repository at this point in the history
  • Loading branch information
aangelopoulos committed Sep 20, 2024
1 parent c742308 commit 3bde002
Showing 1 changed file with 48 additions and 75 deletions.
123 changes: 48 additions & 75 deletions _includes/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -42,90 +42,63 @@

<div class="collapse navbar-collapse text-right" id="navbarNav">
<ul class="navbar-nav ml-auto flex-nowrap">
{% for page in site.pages %}
{% if page.permalink == '/' %} {% assign about_title = page.title %} {% endif %}
<!-- Other pages -->
{% assign sorted_pages = site.pages | sort: 'nav_order' %}
{% for p in sorted_pages %}
{% unless p.permalink == '/index.html' %}
{% if p.nav and p.autogen == null %}
<!-- Existing logic for other pages -->
{% if p.dropdown %}
<!-- Dropdown logic -->
{% 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 or has_active_child %}
<span class="sr-only">(current)</span>
{% endif %}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
{% for child in p.children %}
{% if child.title == 'divider' %}
<div class="dropdown-divider"></div>
{% else %}
<a class="dropdown-item {% if page.title == child.title %}active{% endif %}" href="{{ child.permalink | relative_url }}">
{{- child.title -}}
</a>
{% endif %}
{% endfor %}
</div>
</li>
{% else %}
{% assign parent_link = p.permalink | remove: 'index.html' %}
<li class="nav-item {% if page.url contains parent_link %}active{% endif %}">
<a class="nav-link" href="{{ p.url | relative_url }}">
{{- p.title }}
{% if page.url contains p.url %}
<span class="sr-only">(current)</span>
{% endif %}
</a>
</li>
{% endif %}
{% endif %}
{% endunless %}
{% endfor %}

<!-- About -->
<!-- Home/blog Page -->
<li class="nav-item {% if page.permalink == '/' %}active{% endif %}">
<a class="nav-link" href="{{ '/' | relative_url }}">
{{- about_title }}
blog
{% if page.permalink == '/' %}
<span class="sr-only">(current)</span>
{% endif %}
</a>
</li>

<!-- Other pages -->
{% assign sorted_pages = site.pages | sort: 'nav_order' %}
{% for p in sorted_pages %}
{% if p.nav and p.autogen == null %}
{% if p.dropdown %}
{% 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 or has_active_child %}
<span class="sr-only">(current)</span>
{% endif %}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
{% for child in p.children %}
{% if child.title == 'divider' %}
<div class="dropdown-divider"></div>
{% else %}
<a class="dropdown-item {% if page.title == child.title %}active{% endif %}" href="{{ child.permalink | relative_url }}">
{{- child.title -}}
</a>
{% endif %}
{% endfor %}
</div>
</li>
{% else %}
{% assign parent_link = p.permalink | remove: 'index.html' %}
<li class="nav-item {% if page.url contains parent_link %}active{% endif %}">
{% if p.permalink contains '/blog/' %}{% assign url = '/blog/' %} {% else %}{% assign url = p.url %}{% endif %}
<a class="nav-link" href="{{ url | relative_url }}">
{{- p.title }}
{% if page.url contains p.url %}
<span class="sr-only">(current)</span>
{% endif %}
</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
{% if site.search_enabled %}
<!-- Search -->
<li class="nav-item">
<button id="search-toggle" title="Search" onclick="openSearchModal()">
<span class="nav-link">ctrl k <i class="ti ti-search"></i></span>
</button>
</li>
{% endif %}
{% if site.enable_darkmode %}
<!-- Toogle theme mode -->
<li class="toggle-container">
<button id="light-toggle" title="Change theme">
<i class="ti ti-sun-moon" id="light-toggle-system"></i>
<i class="ti ti-moon-filled" id="light-toggle-dark"></i>
<i class="ti ti-sun-filled" id="light-toggle-light"></i>
</button>
</li>
{% endif %}
</ul>
</div>
</div>
Expand Down

0 comments on commit 3bde002

Please sign in to comment.