]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix taxonomy weight sort regression
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 1 Nov 2022 16:15:04 +0000 (17:15 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 1 Nov 2022 17:45:34 +0000 (18:45 +0100)
Fixes #10406

hugolib/page.go
hugolib/taxonomy_test.go

index 9f0d08ca3510d7d34837137558f74ff6ddf1d2c9..ec7b8227771ff332d43587e26b944e1a548d5d66 100644 (file)
@@ -268,7 +268,10 @@ func (p *pageState) Pages() page.Pages {
                case page.KindSection, page.KindHome:
                        pages = p.getPagesAndSections()
                case page.KindTerm:
-                       pages = p.bucket.getTaxonomyEntries()
+                       b := p.treeRef.n
+                       viewInfo := b.viewInfo
+                       taxonomy := p.s.Taxonomies()[viewInfo.name.plural].Get(viewInfo.termKey)
+                       pages = taxonomy.Pages()
                case page.KindTaxonomy:
                        pages = p.bucket.getTaxonomies()
                default:
index b2603217402f05fa671e76bb8314600d8add0003..b6b696ed3bd738d8e5e933c20b85805063a78896 100644 (file)
@@ -60,7 +60,6 @@ YAML frontmatter with tags and categories taxonomy.`
        }
 }
 
-//
 func TestTaxonomiesWithAndWithoutContentFile(t *testing.T) {
        for _, uglyURLs := range []bool{false, true} {
                uglyURLs := uglyURLs
@@ -521,7 +520,7 @@ Funny:|/p1/|
 Funny:|/p2/|`)
 }
 
-//https://github.com/gohugoio/hugo/issues/6590
+// https://github.com/gohugoio/hugo/issues/6590
 func TestTaxonomiesListPages(t *testing.T) {
        b := newTestSitesBuilder(t)
        b.WithTemplates("_default/list.html", `
@@ -694,3 +693,42 @@ abcdefgs: {{ template "print-page" $abcdefgs }}|IsAncestor: {{ $abcdefgs.IsAnces
     abcdefgs: /abcdefgs/|Abcdefgs|taxonomy|Parent: /|CurrentSection: /|FirstSection: /|IsAncestor: true|IsDescendant: false
 `)
 }
+
+func TestTaxonomiesWeightSort(t *testing.T) {
+
+       files := `
+-- layouts/index.html --
+{{ $a := site.GetPage "tags/a"}}
+:{{ range $a.Pages }}{{ .RelPermalink }}|{{ end }}:
+-- content/p1.md --
+---
+title: P1
+weight: 100
+tags: ['a']
+tags_weight: 20
+---
+-- content/p3.md --
+---
+title: P2
+weight: 200
+tags: ['a']
+tags_weight: 30
+---
+-- content/p2.md --
+---
+title: P3
+weight: 50
+tags: ['a']
+tags_weight: 40
+---
+       `
+
+       b := NewIntegrationTestBuilder(
+               IntegrationTestConfig{
+                       T:           t,
+                       TxtarString: files,
+               },
+       ).Build()
+
+       b.AssertFileContent("public/index.html", `:/p1/|/p3/|/p2/|:`)
+}