From 6d98c1513660503c12b0ed183324aadf1cccdf5e Mon Sep 17 00:00:00 2001 From: donfiguerres Date: Sat, 14 Aug 2021 18:00:35 +0800 Subject: [PATCH] Configure the number of posts in recent posts (#395) * Add configuration to number of recent posts. * Added default value. Co-authored-by: donfiguerres --- layouts/partials/sections/recent-posts.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/layouts/partials/sections/recent-posts.html b/layouts/partials/sections/recent-posts.html index 937bdff..9491977 100644 --- a/layouts/partials/sections/recent-posts.html +++ b/layouts/partials/sections/recent-posts.html @@ -3,13 +3,19 @@ {{ $sectionID = .section.id }} {{ end }} +{{ $numShow := 3}} +{{ if .section.numShow }} + {{ $numShow = .section.numShow }} +{{ end }} + +
{{ if not (.section.hideTitle) }}

{{ .section.name }}

{{ end }}
- {{ 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 }}