Skip to content

Commit

Permalink
Docs: Fix categories to sort by title instead of filename
Browse files Browse the repository at this point in the history
The default seems to be sorted by filename, which would be good
enough if it weren't for the fact that it includes the `.md` file
extension, and thus, after we introduced `test.each.md`, the sorting
was:

* test.each
* test
* test.only
* test.skip
* test.todo

because `each` < `md`:

* test.each.md
* test.md
* test.only.md
* test.skip.md
* test.todo.md

Fix by adding an explicit sort for the `title` key.

Ref #1569.
  • Loading branch information
Krinkle committed May 16, 2021
1 parent 07de4b1 commit 18c47c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/_layouts/category.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h2>{{ page.title }}</h2>

<ul class="page-list">
{% assign pages = site.pages | where:'categories', page.category %}
{% assign pages = site.pages | where: 'categories', page.category | sort_natural: 'title' %}
{% for page in pages %}
<li class="page-item">
<h3><a href="{{ page.url }}">{{page.title}}</a></h3>
Expand Down
10 changes: 5 additions & 5 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<section class="sidebar">
<h4>Main methods</h4>
<ul class="sidebar-list">
{% assign methods = site.pages | where:'categories', 'main' %}
{% assign methods = site.pages | where: 'categories', 'main' | sort_natural: 'title' %}
{% for entry in methods %}
<li class="sidebar-item{% if entry.url == page.url %} sidebar-item-active{% endif %}">
<a href="{{ entry.url }}">{{entry.title}}</a>
Expand All @@ -15,7 +15,7 @@ <h4>Main methods</h4>

<h4>Assertions</h4>
<ul class="sidebar-list">
{% assign assertions = site.pages | where:'categories', 'assert' %}
{% assign assertions = site.pages | where: 'categories', 'assert' | sort_natural: 'title' %}
{% for entry in assertions %}
<li class="sidebar-item{% if entry.url == page.url %} sidebar-item-active{% endif %}">
<a href="{{ entry.url }}">{{entry.title}}</a>
Expand All @@ -26,7 +26,7 @@ <h4>Assertions</h4>
<h4>Configuration tools</h4>

<ul class="sidebar-list">
{% assign config = site.pages | where:'categories', 'config' %}
{% assign config = site.pages | where: 'categories', 'config' | sort_natural: 'title' %}
{% for entry in config %}
<li class="sidebar-item{% if entry.url == page.url %} sidebar-item-active{% endif %}">
<a href="{{ entry.url }}">{{entry.title}}</a>
Expand All @@ -37,7 +37,7 @@ <h4>Configuration tools</h4>
<h4>Callback events</h4>

<ul class="sidebar-list">
{% assign callbacks = site.pages | where:'categories', 'callbacks' %}
{% assign callbacks = site.pages | where: 'categories', 'callbacks' | sort_natural: 'title' %}
{% for entry in callbacks %}
<li class="sidebar-item{% if entry.url == page.url %} sidebar-item-active{% endif %}">
<a href="{{ entry.url }}">{{entry.title}}</a>
Expand All @@ -48,7 +48,7 @@ <h4>Callback events</h4>
<h4>Async control</h4>

<ul class="sidebar-list">
{% assign async = site.pages | where:'categories', 'async' %}
{% assign async = site.pages | where: 'categories', 'async' | sort_natural: 'title' %}
{% for entry in async %}
<li class="sidebar-item{% if entry.url == page.url %} sidebar-item-active{% endif %}">
<a href="{{ entry.url }}">{{entry.title}}</a>
Expand Down

0 comments on commit 18c47c0

Please sign in to comment.