-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
61 lines (57 loc) · 1.82 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
---
layout: default
title: Home
---
<div class="posts">
{% for post in paginator.posts %}
<div class="post">
<h1 class="post-title">
<a href="{{ post.url | absolute_url }}">
{{ post.title }}
</a>
</h1>
<span class="post-date">{{ post.date | date_to_string }}</span>
<!-- <small> -->
<!-- 显示全文 -->
<!-- {{ post.content }} -->
<!-- 显示全文前15字符,对不以空格断开字词意群的语言无效 -->
<!-- {{ post.content | strip_html | truncatewords:15 }} -->
<!-- 显示第一段 -->
<!-- {{ post.excerpt }} -->
<!-- 自定义 -->
<!-- </small> -->
<small class="post-content" id="content-{{ forloop.index }}">
{{ post.content | strip_html }}
</small>
</div>
{% endfor %}
</div>
<div class="pagination">
{% if paginator.next_page %}
<a class="pagination-item older" href="{{ paginator.next_page_path | absolute_url }}">Older</a>
{% else %}
<span class="pagination-item older">Older</span>
{% endif %}
{% if paginator.previous_page %}
{% if paginator.page == 2 %}
<a class="pagination-item newer" href="{{ '/' | absolute_url }}">Newer</a>
{% else %}
<a class="pagination-item newer" href="{{ paginator.previous_page_path | absolute_url }}">Newer</a>
{% endif %}
{% else %}
<span class="pagination-item newer">Newer</span>
{% endif %}
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
var posts = document.querySelectorAll('.post-content');
var maxLength = 200; // 设置截断长度
posts.forEach(function(post) {
var text = post.textContent;
if (text.length > maxLength) {
text = text.substring(0, maxLength) + '...';
post.textContent = text;
}
});
});
</script>