diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-06-09 12:50:53 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-06-10 08:32:44 +0200 |
commit | e8a716b23a1ca78cf29460daacd4ba49bbc05ad1 (patch) | |
tree | a55a3ade6ca19306b3ebbae6cbafd2aefaa4c880 /hugolib/paginator_test.go | |
parent | 3e6cb2cb77e16be5b6ddd4ae55d5fc6bfba2d226 (diff) | |
download | hugo-e8a716b23a1ca78cf29460daacd4ba49bbc05ad1.tar.gz hugo-e8a716b23a1ca78cf29460daacd4ba49bbc05ad1.zip |
tpl/collections: Fix slice type handling in sort
The `sort` template func was producing a `[]page.Page` which did not work in `.Paginate`.
Fixes #6023
Diffstat (limited to 'hugolib/paginator_test.go')
-rw-r--r-- | hugolib/paginator_test.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hugolib/paginator_test.go b/hugolib/paginator_test.go index d98ec30e9..a97a59d04 100644 --- a/hugolib/paginator_test.go +++ b/hugolib/paginator_test.go @@ -15,6 +15,7 @@ package hugolib import ( "fmt" + "path/filepath" "testing" ) @@ -96,3 +97,11 @@ URL: {{ $pag.URL }} "0: 1/1 true") } + +// Issue 6023 +func TestPaginateWithSort(t *testing.T) { + b := newTestSitesBuilder(t).WithSimpleConfigFile() + b.WithTemplatesAdded("index.html", `{{ range (.Paginate (sort .Site.RegularPages ".File.Filename" "desc")).Pages }}|{{ .File.Filename }}{{ end }}`) + b.Build(BuildCfg{}).AssertFileContent("public/index.html", + filepath.FromSlash("|content/sect/doc1.nn.md|content/sect/doc1.nb.md|content/sect/doc1.fr.md|content/sect/doc1.en.md")) +} |