forked from hawkhai/hawkhai.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategories.html
43 lines (37 loc) · 1.23 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
---
layout: page
title: 分类
---
{% assign rawcategories = "" %}
{% for post in site.posts %}
{% assign tcategories = post.categories | join:'|' | append:'|' %}
{% assign rawcategories = rawcategories | append:tcategories %}
{% endfor %}
{% assign rawcategories = rawcategories | split:'|' | sort %}
{% assign categories = "" %}
{% for tag in rawcategories %}
{% if tag != "" %}
{% if categories == "" %}
{% assign categories = tag | split:'|' %}
{% endif %}
{% unless categories contains tag %}
{% assign categories = categories | join:'|' | append:'|' | append:tag | split:'|' %}
{% endunless %}
{% endif %}
{% endfor %}
<div class="posts">
<p>
{% for tag in categories %}
<a href="#{{ tag }}"><code><nobr>{{ tag }}</nobr></code></a>
{% endfor %}
{% for tag in categories %}
<h2 id="{{ tag }}">{{ tag }}</h2>
<ul>
{% for post in site.posts %}
{% if post.categories contains tag %}
<li><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }} | {{ post.date | date_to_string }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
</div>