From d1259149c87f8bc569476d4b04f21d76eda5e5ad Mon Sep 17 00:00:00 2001 From: Roberto MF Date: Sat, 28 Sep 2019 20:52:50 +0200 Subject: [PATCH] Hugo: fix home.Pages breaking change in v0.57.0 Changelog for v0.57.0: https://github.com/gohugoio/hugo/releases/tag/v0.57.0 > `home.Pages` now only returns pages in the top level section. Before this release, it included _all regular pages in the site_. This made it easy to list all the pages on home page, but it also meant that you needed to take special care if you wanted to navigate the page tree from top to bottom. If you need _all regular pages_, use `.Site.RegularPages`. Also see https://github.com/gohugoio/hugo/issues/6153. > `.Pages` now include sections. We have added `.RegularPages` as a convenience method if you want the old behaviour. See https://github.com/gohugoio/hugo/issues/6171 for details. --- themes/virgulilla/layouts/_default/list.atom.xml | 6 +++++- themes/virgulilla/layouts/_default/list.html | 12 +++++------- .../virgulilla/layouts/partials/seo/opengraph.html | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/themes/virgulilla/layouts/_default/list.atom.xml b/themes/virgulilla/layouts/_default/list.atom.xml index 2e8eebd..c16296c 100644 --- a/themes/virgulilla/layouts/_default/list.atom.xml +++ b/themes/virgulilla/layouts/_default/list.atom.xml @@ -35,7 +35,11 @@ {{- end }} Hugo - {{- range first 15 (where .Data.Pages "Type" "in" .Site.Params.home.sections) }} + {{- $regularPages := .RegularPages }} + {{- if .IsHome }} + {{- $regularPages = (where .Site.RegularPages "Section" "in" .Site.Params.home.sections) }} + {{- end -}} + {{- range first 15 $regularPages }} {{ .Title | plainify }} {{- with .OutputFormats.Get "HTML" }} diff --git a/themes/virgulilla/layouts/_default/list.html b/themes/virgulilla/layouts/_default/list.html index 457e185..82945bd 100644 --- a/themes/virgulilla/layouts/_default/list.html +++ b/themes/virgulilla/layouts/_default/list.html @@ -1,15 +1,13 @@ {{ define "main" }} -{{- $var := newScratch }} -{{- if not .IsHome }} - {{- $var.Set "pages" .Pages.ByPublishDate.Reverse }} -{{- else }} - {{- $var.Set "pages" (where .Pages.ByPublishDate.Reverse "Section" "in" .Site.Params.home.sections) }} -{{- end }} +{{- $pages := .RegularPages.ByPublishDate.Reverse }} +{{- if .IsHome }} + {{- $pages = (where .Site.RegularPages.ByPublishDate.Reverse "Section" "in" .Site.Params.home.sections) }} +{{- end -}}
{{ if not .IsHome -}}

{{ .Title }}

{{- end }} - {{ range $var.Get "pages" -}} + {{ range $pages -}}
{{ .Render "li-header" }} diff --git a/themes/virgulilla/layouts/partials/seo/opengraph.html b/themes/virgulilla/layouts/partials/seo/opengraph.html index 80498e0..89917b7 100644 --- a/themes/virgulilla/layouts/partials/seo/opengraph.html +++ b/themes/virgulilla/layouts/partials/seo/opengraph.html @@ -31,7 +31,7 @@ {{- $siteSeries := .Site.Taxonomies.series }}{{ with .Params.series }} {{- range $name := . }} {{- $series := index $siteSeries $name }} - {{- range $page := first 6 $series.Pages }} + {{- range $page := first 6 $series.RegularPages }} {{- if ne $page.Permalink $permalink }}{{ end }} {{- end }} {{ end }}{{ end }}