diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-01 10:19:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-01 10:19:19 +0200 |
commit | 53077b0da54906feee64a03612e5186043e17341 (patch) | |
tree | c99b1456485cfc2ed41f3a1b732e44c4acbc3061 /hugolib | |
parent | a4f96a9d8c2d2da40796757f7e9a3023157abd2f (diff) |
Merge pull request #6149 from bep/sort-caseinsensitive
Implement lexicographically string sorting
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/menu_test.go | 4 | ||||
-rw-r--r-- | hugolib/taxonomy.go | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go index 3708173d9..0c366cafb 100644 --- a/hugolib/menu_test.go +++ b/hugolib/menu_test.go @@ -213,8 +213,8 @@ menu: "main" b.Build(BuildCfg{}) - b.AssertFileContent("public/index.html", "AMP and HTML|/blog/html-amp/|AMP only|/amp/blog/amp/|HTML only|/blog/html/|Home Sweet Home|/|") - b.AssertFileContent("public/amp/index.html", "AMP and HTML|/amp/blog/html-amp/|AMP only|/amp/blog/amp/|HTML only|/blog/html/|Home Sweet Home|/amp/|") + b.AssertFileContent("public/index.html", "AMP and HTML|/blog/html-amp/|AMP only|/amp/blog/amp/|Home Sweet Home|/|HTML only|/blog/html/|") + b.AssertFileContent("public/amp/index.html", "AMP and HTML|/amp/blog/html-amp/|AMP only|/amp/blog/amp/|Home Sweet Home|/amp/|HTML only|/blog/html/|") } // https://github.com/gohugoio/hugo/issues/5989 diff --git a/hugolib/taxonomy.go b/hugolib/taxonomy.go index e6c80161a..a7965ec26 100644 --- a/hugolib/taxonomy.go +++ b/hugolib/taxonomy.go @@ -18,6 +18,8 @@ import ( "path" "sort" + "github.com/gohugoio/hugo/compare" + "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/resources/resource" ) @@ -73,7 +75,7 @@ func (i Taxonomy) TaxonomyArray() OrderedTaxonomy { // Alphabetical returns an ordered taxonomy sorted by key name. func (i Taxonomy) Alphabetical() OrderedTaxonomy { name := func(i1, i2 *OrderedTaxonomyEntry) bool { - return i1.Name < i2.Name + return compare.LessStrings(i1.Name, i2.Name) } ia := i.TaxonomyArray() @@ -89,7 +91,7 @@ func (i Taxonomy) ByCount() OrderedTaxonomy { li2 := len(i2.WeightedPages) if li1 == li2 { - return i1.Name < i2.Name + return compare.LessStrings(i1.Name, i2.Name) } return li1 > li2 } |