forked from FeDemo/fedemo.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
date.html
67 lines (61 loc) · 1.86 KB
/
date.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
---
layout: page
title: "Date"
nav: true
description: "Time flies like an arrow, fruit flies like a banana"
header-img: "img/post-bg-swift.webp"
head_padding: "55px"
---
<!--BY Fe 按日期归档-->
<ul id="myTab" class="nav nav-tabs">
{% for post in site.posts %}
{% capture ym %}{{ post.date | date:"%Y%m" }}{% endcapture %}
{% if yearmonth != ym %}
{% assign yearmonth = ym %}
<li{% if forloop.first %} class="active"{% endif %}>
<a href="/date/#aa{{ ym }}" data-toggle="tab">{{ post.date | date: "%Y年%m月" }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
<div id="myTabContent" class="tab-content">
{% for post in site.posts %}
{% capture ym %}{{ post.date | date:"%Y%m" }}{% endcapture %}
{% if yearmonth != ym %}
{% assign yearmonth = ym %}
{% if forloop.first %}{% else %}</div>{% endif %}
<div class="tab-pane fade{% if forloop.first %} in active{% endif %}" id="aa{{ ym }}">
{% endif %}
<p>
<div class="post-preview">
<a href="{{ post.url }}" title="{{ post.title }}" >
<time datetime="{{ post.date | date_to_string }}">{{ post.date | date: "%Y-%m-%d" }}</time>
{{ post.title }}
</a>
</div>
<hr>
</p>
{% endfor %}
{% for post in site.posts %}
{% capture ym %}{{ post.date | date:"%Y%m" }}{% endcapture %}
{% if yearmonth != ym %}
{% assign yearmonth = ym %}
{% if forloop.first %}</div>{% endif %}
{% endif %}
{% endfor %}
</div>
<script>
$(function () {
var _hash = insertStr(window.location.hash,1,"a");
$('#myTab a[href="/date/'+ _hash+'"]').tab('show');
});
function insertStr(str1,n,str2){
if(str1.length<n){
return str1+str2;
}else{
s1 = str1.substring(0,n);
s2 = str1.substring(n,str1.length);
return s1+str2+s2;
}
}
</script>