Optional delay of grandchildren link display

The current default is that when a grandparent is selected, the links to its
children *and all its grandchildren* are displayed in the navigation menu.
Setting `grandchildren_branch: true` in `_config.yml` delays the display of links
to grandchildren until their parent is selected.
This commit is contained in:
Peter Mosses
2019-08-21 13:49:07 +02:00
parent 0cfc0f0357
commit 8ac545a5eb
3 changed files with 19 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
{%- endif -%}
<a href="{{ child.url | absolute_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
{%- if child.has_children -%}
{%- if page.url == child.url or page.parent == child.title or site.grandchildren_branch != true -%}
{%- assign grand_children_list = site.html_pages | where: "parent", child.title | sort:"nav_order" -%}
<ul class="navigation-list-child-list">
{%- for grand_child in grand_children_list -%}
@@ -29,6 +30,7 @@
{%- endfor -%}
</ul>
{%- endif -%}
{%- endif -%}
</li>
{%- endfor -%}
</ul>