Nav working section with subpages

This commit is contained in:
Fabrice Mouhartem 2023-11-20 11:33:01 +01:00
parent 7b9ee2febe
commit 3c7aabea20
1 changed files with 4 additions and 1 deletions

View File

@ -1,9 +1,12 @@
{% if page %}
{% set page_section = get_section(path=page.ancestors[1], metadata_only = true) %}
{% endif %}
<nav>
<menu>
<li><a {% if section and section == root %} class="nav_current" {% endif %} href="/">Home</a></li>
{% for subsection in root.subsections %}
{% set subsection = get_section(path=subsection, metadata_only=true) %}
<li><a href="{{ subsection.permalink }}" {% if section and section == subsection %} class="nav_current" {% endif %}>{{ subsection.title }}</a></li>
<li><a href="{{ subsection.permalink }}" {% if section and section.title == subsection.title or page and page_section.title == subsection.title %} class="nav_current" {% endif %}>{{ subsection.title }}</a></li>
{% endfor %}
</menu>
</nav>