-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
50 lines (39 loc) · 1.2 KB
/
index.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
---
layout: default
title: Home
navbar_order: 1
---
<h1>Blog posts</h1>
<h3 id="show-filter"></h3>
<ul>
{% for post in site.posts %}
<li data-tags='{{ post.tags | jsonify }}' class="post-item">
<span>{{ post.date | date_to_string }}</span> »
<a href="{{ site.baseurl }}{{ post.url }}">
{{ post.title }}
</a>
</li>
{% endfor %}
</ul>
<script>
function get_filter_tag() {
var re = new RegExp("[?&]tag=([^&#]*)");
var re_result = re.exec(window.location.href);
return re_result ? re_result[1] : null;
}
var filter_heading = document.getElementById("show-filter");
filter_heading.style.display = "none";
var filter_tag = get_filter_tag();
if (filter_tag) {
filter_heading.innerHTML = "Posts tagged with <code>" + filter_tag + "</code>:";
filter_heading.style.display = "block";
var posts = document.querySelectorAll("[data-tags]");
for (var i = 0; i < posts.length; i++) {
var post = posts[i];
if (JSON.parse(post.dataset.tags).indexOf(filter_tag) === -1) {
post.parentNode.removeChild(post);
}
}
}
// TODO: Handle no search result.
</script>