Skip to content

Commit 716bb88

Browse files
authored
Merge pull request #533 from cirry/master
fix: #520,#223,修复首页文章展示异常
2 parents 02c098f + 5fe213d commit 716bb88

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

_config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ copycode: true ## If you want to enable one-click copy of the code blocks, set t
9797
dark: false ## If you want to toggle between light/dark themes, set the value to true.
9898
totop: true ## If you want to use the rocketship button to return to the top, set the value to true.
9999
external_css: false ## If you want to load an external CSS file, set the value to true and create a file named "external.css" in the source/css folder.
100+
post_content_length: 180 ## Set the length of characters displayed on the home page
100101

101102
menu:
102103
- page: home

layout/index.pug

+7-16
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ block content
1111
.post
1212
h1.post-title
1313
if post.sticky
14-
span(class="top-post")= __('Sticky')
14+
span(class="top-post")= __('Sticky')
1515
include _partial/helpers.pug
1616
a(href=url_for(post.path))
1717
+title(post)
@@ -29,20 +29,11 @@ block content
2929
.post-content
3030
!= post.excerpt
3131
else if post.content
32-
- var br = 0
33-
- for (var i = 0; i < 5; ++i) {
34-
- br = post.content.indexOf('\n',br+1)
35-
if br<0
36-
- break
37-
if br >150
38-
- break
39-
- }
40-
if br < 0
41-
.post-content
42-
!= post.content
43-
else
44-
.post-content
45-
!= post.content.substring(0, br)
32+
- const content = strip_html(post.content)
33+
- let expert = content.substring(0,theme.post_content_length)
34+
- content.length > theme.post_content_length ? expert += '...' : ''
35+
.post-content
36+
!= expert
4637
p.readmore
4738
a(href=url_for(post.path))= __('Readmore')
4839

@@ -54,4 +45,4 @@ block content
5445
if config.mathjax
5546
include _partial/mathjax.pug
5647
if config.mathjax2
57-
include _partial/mathjax2.pug
48+
include _partial/mathjax2.pug

0 commit comments

Comments
 (0)