Activate root tab when there'e an active page on the root level

This commit is contained in:
squidfunk 2017-01-27 23:54:52 +01:00
parent 9a36dd67b2
commit 79f277c8fe
2 changed files with 14 additions and 6 deletions

View File

@ -4,7 +4,7 @@
{{ nav_item.title }}
</a>
{% elif nav_item.url == base_url %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-tabs__link {% if nav_item.active %} md-tabs__link--active {% endif %}">
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-tabs__link {% for nav_item_ in nav %} {{nav_item_.children | length}} {% if nav_item_.url == page.url and nav_item_.children | length == 0 %} md-tabs__link--active {% endif %} {% endfor %}">
{{ nav_item.title }}
</a>
{% endif %}

View File

@ -33,14 +33,22 @@
{{ nav_item.title }}
</a>
<!-- Main navigation item -->
<!-- Home page -->
{% elif nav_item.url == base_url %}
<!--
Hack: the item should be active, if we're sure that we're on the first
level of the tree and the current item doesn't have children
-->
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}"
class="md-tabs__link
{% if nav_item.active %}
{% for nav_item_ in nav %}
{{nav_item_.children | length}}
{% if nav_item_.url == page.url and
nav_item_.children | length == 0 %}
md-tabs__link--active
{% endif %}">
{% endif %}
{% endfor %}">
{{ nav_item.title }}
</a>
{% endif %}