Unverified Commit 863d13fc authored by Patrick Marsceill's avatar Patrick Marsceill Committed by GitHub
Browse files

Merge pull request #443 from pdmosses/nav-exclude

Limit the effect of `nav_exclude` to the main navigation
parents 37bbacba 641fa6ac
<ul class="nav-list">
{%- assign included_pages = include.pages
| where_exp:"item", "item.nav_exclude != true"
{%- assign titled_pages = include.pages
| where_exp:"item", "item.title != nil" -%}
{%- comment -%}
......@@ -15,9 +14,9 @@
The case-sensitivity of string sorting is determined by `site.nav_sort`.
{%- endcomment -%}
{%- assign string_ordered_pages = included_pages
{%- assign string_ordered_pages = titled_pages
| where_exp:"item", "item.nav_order == nil" -%}
{%- assign nav_ordered_pages = included_pages
{%- assign nav_ordered_pages = titled_pages
| where_exp:"item", "item.nav_order != nil" -%}
{%- comment -%}
......@@ -60,10 +59,8 @@
{%- for node in pages_list -%}
{%- if node.parent == nil -%}
{%- unless node.nav_exclude -%}
<li class="nav-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
{%- if page.parent == node.title or page.grand_parent == node.title -%}
{%- assign first_level_url = node.url | absolute_url -%}
{%- endif -%}
{%- if node.has_children -%}
<a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
{%- endif -%}
......@@ -72,10 +69,8 @@
{%- assign children_list = pages_list | where: "parent", node.title -%}
<ul class="nav-list ">
{%- for child in children_list -%}
{%- unless child.nav_exclude -%}
<li class="nav-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
{%- if page.url == child.url or page.parent == child.title -%}
{%- assign second_level_url = child.url | absolute_url -%}
{%- endif -%}
{%- if child.has_children -%}
<a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
{%- endif -%}
......@@ -84,17 +79,21 @@
{%- assign grand_children_list = pages_list | where: "parent", child.title | where: "grand_parent", node.title -%}
<ul class="nav-list">
{%- for grand_child in grand_children_list -%}
{%- unless grand_child.nav_exclude -%}
<li class="nav-list-item {% if page.url == grand_child.url %} active{% endif %}">
<a href="{{ grand_child.url | absolute_url }}" class="nav-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
</li>
{%- endunless -%}
{%- endfor -%}
</ul>
{%- endif -%}
</li>
{%- endunless -%}
{%- endfor -%}
</ul>
{%- endif -%}
</li>
{%- endunless -%}
{%- endif -%}
{%- endfor -%}
</ul>
......@@ -101,6 +101,21 @@ layout: table_wrappers
<div id="main-content-wrap" class="main-content-wrap">
{% 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 -%}
<nav aria-label="Breadcrumb" class="breadcrumb-nav">
<ol class="breadcrumb-nav-list">
{% if page.grand_parent %}
......
......@@ -66,7 +66,9 @@ nav_exclude: true
---
```
Pages with no `title` are automatically excluded from the navigation.
The `nav_exclude` parameter does not affect the [auto-generating list of child pages](#auto-generating-table-of-contents), which you can use to access pages excluded from the main navigation.
Pages with no `title` are automatically excluded from the navigation.
---
......
---
layout: default
title: A
title: Tests for disambiguation A
has_children: true
---
......@@ -9,6 +9,6 @@ has_children: true
A top-level page
```yaml
title: A
title: Tests for disambiguation A
has_children: true
```
---
layout: default
title: B
title: Tests for disambiguation B
has_children: true
---
......@@ -9,6 +9,6 @@ has_children: true
A top-level page
```yaml
title: B
title: Tests for disambiguation B
has_children: true
```
---
layout: default
title: C
parent: A
title: Tests for disambiguation C
parent: Tests for disambiguation A
has_children: true
---
......@@ -10,7 +10,7 @@ has_children: true
A child of page A, and parent of page D
```yaml
title: C
parent: A
title: Tests for disambiguation C
parent: Tests for disambiguation A
has_children: true
```
---
layout: default
title: C
parent: B
title: Tests for disambiguation C
parent: Tests for disambiguation B
has_children: true
---
......@@ -10,7 +10,7 @@ has_children: true
A child of page B, and parent of page D
```yaml
title: C
parent: B
title: Tests for disambiguation C
parent: Tests for disambiguation B
has_children: true
```
---
layout: default
title: Tests for disambiguation D
parent: Tests for disambiguation C
grand_parent: Tests for disambiguation A
---
# D
A grandchild of page A
```yaml
title: Tests for disambiguation D
parent: Tests for disambiguation C
grand_parent: Tests for disambiguation A
```
---
layout: default
title: Tests for disambiguation D
parent: Tests for disambiguation C
grand_parent: Tests for disambiguation B
---
# D
A grandchild of page B
```yaml
title: Tests for disambiguation D
parent: Tests for disambiguation C
grand_parent: Tests for disambiguation B
```
---
layout: default
title: Disambiguation
parent: Navigation
grand_parent: Tests
---
# Disambiguation
When different pages with children have the same title, referencing the relevant grandparent in the children disambiguates which page is intended.
- [Page A](a/) has a child [page with title C](ca/), and a grandchild [page with title D](dca/).
- [Page B](b/) has a child [page with title C](cb/), and a grandchild [page with title D](dcb/).
- The grandchild pages specify their parent and grandparent pages, so there is no ambiguity.
---
layout: default
title: Excluded Child
parent: Not Excluded
nav_exclude: true
---
# Excluded Child
This child page is explicitly excluded, and should not appear in the navigation.
```yaml
title: Excluded Child
parent: Not Excluded
nav_exclude: true
```
---
layout: default
title: Excluded Grandchild
parent: Non-excluded Child
grand_parent: Non-excluded
nav_exclude: true
---
# Excluded Grandchild
This grandchild page is explicitly excluded, and should not appear in the navigation.
```yaml
title: Excluded Grandchild
parent: Non-excluded Child
grand_parent: Non-excluded
nav_exclude: true
```
---
layout: default
title: Non-excluded Child of Excluded
parent: Excluded
nav_exclude: false
---
# Non-excluded Child of Excluded
This child page is explicitly not excluded, but its parent page is excluded, so it should not appear in the navigation.
```yaml
title: Non-excluded Child of Excluded
parent: Excluded
nav_exclude: false
```
---
layout: default
title: Non-excluded Grandchild of Excluded
parent: Non-excluded Child
grand_parent: Excluded
nav_exclude: false
---
# Non-excluded Grandchild of Excluded
This grandchild page is explicitly not excluded, and neither is its parent page; but its grandparent page is excluded, so it should not appear in the navigation.
```yaml
title: Non-excluded Grandchild of Excluded
parent: Non-excluded Child
grand_parent: Excluded
nav_exclude: false
```
---
layout: default
title: Non-excluded Grandchild
parent: Non-excluded Child
grand_parent: Non-excluded
nav_exclude: false
---
# Non-excluded Grandchild
This grandchild page is explicitly not excluded, and neither is its parent page nor its grandparent page, so it should appear in the navigation.
```yaml
title: Non-excluded Grandchild of Excluded
parent: Non-excluded Child
grand_parent: Excluded
nav_exclude: false
```
---
layout: default
title: Excluded
title: Tests for exclusion 0
has_children: true
nav_exclude: true
---
# Excluded
This top-level page is explicitly excluded, and should not appear in the navigation. Any child pages are implicitly excluded.
# Tests for exclusion 0
```yaml
title: Excluded
title: Tests for exclusion 0
has_children: true
nav_exclude: true
```
---
layout: default
title: Tests for exclusion 00
parent: Tests for exclusion 0
has_children: true
nav_exclude: true
---
# Tests for exclusion 00
```yaml
title: Tests for exclusion 00
parent: Tests for exclusion 0
has_children: true
nav_exclude: true
```
---
layout: default
title: Tests for exclusion 000
parent: Tests for exclusion 00
grand_parent: Tests for exclusion 0
has_children: false
nav_exclude: true
---
# Tests for exclusion 000
```yaml
title: Tests for exclusion 000
parent: Tests for exclusion 00
grand_parent: Tests for exclusion 0
has_children: false
nav_exclude: true
```
---
layout: default
title: Tests for exclusion 001
parent: Tests for exclusion 00
grand_parent: Tests for exclusion 0
has_children: false
nav_exclude: false
---
# Tests for exclusion 001
```yaml
title: Tests for exclusion 001
parent: Tests for exclusion 00
grand_parent: Tests for exclusion 0
has_children: false
nav_exclude: false
```
---
layout: default
title: Non-excluded Child
parent: Non-excluded
title: Tests for exclusion 01
parent: Tests for exclusion 0
has_children: true
nav_exclude: false
---
# Non-excluded Child
This child page is explicitly not excluded, and should appear in the navigation.
# Tests for exclusion 01
```yaml
title: Non-excluded Child
parent: Non-excluded
title: Tests for exclusion 01
parent: Tests for exclusion 0
has_children: true
nav_exclude: false
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment