From 09ab1c3131179f801d66f9b66852dbd13360db78 Mon Sep 17 00:00:00 2001 From: PLanCompS <18308236+pdmosses@users.noreply.github.com> Date: Mon, 28 Sep 2020 17:06:06 +0200 Subject: [PATCH] List children also when excluded from main navigation - Limit the effect of `nav_exclude: true` to the main navigation. - Include links to excluded pages in auto-generating lists of child pages and in breadcrumbs. - Refactor implementation by moving assignment of `first_level_url` and `second_level_url` from `_includes/nav.html` to `_layouts/default.html`. - Clarify the effect of `nav_exclude` in the documentation. --- _includes/nav.html | 19 +++++++++---------- _layouts/default.html | 15 +++++++++++++++ docs/navigation-structure.md | 4 +++- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/_includes/nav.html b/_includes/nav.html index 976dbbd..325a68c 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -1,6 +1,5 @@ diff --git a/_layouts/default.html b/_layouts/default.html index 442d44d..a92beb9 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -101,6 +101,21 @@ layout: table_wrappers
{% unless page.url == "/" %} {% if page.parent %} + {%- for node in pages_list -%} + {%- if node.parent == nil -%} + {%- if page.parent == node.title or page.grand_parent == node.title -%} + {%- assign first_level_url = node.url | absolute_url -%} + {%- endif -%} + {%- if node.has_children -%} + {%- assign children_list = pages_list | where: "parent", node.title -%} + {%- for child in children_list -%} + {%- if page.url == child.url or page.parent == child.title -%} + {%- assign second_level_url = child.url | absolute_url -%} + {%- endif -%} + {%- endfor -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%}