I need to combine GroupByDate and Type. ‘Where’ seems to have no effect when combined with GroupByDate:
{{ range $index, $value := (.Site.Pages.GroupByDate “January 2006” ) (where .Site.Pages “Type” “post”) }}
Context: I am building a collapsible list where posts are grouped by date. Everything is working fine except I am getting dates with no posts (because it’s currently iterating over all content. If this is narrowed down to Type=post then in theory my problem will be solved.
<!-- accordion start -->
<div class="panel-group" id="accordion1">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion1" href="#collapseTwo">
Archive</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<!-- Here we insert another nested accordion -->
<div class="panel-group" id="accordion2">
{{ range $index, $value := (.Site.Pages.GroupByDate "January 2006" ) (where .Site.Pages "Type" "post") }}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a data-toggle="collapse" data-parent="#post-month-{{$index}}" href="#post-month-{{$index}}">
{{ .Key }}
</a></h4>
</div>
<div id="post-month-{{$index}}" class="panel-collapse collapse">
<div class="panel-body">
{{ range $element := (where .Pages "Type" "post") }}
{{ if ne . $ }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}
</div>
<!-- Inner accordion ends here -->
</div>
</div>
</div>
</div>
<!-- accordion end -->