-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.html
51 lines (51 loc) · 1.64 KB
/
post.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
<div class="progress-bar"></div>
<div class="wrapper blog-wrapper content-wrapper">
<div class="article">
<div class="article-head">
<div class="article-title">
{{ post.title }}
</div>
<div class="article-info">
{{ post.date }} |
<span class="categories">
{% for cat in post.cats %}
<a href="{{ cat.url }}" title="{{ cat.name }}"> {{ cat.name }} </a>
{% /for %}
</span>
</div>
</div>
<div class="article-main">
{{ post.content }}
<div class="row">
<span class="text-left">
{% if postNav.prev %}
<a href="{{ postNav.prev.url }}">« {{ postNav.prev.title }}</a>
{% /if %}
</span>
<span class="text-right">
{% if postNav.next %}
<a href="{{ postNav.next.url }}">« {{ postNav.next.title }}</a>
{% /if %}
</span>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('scroll', function (e) {
var wrapper = document.querySelector('.blog-wrapper');
var article = document.querySelector('.article');
var docHeight = wrapper.offsetHeight;
var maxHeight = docHeight - window.innerHeight - article.offsetTop;
var scrollTop = window.scrollY || window.scollTop || document.getElementsByTagName("html")[0].scrollTop;
var ratio = scrollTop / maxHeight;
var progressBar = document.querySelector('.progress-bar');
var winWidth = window.innerWidth;
if (ratio <= 1.0) {
progressBar.style.width = winWidth * ratio + 'px';
}
else {
progressBar.style.width = winWidth + 'px';
}
});
</script>