-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
tpl/collections: Add group template func #5187
Conversation
This completes the work started by @vdanjean -- I have put this into a template function. This is going to be useful to many. But before I pull it in, It would be cool if people agreed/disagreed about the name of the func, /cc @kaushalmodi @regisphilibert @moorereason @onedrawingperday and gang. |
Ah! This is pretty cool. I'm fine with the name. |
tpl/collections/collections.go
Outdated
@@ -30,6 +30,11 @@ import ( | |||
"github.com/spf13/cast" | |||
) | |||
|
|||
// This is currently only implemented on Page. | |||
type grouper interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface duplicates the one above. Can we consolidate these two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not without exporting them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do that, of course, but I currently don't see the value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that value may come sooner rather than later ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have added a commit where I pulled this out into its own package.
This extends the page grouping in Hugo with a template function that allows for ad-hoc grouping. A made-up example: ``` {{ $cool := where .Site.RegularPages "Params.cool" true | group "cool" }} {{ $blue := where .Site.RegularPages "Params.blue" true | group "blue" }} {{ $paginator := .Paginate (slice $cool $blue) }} ``` Closes gohugoio#4865
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This extends the page grouping in Hugo with a template function that allows for ad-hoc grouping.
A made-up example:
Closes #4865