Alphabetize tag listing. Fixes #10

This commit is contained in:
Michael Rose 2014-06-11 13:43:08 -04:00
parent 5e37436a64
commit 37326f6e6e
2 changed files with 17 additions and 27 deletions

View file

@ -16,7 +16,7 @@
{% if page.image.feature %}<img src="{{ site.url }}/images/{{ page.image.feature }}" class="entry-feature-image" alt="{{ page.title }}" {% if site.logo == null %}style="margin-top:0;"{% endif %}>{% if page.image.credit %}<p class="image-credit">Photo Credit: <a href="{{ page.image.creditlink }}">{{ page.image.credit }}</a>{% endif %}{% endif %} {% if page.image.feature %}<img src="{{ site.url }}/images/{{ page.image.feature }}" class="entry-feature-image" alt="{{ page.title }}" {% if site.logo == null %}style="margin-top:0;"{% endif %}>{% if page.image.credit %}<p class="image-credit">Photo Credit: <a href="{{ page.image.creditlink }}">{{ page.image.credit }}</a>{% endif %}{% endif %}
<div class="entry-wrapper"> <div class="entry-wrapper">
<header class="entry-header"> <header class="entry-header">
<span class="entry-tags">{% for tag in page.tags %}<a href="{{ site.url }}/tags/#{{ tag | cgi_encode }}" title="Pages tagged {{ tag }}">{{ tag }}</a>{% unless forloop.last %}&nbsp;&bull;&nbsp;{% endunless %}{% endfor %}</span> <span class="entry-tags">{% for tag in page.tags %}<a href="{{ site.url }}/tags/#{{ tag }}" title="Pages tagged {{ tag }}">{{ tag }}</a>{% unless forloop.last %}&nbsp;&bull;&nbsp;{% endunless %}{% endfor %}</span>
{% if page.link %} {% if page.link %}
<h1 class="entry-title"><a href="{{ page.link }}">{% if page.headline %}{{ page.headline }}{% else %}{{ page.title }}{% endif %} <span class="link-arrow">&rarr;</span></a></h1> <h1 class="entry-title"><a href="{{ page.link }}">{% if page.headline %}{{ page.headline }}{% else %}{{ page.title }}{% endif %} <span class="link-arrow">&rarr;</span></a></h1>
{% else %} {% else %}

View file

@ -5,32 +5,22 @@ title: Tag Index
description: "An archive of posts sorted by tag." description: "An archive of posts sorted by tag."
--- ---
{% capture site_tags %}{% for tag in site.tags %}{{ tag | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign tags_list = site_tags | split:',' | sort %}
<ul class="tag-box inline"> <ul class="tag-box inline">
{% assign tags_list = site.tags %} {% for item in (0..site.tags.size) %}{% unless forloop.last %}
{% if tags_list.first[0] == null %} {% capture this_word %}{{ tags_list[item] | strip_newlines }}{% endcapture %}
{% for tag in tags_list %} <li><a href="#{{ this_word }}">{{ this_word }} <span>{{ site.tags[this_word].size }}</span></a></li>
<li><a href="#{{ tag }}">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li> {% endunless %}{% endfor %}
{% endfor %}
{% else %}
{% for tag in tags_list %}
<li><a href="#{{ tag[0] }}">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li>
{% endfor %}
{% endif %}
{% assign tags_list = nil %}
</ul> </ul>
{% for tag in site.tags %} {% for item in (0..site.tags.size) %}{% unless forloop.last %}
<h2 id="{{ tag[0] }}">{{ tag[0] }}</h2> {% capture this_word %}{{ tags_list[item] | strip_newlines }}{% endcapture %}
<ul class="post-list"> <h2 id="{{ this_word }}">{{ this_word }}</h2>
{% assign pages_list = tag[1] %} <ul class="post-list">
{% for post in pages_list %} {% for post in site.tags[this_word] %}{% if post.title != null %}
{% if post.title != null %} <li><a href="{{ site.url }}{{ post.url }}">{{ post.title }}<span class="entry-date"><time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date: "%B %d, %Y" }}</time></span></a></li>
{% if group == null or group == post.group %} {% endif %}{% endfor %}
<li><a href="{{ site.url }}{{ post.url }}">{{ post.title }}<span class="entry-date"><time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date: "%B %d, %Y" }}</time></span></a></li> </ul>
{% endif %} {% endunless %}{% endfor %}
{% endif %}
{% endfor %}
{% assign pages_list = nil %}
{% assign group = nil %}
</ul>
{% endfor %}