From: Bjørn Erik Pedersen Date: Thu, 20 Feb 2020 13:03:56 +0000 (+0100) Subject: hugolib: Fix 2 Paginator.Pages taxonomy regressions X-Git-Tag: v0.65.1~3 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7ef5a4c83e4560bced3eee0ccf0e0db176146f44;p=brevno-suite%2Fhugo hugolib: Fix 2 Paginator.Pages taxonomy regressions Fixes #6921 Fixes #6918 --- diff --git a/hugolib/page__paginator.go b/hugolib/page__paginator.go index 640a88c4..942597e0 100644 --- a/hugolib/page__paginator.go +++ b/hugolib/page__paginator.go @@ -82,14 +82,19 @@ func (p *pagePaginator) Paginator(options ...interface{}) (*page.Pager, error) { pd.Type = p.source.outputFormat() var pages page.Pages - if p.source.IsHome() { + + switch p.source.Kind() { + case page.KindHome: // From Hugo 0.57 we made home.Pages() work like any other // section. To avoid the default paginators for the home page // changing in the wild, we make this a special case. pages = p.source.s.RegularPages() - } else { + case page.KindTaxonomy, page.KindTaxonomyTerm: + pages = p.source.Pages() + default: pages = p.source.RegularPages() } + paginator, err := page.Paginate(pd, pages, pagerSize) if err != nil { initErr = err diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go index 913773da..0e2f0d83 100644 --- a/hugolib/taxonomy_test.go +++ b/hugolib/taxonomy_test.go @@ -577,6 +577,9 @@ Cats Pages: {{ range $cats.Pages}}{{.RelPermalink }}|{{ end }}:END P1 Terms: {{ range $p1.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Section Terms: {{ range $section.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Home Terms: {{ range $home.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END +Category Paginator {{ range $categories.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END +Cats Paginator {{ range $cats.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END + `) b.Build(BuildCfg{}) @@ -591,12 +594,14 @@ Home Terms: {{ range $home.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}: b.Assert(funny.Parent(), qt.Equals, cat) b.AssertFileContent("public/index.html", ` - Categories Pages: /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END - Funny Pages: /section/p1/|/section/p2/|:END - Cats Pages: /section/p1/|/section/|:END - P1 Terms: /categories/cats/|/categories/funny/|:END - Section Terms: /categories/birds/|/categories/cats/|/categories/dogs/|:END - Home Terms: /categories/dogs/|/categories/gorillas/|:END +Categories Pages: /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END +Funny Pages: /section/p1/|/section/p2/|:END +Cats Pages: /section/p1/|/section/|:END +P1 Terms: /categories/cats/|/categories/funny/|:END +Section Terms: /categories/birds/|/categories/cats/|/categories/dogs/|:END +Home Terms: /categories/dogs/|/categories/gorillas/|:END +Cats Paginator /section/p1/|/section/|:END +Category Paginator /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END `) b.AssertFileContent("public/categories/funny/index.xml", `http://example.com/section/p1/`)