forked from iEverX/ieverx.github.com_bk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
133 lines (124 loc) · 4.97 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
layout: default
title: 天外天
tagline: 天外有天,山外有山
role: index
---
<div class="posts">
{% assign post = site.posts.first %}
<section class="post-glance">
<header class="post-header">
<h2 class="post-title"><a href="{{ post.url | prepand: site.baseurl }}">{{ post.title }}</a></h2>
<div class="post-meta">
<span>
<i class="fa fa-calendar"></i> {{ post.date | date: '%Y-%m-%d' }}
</span>
{% if post.tags != empty %}
<span>
<i class="fa fa-tags"></i> {% for tag in post.tags %}<a class="tag" href="{{ site.tags_path | prepend: site.baseurl }}#{{ tag }}" rel="nofollow">{{ tag }}</a> {% endfor %}
</span>
{% endif %}
</div>
</header>
<div class="post-content">
{{ post.content }}
</div>
</section>
<div class="post-extra">
<a href="{{ BASE_PATH }}{{ post.url }}#ds-comment">添加/查看评论</a>
</div>
<!-- <div class="divider divider-dashed"></div> -->
{% assign post = nil %}
</div>
<script type="text/javascript">
var posts = [
{% for post in site.posts offset:1 %}
{
title: '{{ post.title }}',
url: '{{ BASE_PATH }}{{ post.url }}',
meta: {
tags: [
{% for tag in post.tags %}
{
tag: '{{ tag }}',
url: '{{ site.tags_path | prepand: site.baseurl }}#{{ tag }}',
},
{% endfor %}
],
author: '{{ site.author.name }}',
date: '{{ post.date | date: "%Y-%m-%d" }}'
{% if post.math %}
,
math: true
{% endif %}
{% if post.lang %}
,
lang: [
{% for lang in post.lang %}
'{{ lang }}',
{% endfor %}
]
{% endif %}
}
},
{% endfor %}
];
function putPost(post) {
if (post.meta.math) {
(function() {
var m = document.createElement('script');
m.src = '//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(m, s);
})();
}
var $postTitle = $('<h2 class="post-title"><a href="' + post.url + '">' + post.title + '</a></h2>');
var tags = post.meta.tags.reduce(function(p, c) {
return p + '<a class="tag" href="' + c.url + '">' + c.tag + '</a> ';
}, '');
var spand = $('<span></span>').html('<i class="fa fa-calendar"></i> ' + post.meta.date);
var spant = $('<span></span>').html('<i class="fa fa-tags"></i> ' + tags);
var $meta = $('<div class="post-meta"></div>').append(spand).append(spant);
var $postHeader = $('<header class="post-header"></header>').append($postTitle).append($meta);
var $postContent = $('<div class="post-content"></div>');
var $post = $('<section class="post-glance"></section>').append($postHeader).append($postContent);
var $postExtra = $('<div class="post-extra"></div>').append($('<a href="' + post.url + '#ds-comment">添加/查看评论</a>'));
$('.posts').append($post).append($postExtra);
$postContent.load(post.url + ' ' + '.post-content', function(res) {
var children = $(res).find('.post-content').children();
$postContent.html('').append(children);
});
}
$(function() {
var c = +new Date();
function checkAndAdd() {
if ($(window).scrollTop() + $(window).height() > $(document).height() - 50 && posts.length > 0) {
var post = posts.shift();
putPost(post);
}
}
function throttle(func, wait) {
var timeout = null;
var previous = 0;
return function() {
var now = +new Date();
var remaining = wait - (now - previous);
if (remaining <= 0) {
clearTimeout(timeout);
timeout = null;
previous = now;
func();
} else if (!timeout) {
timeout = setTimeout(function() {
previous = now;
timeout = null;
func();
}, remaining);
}
}
}
checkAndAdd();
$(window).scroll(throttle(checkAndAdd, 100));
$(window).resize(throttle(checkAndAdd, 100));
});
</script>