-
Notifications
You must be signed in to change notification settings - Fork 2
/
categories.html
executable file
·57 lines (48 loc) · 1.87 KB
/
categories.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
layout: page
title: Category Index
permalink: /categories/index.html
title: Category Index
tags: [Categories]
description: "An archive of posts sorted by categories."
---
{% comment %}
Get all the category slugs
{% endcomment %}
{% capture site_categories %}{% for category in site.categories %}{% assign catslug = category | first %}{% for categoryslug in site.data.categories %}{% if categoryslug.slug == catslug %}{{ categoryslug.name }}{% else %}{{ category | first }}{% endif %}{% endfor %}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign category_words = site_categories | split:',' | sort %}
<ul class="tag-box inline">
{% assign category_list = category_words %}
{% for category in category_list %}
{% assign slug = category %}
{% for categoryslug in site.data.categories %}
{% if categoryslug.name == category %}
{% assign slug = categoryslug.slug %}
{% endif %}
{% endfor %}
<li><a href="#{{ slug }}"><span class="article-count">{{ site.categories[slug].size }}</span><span class="element-invisible"> articles tagged </span>{{ category }}</a></li>
{% endfor %}
{% assign category_list = nil %}
</ul>
{% for category in category_words %}
{% comment %}Match the slugs back to the categories{% endcomment %}
{% assign slug = category %}
{% for categoryslug in site.data.categories %}
{% if categoryslug.name == category %}
{% assign slug = categoryslug.slug %}
{% endif %}
{% endfor %}
<h2 id="{{ slug }}">{{ category }}</h2>
<ul class="post-list">
{% assign pages_list = site.categories[slug] %}
{% for post in pages_list %}
{% if post.title != null %}
{% if group == null or group == post.group %}
{% include post-listing.html %}
{% endif %}
{% endif %}
{% endfor %}
{% assign pages_list = nil %}
{% assign group = nil %}
</ul>
{% endfor %}