Skip to content

Commit 3b1c108

Browse files
authored
fix: blog highlighted in nav for child pages (alshedivat#2516)
Currently, in all blog posts, or any child page under /blog, the "blog" in nav is not highlighted. In all other child pages for a parent in nav, the parent is highlighted. For example, in a sub page of projects, projects in nav is highlighted. This fix creates a consistent behavior for nav and highlights the blog in nav if in a blog post. BEFORE: <img width="1427" alt="image" src="https://github.com/alshedivat/al-folio/assets/52665298/fc79727c-dc22-4af7-8c16-80efa216ecbc"> AFTER: <img width="1434" alt="image" src="https://github.com/alshedivat/al-folio/assets/52665298/6b32e7f9-e421-4b08-b86e-813b20ac058e">
1 parent 5d3d3ff commit 3b1c108

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

_includes/header.liquid

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
</div>
9696
</li>
9797
{% else %}
98-
<li class="nav-item {% if page.url contains p.permalink %}active{% endif %}">
98+
{% assign parent_link = p.permalink | remove: 'index.html' %}
99+
<li class="nav-item {% if page.url contains parent_link %}active{% endif %}">
99100
{% if p.permalink contains '/blog/' %}{% assign url = '/blog/' %} {% else %}{% assign url = p.url %}{% endif %}
100101
<a class="nav-link" href="{{ url | relative_url }}">
101102
{{- p.title }}

0 commit comments

Comments
 (0)