diff --git a/.gitignore b/.gitignore index b447a12d605ace944d4b5f46e384a2513e8af4f1..a802a863ac5ddcf32b32cdcc986f973cbca92f74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.gem .bundle +.jekyll-cache .sass-cache _site Gemfile.lock diff --git a/_config.yml b/_config.yml index 7a48a7017040187b841fad9fc9218da57056a6cc..0f6cac82818a56727f3dce6e8d53878d139d6745 100644 --- a/_config.yml +++ b/_config.yml @@ -38,6 +38,10 @@ aux_links: "Just the Docs on GitHub": - "//github.com/pmarsceill/just-the-docs" +# Sort order for navigation links +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 footer_content: "Copyright © 2017-2019 Patrick Marsceill. Distributed by an <a href=\"https://github.com/pmarsceill/just-the-docs/tree/master/LICENSE.txt\">MIT license.</a>" diff --git a/_includes/nav.html b/_includes/nav.html index 8042aa48a2130252e06c04230b993e0471ecfb3d..6858dec980294a400ec5211b8a8f42e39d7a852a 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -1,6 +1,15 @@ <nav role="navigation" aria-label="Main navigation"> <ul class="navigation-list"> - {%- assign pages_list = site.html_pages | sort:"nav_order" -%} + {%- assign ordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order != nil" -%} + {%- assign unordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order == nil" -%} + {%- if site.nav_sort == 'case_sensitive' -%} + {%- assign sorted_ordered_pages_list = ordered_pages_list | sort:"nav_order" -%} + {%- assign sorted_unordered_pages_list = unordered_pages_list | sort:"title" -%} + {%- else -%} + {%- assign sorted_ordered_pages_list = ordered_pages_list | sort_natural:"nav_order" -%} + {%- assign sorted_unordered_pages_list = unordered_pages_list | sort_natural:"title" -%} + {%- endif -%} + {%- assign pages_list = sorted_ordered_pages_list | concat: sorted_unordered_pages_list -%} {%- for node in pages_list -%} {%- unless node.nav_exclude -%} {%- if node.parent == nil -%} @@ -10,29 +19,27 @@ {%- endif -%} <a href="{{ node.url | absolute_url }}" class="navigation-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a> {%- if node.has_children -%} - {%- assign children_list = site.html_pages | where: "parent", node.title | sort:"nav_order" -%} + {%- assign children_list = pages_list | where: "parent", node.title -%} <ul class="navigation-list-child-list "> {%- for child in children_list -%} - {%- unless child.nav_exclude -%} - <li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}"> - {%- if page.url == child.url or page.parent == child.title -%} - {%- assign second_level_url = child.url | absolute_url -%} - {%- endif -%} - <a href="{{ child.url | absolute_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a> - {%- if child.has_children -%} - {%- assign grand_children_list = site.html_pages | where: "parent", child.title | sort:"nav_order" -%} - <ul class="navigation-list-child-list"> - {%- for grand_child in grand_children_list -%} - {%- unless grand_child.nav_exclude -%} - <li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}"> - <a href="{{ grand_child.url | absolute_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a> - </li> - {%- endunless -%} - {%- endfor -%} - </ul> - {%- endif -%} - </li> - {%- endunless -%} + {%- unless child.nav_exclude -%} + <li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}"> + {%- if page.url == child.url or page.parent == child.title -%} + {%- assign second_level_url = child.url | absolute_url -%} + {%- endif -%} + <a href="{{ child.url | absolute_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a> + {%- if child.has_children -%} + {%- assign grand_children_list = pages_list | where: "parent", child.title -%} + <ul class="navigation-list-child-list"> + {%- for grand_child in grand_children_list -%} + <li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}"> + <a href="{{ grand_child.url | absolute_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a> + </li> + {%- endfor -%} + </ul> + {%- endif -%} + </li> + {%- endunless -%} {%- endfor -%} </ul> {%- endif -%} diff --git a/_layouts/default.html b/_layouts/default.html index 13a860f354fb83b2a5903170199a701b42ec1e0d..d7ebc17cb2ec89b0fc02d522082960ccf7c71888 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -74,9 +74,8 @@ layout: table_wrappers {% if page.has_children == true and page.has_toc != false %} <hr> <h2 class="text-delta">Table of contents</h2> - {% assign children_list = site.pages | sort:"nav_order" %} <ul> - {% for child in children_list %} + {% for child in pages_list %} {% if child.parent == page.title and child.title != page.title %} <li> <a href="{{ child.url | absolute_url }}">{{ child.title }}</a>{% if child.summary %} - {{ child.summary }}{% endif %} diff --git a/docs/navigation-structure.md b/docs/navigation-structure.md index a4fef75ef4a46d8e6bd5684652febb99c90f3e74..e5f29ad2682eb95fc5a07040ffccd11f25831491 100644 --- a/docs/navigation-structure.md +++ b/docs/navigation-structure.md @@ -38,6 +38,12 @@ nav_order: 4 --- ``` +The specified `nav_order` parameters on a site should be all integers or all strings. +Pages without a `nav_order` parameter are ordered alphabetically by their `title`, +and appear after the explicitly-ordered pages at each level. +To sort all Capital letters before lowercase letters, +add `nav_sort: case_sensitive` in the configuration file. + --- ## Excluding pages diff --git a/docs/utilities/color.md b/docs/utilities/color.md index ba90b3b95530f5a8917bf23f6178d68ce7158e78..0f375978afbf24ce47bdcd76f4b043883e0f5aae 100644 --- a/docs/utilities/color.md +++ b/docs/utilities/color.md @@ -2,7 +2,6 @@ layout: default title: Color parent: Utilities -nav_order: 3 --- # Color Utilities diff --git a/docs/utilities/layout.md b/docs/utilities/layout.md index 38ec1b2eec5f3cbec293f7a29767246fbba5b485..4410459f1d5ee7b30aecd72d638a09b2c791e0e6 100644 --- a/docs/utilities/layout.md +++ b/docs/utilities/layout.md @@ -2,7 +2,6 @@ layout: default title: Layout parent: Utilities -nav_order: 2 --- # Layout Utilities diff --git a/docs/utilities/responsive-modifiers.md b/docs/utilities/responsive-modifiers.md index bc5e2cb2def922e11109814a84ff095495bf76c5..c732530ed7a06df6730960f1c715689008da2a43 100644 --- a/docs/utilities/responsive-modifiers.md +++ b/docs/utilities/responsive-modifiers.md @@ -2,7 +2,6 @@ layout: default title: Responsive Modifiers parent: Utilities -nav_order: 1 --- # Responsive modifiers diff --git a/docs/utilities/typography.md b/docs/utilities/typography.md index 786b65a504da9e0fa99f7c3198de2e70a589f750..6b952a970e4906f394ce36c3a404c5736505e041 100644 --- a/docs/utilities/typography.md +++ b/docs/utilities/typography.md @@ -2,7 +2,6 @@ layout: default title: Typography parent: Utilities -nav_order: 4 --- # Typography Utilities