From 94c1dc37365b59122f178e58d03880c0819206ea Mon Sep 17 00:00:00 2001
From: Peter Mosses
Date: Sat, 16 Nov 2019 11:44:46 +0100
Subject: [PATCH] Hides dispay of grandchildren
Display of grandchildren links in the navigation is now delayed until their parent is selected.
To test, select the `Grandchildren test` node. Only the direct children should appear. Selecting one of them then shows its children.
---
_includes/nav.html | 6 +++++-
docs/grandchildren-test/buttons.md | 11 +++++++++++
docs/grandchildren-test/buttons/grandchild.md | 9 +++++++++
docs/grandchildren-test/index.md | 12 ++++++++++++
docs/grandchildren-test/labels.md | 11 +++++++++++
docs/grandchildren-test/labels/label-grandchild.md | 9 +++++++++
6 files changed, 57 insertions(+), 1 deletion(-)
create mode 100644 docs/grandchildren-test/buttons.md
create mode 100644 docs/grandchildren-test/buttons/grandchild.md
create mode 100644 docs/grandchildren-test/index.md
create mode 100644 docs/grandchildren-test/labels.md
create mode 100644 docs/grandchildren-test/labels/label-grandchild.md
diff --git a/_includes/nav.html b/_includes/nav.html
index d561a42..eb96e28 100644
--- a/_includes/nav.html
+++ b/_includes/nav.html
@@ -10,6 +10,7 @@
{%- endif -%}
{{ node.title }}
{%- if node.has_children -%}
+ {%- if page.url == node.url or page.parent == node.title or page.grand_parent == node.title -%}
{%- assign children_list = site.html_pages | where: "parent", node.title | sort:"nav_order" -%}
{%- for child in children_list -%}
@@ -19,6 +20,7 @@
{%- endif -%}
{{ child.title }}
{%- if child.has_children -%}
+ {%- if page.url == child.url or page.parent == child.title -%}
{%- assign grand_children_list = site.html_pages | where: "parent", child.title | sort:"nav_order" -%}
+
+ {%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
+ {%- endif -%}
{%- endif -%}
{%- endunless -%}
diff --git a/docs/grandchildren-test/buttons.md b/docs/grandchildren-test/buttons.md
new file mode 100644
index 0000000..96fc21e
--- /dev/null
+++ b/docs/grandchildren-test/buttons.md
@@ -0,0 +1,11 @@
+---
+layout: default
+title: Buttons
+parent: Grandchildren test
+has_children: true
+---
+
+Buttons
+----
+
+Child of [Grandchildren test](..)
diff --git a/docs/grandchildren-test/buttons/grandchild.md b/docs/grandchildren-test/buttons/grandchild.md
new file mode 100644
index 0000000..093d200
--- /dev/null
+++ b/docs/grandchildren-test/buttons/grandchild.md
@@ -0,0 +1,9 @@
+---
+layout: default
+title: Buttons Child Page
+parent: Buttons
+grand_parent: Grandchildren test
+---
+
+Buttons Child Page
+----
diff --git a/docs/grandchildren-test/index.md b/docs/grandchildren-test/index.md
new file mode 100644
index 0000000..dd03d58
--- /dev/null
+++ b/docs/grandchildren-test/index.md
@@ -0,0 +1,12 @@
+---
+layout: default
+title: Grandchildren test
+has_children: true
+nav_order: 8
+---
+
+Grandchildren test
+==================
+
+Has a child [Buttons](buttons)
+and a grandchild [Child of Buttons](buttons/grandchild)
diff --git a/docs/grandchildren-test/labels.md b/docs/grandchildren-test/labels.md
new file mode 100644
index 0000000..f4b9ea8
--- /dev/null
+++ b/docs/grandchildren-test/labels.md
@@ -0,0 +1,11 @@
+---
+layout: default
+title: Labels
+parent: Grandchildren test
+has_children: true
+---
+
+Labels
+----
+
+Child of Grandchildren test
diff --git a/docs/grandchildren-test/labels/label-grandchild.md b/docs/grandchildren-test/labels/label-grandchild.md
new file mode 100644
index 0000000..f6c9550
--- /dev/null
+++ b/docs/grandchildren-test/labels/label-grandchild.md
@@ -0,0 +1,9 @@
+---
+layout: default
+title: Labels Child Page
+parent: Labels
+grand_parent: Grandchildren test
+---
+
+Labels Child Page
+----