-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default nav order #236
Default nav order #236
Conversation
When `nav_order` is omitted, the order of nodes at each menu level (and in the auto-generated TOC) is alphabetical by `title`, instead of random. Any nodes with a specified `nav_order` precede all nodes at that level where it is omitted. Note that `nav_order` fields must have a uniform site-ide type: integers and strings cannot be mixed, otherwise Jekyll reports errors. The implementation filters the ordered and unordered pages from `site.html_pages`, sorts them separately, and concatenates the resulting arrays.
The `nav_order` fields are removed from the children of the Utilities node, which results in alphabetic order.
Added documentation of default nav order.
For example, see https://pdmosses.github.io/test-nav/ where all |
#192 already does this btw |
@thealjey That is what I thought too, when I looked at your code. But when I tested it on my test-nav site with no explicit You have:
I suspect that the My suggested implementation avoids sorting pages on |
hm, my pages all have a I think the do you have a suggestion how to address this problem (while keeping the functionality)? |
I agree with your summary. Note however that the Liquid filters page states:
The following appears to address the issue when using your recursive navigation code in https://github.com/pdmosses/test-nav:
I made related changes in some of the files in |
so, you simply want them at the end, rather than to preserve their alphabetical order? |
My proposed fix ensures that pages at each menu level are sorted by title when no Mixing pages with Note also that when sorting on a mixture of |
move ref doc gen back to API repo generated ref docs using new md format adds accordion style nav patch from just-the-docs/just-the-docs#252 splits out reference types fix return type orders TOC and children by name retrofits just-the-docs/just-the-docs#236 fix ref types connection types allows great grandchildren splits mutations into sub groups add favicon remove old reference htmls move voyager to root regen reference update getting started fref fvoyager fix voyager links fix paths connections grouped fix breadcrumb, fix sidebar hierarchy fref snakecase all urls fix field links for custom grouped objects group return types adds input type groupings rm about fix broken grouping for LabelInput (where we strip Input suffix) fix toc and nav linking to other great grandchildren in reference tree
Changing »sort« with »sort_natural« would allow this theme to be used with the german language, where all nouns are capitalized and there should be no difference (when sorted alphabetically) between, let’s say »gut« (good) and »Gute« (the good). sort : Sorts items in an array in case-sensitive order. sort_natural : Sorts items in an array in case-insensitive order. Wouldn’t it (even with the english language) make more sense to sort ( let’s say in a dictionary) in case-INSENSITIVE order? By the way: Thanks a lot for this. |
@alemsabic thanks for the suggestion of using I agree that |
This sounds good to me, thanks for the work and thinking here @pdmosses @alemsabic and @alemsabic |
@pmarsceill I will try to update this PR tomorrow to incorporate the customisable sort order, and test (locally) that it works as intended. How about the following names for use in the config file:
I think that is clearer than Liquid's Also, I need to update the branch for this PR to the current release. I'm assuming that I can just click on |
Added `.jekyll-cache`
Added a configuration option to determine whether the sort order is case-sensitive. The default is case-insensitive. To test: - open `/just-the-docs/docs/utilities/` in the browser, and check that the navigation links in `Utilities` are sorted alphabetically; - in `docs/utilities/layout.md', change the preamble to `title: layout`, and check that the links in `Utilities` are still sorted alphabetically; - add `nav_sort: case_sensitive` in the configuration file, and check that the link to `layout` is now listed last under `Utilities`.
A failing CI check appeared right after I clicked on I have subsequently updated the PR with the suggested configuration option for case-sensitivity. To test:
@pmarsceill, could this be included in the next minor release? AFAIK, it is non-breaking. |
@alemsabic I've updated this PR to revert the default for See also the comments about A potential workaround is to check whether the |
@pdmosses Wow! Just read about it. Crazy you found this out by testing. I had about fifty pages on a German site and a Croatian site as well (with your proposed changes for the navigation plus |
@alemsabic I fully agree :-) In fact I only discovered it accidentally (rather than by systematic testing): I was testing a different PR based on 0.2.9, and I added some test files, using numbers above 100 for the BTW, I'm not familiar with the Ruby/Jekyll/Liquid code base, and I have difficulty finding the relevant sources. If you happen to know where to look for the source code for |
When
nav_order
is omitted, the order of nodes at each menu level (and in the auto-generated TOC) is now alphabetical bytitle
, instead of random. Addresses issue #228.When a non-alphabetic order is required at a particular level, it is recommended to set the
nav_order
for all its nodes. (If mixed, ordered nodes come before unordered nodes).As at present,
nav_order
fields must have a uniform site-wide type: integers and strings cannot be mixed, otherwise Jekyll reports errors.The implementation filters the ordered and unordered pages from
site.html_pages
, sorts them separately, and concatenates the resulting arrays. It has been tested by removing thenav_order
fields from the children of the Utilities node, which results in alphabetic order at that menu level.It should be straightforward to implement this change also for the recursive navigation feature proposed in PR #192.