hugolib: Fix 2 Paginator.Pages taxonomy regressions

Fixes #6921
Fixes #6918
This commit is contained in:
Bjørn Erik Pedersen 2020-02-20 14:03:56 +01:00
parent a70bbd0696
commit 7ef5a4c83e
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 18 additions and 8 deletions

View file

@ -82,14 +82,19 @@ func (p *pagePaginator) Paginator(options ...interface{}) (*page.Pager, error) {
pd.Type = p.source.outputFormat() pd.Type = p.source.outputFormat()
var pages page.Pages 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 // From Hugo 0.57 we made home.Pages() work like any other
// section. To avoid the default paginators for the home page // section. To avoid the default paginators for the home page
// changing in the wild, we make this a special case. // changing in the wild, we make this a special case.
pages = p.source.s.RegularPages() pages = p.source.s.RegularPages()
} else { case page.KindTaxonomy, page.KindTaxonomyTerm:
pages = p.source.Pages()
default:
pages = p.source.RegularPages() pages = p.source.RegularPages()
} }
paginator, err := page.Paginate(pd, pages, pagerSize) paginator, err := page.Paginate(pd, pages, pagerSize)
if err != nil { if err != nil {
initErr = err initErr = err

View file

@ -577,6 +577,9 @@ Cats Pages: {{ range $cats.Pages}}{{.RelPermalink }}|{{ end }}:END
P1 Terms: {{ range $p1.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END P1 Terms: {{ range $p1.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END
Section Terms: {{ range $section.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Section Terms: {{ range $section.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END
Home Terms: {{ range $home.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{}) b.Build(BuildCfg{})
@ -591,12 +594,14 @@ Home Terms: {{ range $home.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:
b.Assert(funny.Parent(), qt.Equals, cat) b.Assert(funny.Parent(), qt.Equals, cat)
b.AssertFileContent("public/index.html", ` b.AssertFileContent("public/index.html", `
Categories Pages: /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END Categories Pages: /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END
Funny Pages: /section/p1/|/section/p2/|:END Funny Pages: /section/p1/|/section/p2/|:END
Cats Pages: /section/p1/|/section/|:END Cats Pages: /section/p1/|/section/|:END
P1 Terms: /categories/cats/|/categories/funny/|:END P1 Terms: /categories/cats/|/categories/funny/|:END
Section Terms: /categories/birds/|/categories/cats/|/categories/dogs/|:END Section Terms: /categories/birds/|/categories/cats/|/categories/dogs/|:END
Home Terms: /categories/dogs/|/categories/gorillas/|: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", `<link>http://example.com/section/p1/</link>`) b.AssertFileContent("public/categories/funny/index.xml", `<link>http://example.com/section/p1/</link>`)