Skip to content

Commit

Permalink
Correct details regarding nav sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
pdmosses committed Jul 31, 2023
1 parent 242186d commit 07df179
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ enable_copy_code_button: true
# block:
# line_numbers: true

# nav_sort: case_insensitive

collections_dir: collections

collections:
Expand Down
14 changes: 6 additions & 8 deletions collections/_navigation/order/mixture/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ 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
0.0
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"`.
15 changes: 15 additions & 0 deletions collections/_navigation/order/strings/b.md
Original file line number Diff line number Diff line change
@@ -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
```
18 changes: 15 additions & 3 deletions collections/_navigation/order/strings/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 07df179

Please sign in to comment.