/
tag.html
75 lines (67 loc) · 1.96 KB
/
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
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
layout: document
title: Tag
permalink: /tag/
public: true
---
{% assign tagMap = site.data.tagMap %}
{% assign tagList = site.data.tagList %}
<div>
<ul class="tag-list">
{% for tag in tagList %}
<li>
<a href="#{{tag}}" onclick="showTag('#{{tag}}')">
{{tag}}<sup>{{ tagMap[tag] | size }}</sup>
</a>
</li>
{% endfor %}
</ul>
</div>
<div>
{% for tag in tagList %}
<div class="archive-group invisible" id="{{tag}}">
<h3 id="{{tag}}">{{ tag }}</h3>
<ul class="post-list">
{% assign list = tagMap[tag] | sort: 'updated' | reverse %}
{% for postObj in list %}
{% assign post = site.data.pageMap[postObj.fileName] %}
{% if post.public != false %}
<li>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">
<span>{{ post.title }}</span>
<div class="post-meta" style="float: right;">
{{ post.updated | date: "%Y.%m.%d" }}
</div>
{% if post.summary %}
<div class="post-excerpt">
- {{ post.summary }}
</div>
{% endif %}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
<script>
function showTag(selector) {
document.querySelectorAll('.visible')
.forEach(function(el) {
el.classList.remove('visible');
el.classList.add('invisible');
})
var list = document.querySelector(selector);
list.classList.add('visible');
list.classList.remove('invisible');
}
;(function showInitTag() {
const url = window.location.href;
const req = /#([^\s]+)$/.exec(url);
if(Array.isArray(req)) {
var selector = '#' + req.pop();
showTag(selector);
}
})();
</script>