forked from mlg-blog/mlg-blog.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathposts-by-tag.html
28 lines (25 loc) · 1.04 KB
/
posts-by-tag.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
layout: static_page_no_bg
permalink: /posts-by-tag
title: "Posts by Tag"
# Inspired by http://pavdmyt.com/how-to-implement-tags-at-jekyll-website/.
---
<!-- Capture all tags. -->
{% capture tags %}{% for tag in site.tags %}{{ tag | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign tags = tags | split: ',' | sort %}
<!-- Print tags. -->
<p class="tags posts-by-tag">
{% for i in (0..site.tags.size) %}{% unless forloop.last %}{{ ""
}}{% assign tag = tags[i] %}{{ ""
}}<a href="#{{ tag | cgi_escape }}" class="tag">{{ tag }}
<span class="count">({{ site.tags[tag].size }})</span>
</a>{{ ""
}}{% endunless %}{% endfor %}
</p>
<!-- Print sections associated to tags. -->
{% for tag in tags %}
{% assign words = tag | split: ' ' %}
{% capture tag_titled %}{% for word in words %}{{ word | capitalize }} {% endfor %}{% endcapture %}
<h2 id="{{ tag | cgi_escape }}" class="small-share-shift">{{ tag_titled }}</h2>
{% include posts.html tag=tag %}
{% endfor %}