Skip to content

Instantly share code, notes, and snippets.

@shrysr
Last active April 3, 2016 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrysr/191d064f90f5b0046959a9e495d9047f to your computer and use it in GitHub Desktop.
Save shrysr/191d064f90f5b0046959a9e495d9047f to your computer and use it in GitHub Desktop.
Code for creating jekyll posts sorted by the tag on a page called archive-tags-sort.md
<div class='list-group'>
{% assign tags_list = site.tags %}
{% if tags_list.first[0] == null %}
{% for tag in tags_list %}
<a href="/archive-tags-sort#{{ tag }}-ref" class='list-group-item'>
{{ tag }} <span class='badge'>{{ site.tags[tag].size }}</span>
</a>
{% endfor %}
{% else %}
{% for tag in tags_list %}
<a href="/archive-tags-sort#{{ tag[0] }}-ref" class='list-group-item'>
{{ tag[0] }} <span class='badge'>{{ tag[1].size }}</span>
</a>
{% endfor %}
{% endif %}
{% assign tags_list = nil %}
</div>
{% for tag in site.tags %}
<h2 class='tag-header' id="{{ tag[0] }}-ref">{{ tag[0] }}</h2>
<ul>
{% assign pages_list = tag[1] %}
{% for node in pages_list %}
{% if node.title != null %}
{% if group == null or group == node.group %}
{% if page.url == node.url %}
<li class="active"><a href="{{node.url}}" class="active">{{node.title}}</a></li>
{% else %}
<li><a href="{{node.url}}">{{node.title}}</a></li>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% assign pages_list = nil %}
{% assign group = nil %}
</ul>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment