mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Feature: Allow unlimited multi-level navigation (#1431)
* Allow unlimited multi-level navigation This PR supersedes #462. The only user-level difference from #462 is that disambiguation of parent pages has to use either `grand_parent` or `ancestor` titles: the somewhat unnatural `section_id` and `in_section` fields are not supported. The implementation has been significantly simplified by the changes introduced in v0.7.0 of the theme. * Detect cyclic parenthood A page should not have a parent or ancestor with the same title. If it does, the location of the repeated link is marked by ∞, to facilitate debugging the navigation (and an unbounded loop leading to a build exception is avoided). * Add nav_error_report warning in main navigation When activated by `nav_error_report: true` in `_config.yml`, displays warnings about pages with the same title as their parent page or an ancestral page. * Cache site-nav with links to all pages The extra cached site-nav is used for determining breadcrumbs and children navigation, which may involve pages that are excluded from the main navigation. * Replace code for determining children by inclusion of components/nav/children.html * Update CHANGELOG.md --------- Co-authored-by: Matt Wang <matt@matthewwang.me>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
{%- comment -%}
|
||||
Include as: {%- include_cached components/site_nav.html -%}
|
||||
Include as: {%- include_cached components/site_nav.html all=bool -%}
|
||||
Depends on: site.
|
||||
Results in: HTML for the site-nav.
|
||||
Results in: cached HTML for the main navigation when `all` is nil or false;
|
||||
includes links to pages excluded from the main navigation when `all` is true.
|
||||
Includes:
|
||||
components/nav.html
|
||||
components/nav/pages.html
|
||||
Overwrites:
|
||||
pages_top_size, collections_size, collection_entry,
|
||||
collection_key, collection_value, collection.
|
||||
@@ -16,7 +17,7 @@
|
||||
| where_exp:"item", "item.nav_exclude != true"
|
||||
| size %}
|
||||
{% if pages_top_size > 0 %}
|
||||
{% include components/nav.html pages=site.html_pages %}
|
||||
{% include components/nav/pages.html pages=site.html_pages all=include.all %}
|
||||
{% endif %}
|
||||
{%- if site.nav_external_links -%}
|
||||
<ul class="nav-list">
|
||||
@@ -51,17 +52,21 @@
|
||||
</button>
|
||||
{%- endif -%}
|
||||
<div class="nav-category">{{ collection_value.name }}</div>
|
||||
{% include components/nav.html pages=collection %}
|
||||
{% include components/nav/pages.html pages=collection all=include.all %}
|
||||
</li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<div class="nav-category">{{ collection_value.name }}</div>
|
||||
{% include components/nav.html pages=collection %}
|
||||
{% include components/nav/pages.html pages=collection all=include.all %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% include components/nav.html pages=collection %}
|
||||
{% include components/nav/pages.html pages=collection all=include.all %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</nav>
|
||||
|
||||
{% if site.nav_error_report %}
|
||||
{{ nav_error_report }}
|
||||
{%- endif %}
|
||||
|
Reference in New Issue
Block a user