-
Notifications
You must be signed in to change notification settings - Fork 19
/
page-archives-post.hbs
71 lines (70 loc) · 2.96 KB
/
page-archives-post.hbs
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
{{!< default}}
<div class="row page pages">
<div class="slidenav">
{{> aside}}
<div class="closeslide"></div>
</div>
<main>
<nav>
<header class="nav-wrapper blue-grey">
<div>
<a id="show-slide-nav"><i class="fa fa-bars fa-lg"></i></a>
<p>
<span class="header-title">{{@blog.title}}</span>
</p>
<span></span>
</div>
</header>
</nav>
<div class="contents content-in about">
{{#post}}
<article>
<div style="text-align:center"><h4 class="archives-title">Archives</h4></div>
<article class="archives"></article>
</article>
<div class="noborderfooter" style="margin-top:50px;">
{{> footer}}
</div>
</div>
</main>
</div>
{{/post}}
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script src="//cdn.bootcss.com/moment.js/2.14.1/moment.min.js"></script>
<script type = "text/javascript">
jQuery(document).ready(function() {
$.get(ghost.url.api('posts', {
fields: "title,slug,published_at",
limit: 'all',
order: "published_at desc"
})).done(function(data) {
var posts = data.posts;
var count = posts.length;
for (var i = 0; i < count; i++) {
var time = moment(posts[i].published_at).utcOffset("-06:00");
var year = time.get('y');
var month = time.get('M') + 1;
if (month < 10) month = "0" + month;
var date = time.get('D');
if (date < 10) date = "0" + date;
var title = posts[i].title;
var url = "https://www.ldsun.com/" + posts[i].slug;
if (i > 0) {
var pre_month = moment(posts[i - 1].published_at).utcOffset("-08:00").get('month') + 1;
if (month == pre_month) {
var html = "<li><time>" + date + "日</time><a href='" + url + "'>" + title + "</a></li>";
$(html).appendTo(".archives .list-" + year + "-" + month)
} else {
var html = "<div class='item'><h3><i class='fa fa-calendar fa-fw' aria-hidden='true'></i> " + year + "-" + month + "</h3><ul class='archives-list list-" + year + "-" + month + "'><li><time>" + date + "日</time><a href='" + url + "'>" + title + "</a></li></ul></div>";
$(html).appendTo('.archives')
}
} else {
var html = "<div class='item'><h3><i class='fa fa-calendar fa-fw' aria-hidden='true'></i> " + year + "-" + month + "</h3><ul class='archives-list list-" + year + "-" + month + "'><li><time>" + date + "日</time><a href='" + url + "'>" + title + "</a></li></ul></div>";
$(html).appendTo('.archives')
}
}
}).fail(function(err) {
console.log(err)
})
});
</script>