From d214834089ca140ad1c4ffd9793e8af3d3d6bbec Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Wed, 7 Sep 2016 23:54:55 +0300 Subject: [PATCH] Allow configuration of recent posts on sidebar By default it shows the latest five posts, but you can set this property in your config to override it: [params.sidebar] num_recent_posts = 7 Still no way to disable it, as I don't understand golang's HTML templating stuff yet. The Hugo docs are a bit confusing, but it seems like conditionals are a bit tricky because both false and 0 return a boolean false... hmm. See: https://gohugo.io/templates/go-templates/ --- layouts/partials/sidebar.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 435517b..454bf67 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -6,16 +6,16 @@ {{ end }} - {{ if isset .Site.Params.sidebar "num_recent_posts" }} + {{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }} + - {{ end }}