<!--
Following on the sorting technique above, for this docs site, the left nav is essentially a category name and then a list of the posts within that category. In the below code, I loop through the posts (sorted by weight) and display the category header assuming the post’s category is different from the prior post (of course, this assumes that the content is organized properly by weight).
One other thing you may notice is that I ignore posts with no title. In the case of my single page documentation site, some sections had “intro” text that would display in the content but doesn’t require a navigation link. Thus, if I left the title blank, I will display it in the main content output but not in the navigation. You can also see that I am using the post.slug variable as a way to anchor the links rather than directly link to the page.
-->
<ul class="docs-nav">
{% assign posts_list = site.posts | sort:"weight" %}
{% assign last_cat = "" %}
{% for posts in posts_list %}
{% if posts.title != "" %}
{% for category in posts.categories limit:1 %}
{% if category != last_cat %}
<li><strong>{{ category | replace: "-", " " | capitalize }}</strong></li>
{% endif %}
{% assign last_cat = category %}
{% endfor %}
<li><a href="#{{ posts.slug }}" class="cc-active">{{ posts.title }}</a></li>
{% endif %}
{% endfor %}
</ul>