Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collections.Sort looses slice type info (which makes it fail in .Paginate) #6023

Closed
gbmhunter opened this issue Jun 9, 2019 · 1 comment

Comments

@gbmhunter
Copy link

commented Jun 9, 2019

I use the paginator in the following fashion:

{{ range (.Paginate (first 20 ( sort (where .Site.RegularPages "Section" "posts") "Date" "desc" )) 5 ).Pages }}
   <do stuff here>
{{ end }}

This worked fine in v0.54. However, upon upgrading to v0.56.6 (this includes the paginator bug fix), I get the following error when trying to either run the server or perform a build:

Error: Error building site: failed to render pages: render of "home" failed: "C:\Users\gbmhu\code\blog\layouts\index.html:11:14": execute of template failed: template: index.html:11:14: executing "main" at <.Paginate>: error calling Paginate: cannot convert type []page.Page to Pages

I am running hugo on Windows 10, installed by chocolaty. The repo that contains the code which causes the crash can be found at https://github.com/gbmhunter/blog (trying to run that with v0.55.6 should cause the exact same error above).

I even tried simplifying the paginator to what is specified in the tutorial, i.e.:

{{ $paginator := .Paginate (where .Pages "Type" "posts") }}
{{ template "_internal/pagination.html" . }}
{{ range $paginator.Pages }}
   {{ .Title }}
{{ end }}

The crash still occurred.

@bep bep added this to the v0.56 milestone Jun 9, 2019

@bep bep added Bug and removed NeedsInvestigation labels Jun 9, 2019

@bep bep changed the title `.Paginate` that worked in 0.54 crashes in 0.55.6 (even with the paginator bug fix). .Paginate fails when it gets []page.Page Jun 9, 2019

@bep bep changed the title .Paginate fails when it gets []page.Page collections.Sort looses slice type info (which makes it fail in .Paginate) Jun 9, 2019

bep added a commit to bep/hugo that referenced this issue Jun 9, 2019

tpl/collections: Fix slice type handling in sort
The `sort` template func was producing a `[]page.Page` which did not work in `.Paginate`.

Fixes gohugoio#6023

bep added a commit to bep/hugo that referenced this issue Jun 9, 2019

tpl/collections: Fix slice type handling in sort
The `sort` template func was producing a `[]page.Page` which did not work in `.Paginate`.

Fixes gohugoio#6023
@gbmhunter

This comment has been minimized.

Copy link
Author

commented Jun 10, 2019

Thanks for the investigation and fix for v0.56!

@bep bep closed this in #6024 Jun 10, 2019

bep added a commit that referenced this issue Jun 10, 2019

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

hackingjack pushed a commit to hackingjack/capsule that referenced this issue Jul 17, 2019

Jon
sorting is working in early state #8
working commit

mutch work because of a hugo bug

    gohugoio/hugo#6023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.