hugolib: Fix 2 Paginator.Pages taxonomy regressions
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 20 Feb 2020 13:03:56 +0000 (14:03 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 20 Feb 2020 13:13:04 +0000 (14:13 +0100)
Fixes #6921
Fixes #6918

hugolib/page__paginator.go
hugolib/taxonomy_test.go

index 640a88c4784c3e06dbd632fd53c723a2750803b0..942597e04e6f5b74a5fda654298fb142a6fc1e28 100644 (file)
@@ -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
index 913773da6a8999124efa9a65e9f775651570a484..0e2f0d83d5d16e853dba8e7ff259d740e7255b17 100644 (file)
@@ -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", `<link>http://example.com/section/p1/</link>`)