From 1655b876a8f7cf3c4b9d3a2006e645ffb2504977 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Fri, 9 Mar 2018 17:50:03 +0200 Subject: [PATCH] Use .Site.Params.mainSections instead of hard coding "post" type Hugo 0.32 or so added the quasi-magical .Site.Params.mainSections slice that returns a range over the section that has the most number of pages. This way we don't need to hard code the "post" type, and instead simply use the pages that the user has created. Hugo's quickstart, for example, recommends users create "posts", which currently doesn't work with this theme! Closes #89 --- layouts/_default/baseof.html | 7 ------- layouts/_default/list.html | 2 +- layouts/partials/recent.html | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index e35e981..d510434 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -37,17 +37,10 @@ diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 351f729..d287dd9 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -30,7 +30,7 @@ {{ define "main" }} {{ $truncate := default true .Site.Params.truncate }} -{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }} +{{ $paginator := .Paginate (where .Site.Pages "Section" "in" .Site.Params.mainSections) }} {{ range $paginator.Pages }} {{ if $truncate }} {{ .Render "summary" }} diff --git a/layouts/partials/recent.html b/layouts/partials/recent.html index 3136837..5cc7f67 100644 --- a/layouts/partials/recent.html +++ b/layouts/partials/recent.html @@ -2,7 +2,7 @@

{{ i18n "recentPosts" }}

    {{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }} -{{ range first $num_recent_posts (where .Site.RegularPages "Type" "post") }} +{{ range first $num_recent_posts (where .Site.Pages "Section" "in" .Site.Params.mainSections) }}
  1. {{.Title | markdownify }}
  2. {{ end }}