forked from barryclark/jekyll-now
-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.html
47 lines (44 loc) · 1.01 KB
/
category.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
---
layout: page
title: 文章分类
permalink: /category/
---
{% assign rawcates = "" %}
{% for post in site.posts %}
{% assign ttcate = post.categories | join:'|' | append:'|' %}
{% assign rawcates = rawcates | append:ttcate %}
{% endfor %}
{% assign rawcates = rawcates | split:'|' | sort %}
{% assign cats = "" %}
{% for tag in rawcates %}
{% if tag != "" %}
{% if cats == "" %}
{% assign cats = tag | split:'|' %}
{% endif %}
{% unless cats contains tag %}
{% assign cats = cats | join:'|' | append:'|' | append:tag | split:'|' %}
{% endunless %}
{% endif %}
{% endfor %}
※
{% for tag in cats %}
<a href="#{{ tag | slugify }}"> {{ tag }} </a> ※
{% endfor %}
<hr />
{% for tag in cats %}
<h2 id="{{ tag | slugify }}">{{ tag }}</h2>
<ul>
{% for post in site.posts %}
{% if post.categories contains tag %}
<li>
<h3>
<a href="{{ post.url }}">
{{ post.title }}
<small>{{ post.date | date: "%Y-%m-%d" }}</small>
</a>
</h3>
</li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}