summaryrefslogtreecommitdiffhomepage
path: root/website
diff options
context:
space:
mode:
authorIan Lewis <ianlewis@google.com>2020-08-04 01:05:42 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-04 01:07:42 -0700
commita02b7534f21d4f963ace890e80d7bf17e0d5d10f (patch)
tree26a5d8a6aa4854f41523a098b8f979e4619bfd57 /website
parent25798f214c6d1991916906ea8fca9e7029a8c423 (diff)
Fix grouping and ordering of website menus
Groups subcategories and sorts their pages by weight properly. Subcategories are sorted by name. Pages within subcategories are sorted by weight. PiperOrigin-RevId: 324766128
Diffstat (limited to 'website')
-rw-r--r--website/_layouts/docs.html39
1 files changed, 17 insertions, 22 deletions
diff --git a/website/_layouts/docs.html b/website/_layouts/docs.html
index 6bc5d87db..0422f9fb0 100644
--- a/website/_layouts/docs.html
+++ b/website/_layouts/docs.html
@@ -14,30 +14,25 @@ categories:
{% for category in layout.categories %}
<h3>{{ category }}</h3>
<ul class="sidebar-nav">
- {% assign sorted_pages = site.pages | where: 'layout', 'docs' | where: 'category', category | sort: 'weight' | sort: 'subcategory' %}
- {% assign subcategory = nil %}
- {% for p in sorted_pages %}
- {% if p.subcategory != subcategory %}
- {% if subcategory != nil %}
- </ul>
- </li>
- {% endif %}
- {% assign subcategory = p.subcategory %}
- {% if subcategory != nil %}
- {% assign ac = "aria-controls" %}
- {% assign cid = p.category | remove: " " | downcase %}
- {% assign sid = p.subcategory | remove: " " | downcase %}
- <li>
- <a class="sidebar-nav-heading" data-toggle="collapse" href="#{{ cid }}-{{ sid }}" aria-expanded="false" {{ ac }}="{{ cid }}-{{ sid }}">{{ subcategory }}<span class="caret"></span></a>
- <ul class="collapse sidebar-nav sidebar-submenu" id="{{ cid }}-{{ sid }}">
- {% endif %}
+ {% assign subcats = site.pages | where: 'layout', 'docs' | where: 'category', category | group_by: 'subcategory' | sort: 'name', 'first' %}
+ {% for subcategory in subcats %}
+ {% assign sorted_pages = subcategory.items | sort: 'weight', 'last' %}
+ {% if subcategory.name != "" %}
+ {% assign ac = "aria-controls" %}
+ {% assign cid = category | remove: " " | downcase %}
+ {% assign sid = subcategory.name | remove: " " | downcase %}
+ <li>
+ <a class="sidebar-nav-heading" data-toggle="collapse" href="#{{ cid }}-{{ sid }}" aria-expanded="false" {{ ac }}="{{ cid }}-{{ sid }}">{{ subcategory.name }}<span class="caret"></span></a>
+ <ul class="collapse sidebar-nav sidebar-submenu" id="{{ cid }}-{{ sid }}">
{% endif %}
- <li><a href="{{ p.url }}">{{ p.title }}</a></li>
- {% endfor %}
- {% if subcategory != nil %}
- </ul>
+ {% for p in sorted_pages %}
+ <li><a href="{{ p.url }}">{{ p.title }}</a></li>
+ {% endfor %}
+ {% if subcategory.name != "" %}
</li>
- {% endif %}
+ </ul>
+ {% endif %}
+ {% endfor %}
</ul>
{% endfor %}
</nav>