From 83ec5533489f344bd237c381e6decbecefa850f2 Mon Sep 17 00:00:00 2001 From: PLanCompS <18308236+pdmosses@users.noreply.github.com> Date: Mon, 10 Aug 2020 15:58:42 +0200 Subject: [PATCH] Ensure pages with nav_exclude are ignored by navigation Pages with `nav_exclude: true` were included when sorting on `title` or `nav_order`. That could cause build failures when the type of value of the field differs from that on other pages, as reported in https://github.com/pmarsceill/just-the-docs/issues/406. Pages with `nav_exclude: true` or no `title` are never displayed in the navigation, so removing them from `pages_list` cannot break existing sites. This change also allows the removal of some tests in the code. (The indentation of the code should now be adjusted, but that has been deferred, to restrict the size of the diff for review.) For testing, the title of `404.html` has been changed to the number `404`, the page `docs/untitled-test.md` has been added, and `nav_sort_order` has been set to `case_sensitive`. Those updates give build failures with the current version of `_includes/nav.html`, but not after the suggested changes. It will still be possible for build failures to occur due to sorting fields of *non-excluded* pages with differing types of values (e.g., `nav_order`a mixture of numbers and strings). To make the code completely safe will require relatively complicated changes,. --- 404.html | 2 +- _config.yml | 4 ++-- _includes/nav.html | 11 ++++------- docs/untitled-test.md | 6 ++++++ 4 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 docs/untitled-test.md diff --git a/404.html b/404.html index 1e7a37e..5fde966 100644 --- a/404.html +++ b/404.html @@ -1,6 +1,6 @@ --- layout: default -title: Page not found +title: 404 permalink: /404 nav_exclude: true search_exclude: true diff --git a/_config.yml b/_config.yml index 20bf8a1..fd71b51 100644 --- a/_config.yml +++ b/_config.yml @@ -63,8 +63,8 @@ aux_links: aux_links_new_tab: false # Sort order for navigation links -nav_sort: case_insensitive # default, equivalent to nil -# nav_sort: case_sensitive # Capital letters sorted before lowercase +# nav_sort: case_insensitive # default, equivalent to nil +nav_sort: case_sensitive # Capital letters sorted before lowercase # Footer content # appears at the bottom of every page's main content diff --git a/_includes/nav.html b/_includes/nav.html index f2ec7e5..d74c17c 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -1,6 +1,7 @@ {%- endif -%} {%- endif -%} - {%- endunless -%} {%- endfor -%} diff --git a/docs/untitled-test.md b/docs/untitled-test.md new file mode 100644 index 0000000..84f66d8 --- /dev/null +++ b/docs/untitled-test.md @@ -0,0 +1,6 @@ +--- +layout: default +--- +# Untitled test page + +This page should not appear in the navigation.