浏览代码

Configure the number of posts in recent posts (#395)

* Add configuration to number of recent posts.

* Added default value.

Co-authored-by: donfiguerres <donfiguerres@github.com>
donfiguerres 3 年之前
父节点
当前提交
6d98c15136
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      layouts/partials/sections/recent-posts.html

+ 7 - 1
layouts/partials/sections/recent-posts.html

@@ -3,13 +3,19 @@
   {{ $sectionID = .section.id }}
 {{ end }}
 
+{{ $numShow := 3}}
+{{ if .section.numShow }}
+  {{ $numShow = .section.numShow }}
+{{ end }}
+
+
 <div class="container-fluid anchor pb-5 recent-posts-section" id="{{ $sectionID }}">
   {{ if not (.section.hideTitle) }}
     <h1 class="text-center">{{ .section.name }}</h1>
   {{ end }}
   <div class="container">
     <div class="row" id="recent-post-cards">
-      {{ range first 3 (where site.RegularPages.ByDate.Reverse "Type" "in" "posts" )}}
+      {{ range first $numShow (where site.RegularPages.ByDate.Reverse "Type" "in" "posts" )}}
         {{ partial "cards/recent-post.html" . }}
       {{ end }}
     </div>