Skip to content

Commit 8f1e14a

Browse files
committed
set random_posts
1 parent e102cd5 commit 8f1e14a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ content_position: widget
3838
# true目录将会浮动固定位置,false则相反,当且仅当content_position=widget时该设置值有效
3939
content_display_fixed: true
4040

41-
# 文章底部推荐文章,false关闭
42-
random_posts: true
41+
# 文章底部推荐文章数,false关闭
42+
random_posts: 4
4343

4444
widgets:
4545
- social

layout/_partial/random_posts.ejs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
<h2><%= __('random_posts') %></h2>
44
<div>
55
<ul>
6+
<% var random_posts = theme.random_posts %>
67
<% arr = site.posts.slice(); %>
7-
<% for (var i, tmp, n = arr.length; n; i = Math.floor(Math.random() * n), tmp = arr[--n], arr[n] = arr[i], arr[i] = tmp); %>
8-
<% arr = arr.slice(0,6);%>
8+
<% for (var i, tmp, n = arr.length; n; i = Math.floor(Math.random() * n), tmp = arr[--n], arr[n] = arr[i], arr[i] = tmp); %>
9+
<% arr = arr.slice(0,random_posts);%>
910
<% arr.each(function(post){ %>
1011
<li>
1112
<strong><%= date(post.date, 'YYYY.MM.DD')%>:&nbsp;&nbsp;<a href="<%- url_for(post.path) %>"><%= post.title || '(no title)' %></a></strong>

0 commit comments

Comments
 (0)