From 07df1794351b984a27ea259cf8a02d3ac66de59d Mon Sep 17 00:00:00 2001 From: Peter Mosses <18308236+pdmosses@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:29:11 +0200 Subject: [PATCH] Correct details regarding nav sort order --- Gemfile.lock | 2 +- _config.yml | 2 ++ collections/_navigation/order/mixture/index.md | 14 ++++++-------- collections/_navigation/order/strings/b.md | 15 +++++++++++++++ collections/_navigation/order/strings/index.md | 18 +++++++++++++++--- 5 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 collections/_navigation/order/strings/b.md diff --git a/Gemfile.lock b/Gemfile.lock index c7596d1..1e6b375 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,7 +70,7 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rexml (3.2.6) - rouge (4.1.2) + rouge (4.1.3) safe_yaml (1.0.5) sass-embedded (1.64.1-arm64-darwin) google-protobuf (~> 3.23) diff --git a/_config.yml b/_config.yml index 733a594..8c3d543 100644 --- a/_config.yml +++ b/_config.yml @@ -49,6 +49,8 @@ enable_copy_code_button: true # block: # line_numbers: true +# nav_sort: case_insensitive + collections_dir: collections collections: diff --git a/collections/_navigation/order/mixture/index.md b/collections/_navigation/order/mixture/index.md index 2f1a657..6c512e0 100644 --- a/collections/_navigation/order/mixture/index.md +++ b/collections/_navigation/order/mixture/index.md @@ -9,7 +9,7 @@ has_children: true It seems unlikely that different types of `nav_order` values are needed for the children of the same parent. -1. Check that the titles of the children of this page are shown in the order: +1. Check that the titles of the children of this page are shown in the order:[^1] ``` -1.1 -1 @@ -17,15 +17,13 @@ It seems unlikely that different types of `nav_order` values are needed for the 0 2.2222 10.0 + Aa + aa 2 10 A - Aa - aa ``` + +---- - {: .note } - The default order of numeric titles depends on which version of Jekyll is used - to build the site: - the default build on GitHub Pages uses Jekyll 3.9 and gives lexicographic order, - but when using Jekyll 4, `2` precedes `10`. ❌ +[^1]: When using Jekyll 3.9, the string `"10"` comes before `"2"`. diff --git a/collections/_navigation/order/strings/b.md b/collections/_navigation/order/strings/b.md new file mode 100644 index 0000000..bcfdbcb --- /dev/null +++ b/collections/_navigation/order/strings/b.md @@ -0,0 +1,15 @@ +--- +title: B +nav_order: B +parent: Strings +grand_parent: Order +--- + +# B + +```yaml +title: B +nav_order: B +parent: Strings +grand_parent: Order +``` diff --git a/collections/_navigation/order/strings/index.md b/collections/_navigation/order/strings/index.md index fccb2ed..1c31b78 100644 --- a/collections/_navigation/order/strings/index.md +++ b/collections/_navigation/order/strings/index.md @@ -7,15 +7,27 @@ has_children: true # String Order -By default, all Capital letters come before all lowercase letters; you can add `nav_sort: case_insensitive` in the configuration file to ignore the case). +By default, digits precede letters, numeric strings are sorted by value,[^1] +and all Capital letters come before all lowercase letters. -Digits precede letters, and numeric titles are ordered lexicographically: `"10"` precedes `"2"` (in contrast to explicit numeric `nav_order` values). +When you add `nav_sort: case_insensitive` in the configuration file, `"aa"` precedes `"B"`, +and numeric strings are ordered lexicographically: `"10"` precedes `"2"`. + +1. Check that `_config.yml` contains: + ```yaml + nav_sort: {{ site.nav_sort }} + ``` 1. Check that the titles of the children of this page are shown in the order: ``` - 10 2 + 10 A Aa + B aa ``` + +---- + +[^1]: When using Jekyll 3.9, numeric strings are always sorted lexicographically.