Skip to content

Commit d388da3

Browse files
committed
Alphabetize tag listing
1 parent cf0397b commit d388da3

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

_layouts/post.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h2>{{ page.date | date: "%B %d, %Y" }}</h2>
4343
<div class="entry-content">
4444
{{ content }}
4545
<footer class="entry-meta">
46-
<span class="entry-tags">{% for tag in page.tags %}<a href="{{ site.url }}/tags/#{{ tag | cgi_encode }}" title="Pages tagged {{ tag }}" class="tag">{{ tag }}</a>{% unless forloop.last %}{% endunless %}{% endfor %}</span>
46+
<span class="entry-tags">{% for tag in page.tags %}<a href="{{ site.url }}/tags/#{{ tag }}" title="Pages tagged {{ tag }}" class="tag">{{ tag }}</a>{% unless forloop.last %}{% endunless %}{% endfor %}</span>
4747
<span><a href="{{ site.url }}{{ page.url }}" rel="bookmark" title="{{ page.title }}">{{ page.title }}</a> was published on <span class="entry-date date published updated"><time datetime="{{ page.date | date_to_xmlschema }}">{{ page.date | date: "%B %d, %Y" }}</time></span></span>
4848
{% if page.modified %}(revised: <span class="entry-date date modified"><time datetime="{{ page.modified }}">{{ page.modified | date: "%m/%d/%Y" }}</time></span>){% endif %}
4949
<span class="author vcard"><span class="fn"><a href="{{ site.url }}/about/" title="About {{ site.owner.name }}">{{ site.owner.name }}</a></span></span>

tags.html

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,24 @@
55
description: "An archive of posts sorted by tag."
66
---
77

8+
{% capture site_tags %}{% for tag in site.tags %}{{ tag | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
9+
{% assign tags_list = site_tags | split:',' | sort %}
10+
811
<ul class="entry-meta inline-list">
9-
{% assign tags_list = site.tags %}
10-
{% if tags_list.first[0] == null %}
11-
{% for tag in tags_list %}
12-
<li><a href="#{{ tag }}" class="tag">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li>
13-
{% endfor %}
14-
{% else %}
15-
{% for tag in tags_list %}
16-
<li><a href="#{{ tag[0] }}" class="tag">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li>
17-
{% endfor %}
18-
{% endif %}
19-
{% assign tags_list = nil %}
12+
{% for item in (0..site.tags.size) %}{% unless forloop.last %}
13+
{% capture this_word %}{{ tags_list[item] | strip_newlines }}{% endcapture %}
14+
<li><a href="#{{ this_word }}" class="tag">{{ this_word }} <span>{{ site.tags[this_word].size }}</span></a></li>
15+
{% endunless %}{% endfor %}
2016
</ul>
2117

22-
{% for tag in site.tags %}
18+
{% for item in (0..site.tags.size) %}{% unless forloop.last %}
19+
{% capture this_word %}{{ tags_list[item] | strip_newlines }}{% endcapture %}
2320
<article>
24-
<h2 id="{{ tag[0] }}">{{ tag[0] }}</h2>
21+
<h2 id="{{ this_word }}">{{ this_word }}</h2>
2522
<ul>
26-
{% assign pages_list = tag[1] %}
27-
{% for post in pages_list %}
28-
{% if post.title != null %}
29-
{% if group == null or group == post.group %}
30-
<li class="entry-title"><a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></li>
31-
{% endif %}
32-
{% endif %}
33-
{% endfor %}
34-
{% assign pages_list = nil %}
35-
{% assign group = nil %}
23+
{% for post in site.tags[this_word] %}{% if post.title != null %}
24+
<li class="entry-title"><a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></li>
25+
{% endif %}{% endfor %}
3626
</ul>
3727
</article><!-- /.hentry -->
38-
{% endfor %}
28+
{% endunless %}{% endfor %}

0 commit comments

Comments
 (0)