From e643c1fc0ac2f27763d04b985f617a0e0b8f8b37 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 1 Nov 2019 22:46:52 +0100 Subject: [PATCH] improve sidebar sorting Instead of sorting by title then sort_key, sort by sort_key first and then by title within a single sort_key. Also ensure documents without sort_key come after pages with. --- _layouts/sidebar.html | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/_layouts/sidebar.html b/_layouts/sidebar.html index feffca8cc2..615fd2c6b7 100644 --- a/_layouts/sidebar.html +++ b/_layouts/sidebar.html @@ -6,27 +6,30 @@ layout: default
- {% for group in toplevels %} - {% assign frontdoc=group.docs| where_exp: "doc","doc.path == group.frontpage"|first %} + {% for collection in toplevels %} + {% assign frontdoc = collection.docs | where_exp: "doc","doc.path == collection.frontpage" | first %} {% unless frontdoc %} - {% assign frontdoc=group.docs[0] %} - {% endunless %} + {% assign frontdoc = collection.docs[0] %} + {% endunless %} {% capture target %}{% include link.html url=frontdoc.url %}{% endcapture %}
- {{ group.caption }} - {% if page.collection == group.label %} - {% assign subpages = group.docs | sort_natural:"title" | sort:"sort_key" %} - {% for doc in subpages %} - {% assign classmodifier="" %} - {% if doc.url == page.url %} - {% assign classmodifier="disabled" %} - {% endif %} - {% capture target %}{% include link.html url=doc.url %}{% endcapture %} - {% include title.html doc=doc coll=group %} + {{ collection.caption }} + {% if page.collection == collection.label %} + {% assign docs_by_sort_key = collection.docs | group_by:"sort_key" | sort:"name", "last" %} + {% for group in docs_by_sort_key %} + {% assign docs_sorted = group.items | sort:"title" %} + {% for doc in docs_sorted %} + {% assign classmodifier="" %} + {% if doc.url == page.url %} + {% assign classmodifier="disabled" %} + {% endif %} + {% capture target %}{% include link.html url=doc.url %}{% endcapture %} + {% include title.html doc=doc coll=collection %} + {% endfor %} {% endfor %} {% endif %}
- {% endfor %} + {% endfor %}
{% if page.title %}