jirib
September 25, 2020, 12:04am
1
Hi,
I’d like to achive this list in a section template (I have ‘date’ (date is not year but 2006-01-01 format) and ‘author’ in front matter).
The problem is I have no idea how to do complex query. If I would NOT want to group pages by author, I would use GroupByDate but here I’m lost.
You can nest your range
statements, so something like
<ul>
{{ range $pages.GroupByDate "2006" }}
<li>
{{ .Key }}
<ul>
{{ range .Pages.GroupByParam "author" }}
<li>{{ .Title }}</li>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
jirib
September 25, 2020, 8:41am
3
Thanks a lot. The 2006
is format specification for date or is that a parameter for GroupByDate
“filter”? If the latter, can I get all years dynamically?
That’s the date format, so this tells it to group by year. Each iteration will be the list of pages for that year.
An easy readable documentation of Golang’s weird date formatting is here:
I always wondered what the history is behind this numbered way, never saw it in another programming language.