Hi,
I was looking at the Docsy theme file layouts/partials/section-index.html and I have a couple of questions:
- Can I rewrite this using range where?
{{ $pages := (where .Site.Pages "Section" .Section).ByWeight }}
{{ $parent := .Page }}
{{ range $pages }}
{{ if eq .Parent $parent }}
<li><a href="{{ .RelPermalink }}">{{- .Title -}}</a></li>
{{ end }}
{{ end }}
- Can I rewrite this in such a way the
<hr>
is only run if therange $pages
+if eq
is not empty?
{{ $pages := (where .Site.Pages "Section" .Section).ByWeight }}
{{ $parent := .Page }}
<hr class="panel-line">
{{ range $pages }}
{{ if eq .Parent $parent }}
// Show only one <hr> if this happens
{{ end }}
{{ end }}
I've tried many syntax variants, search the forums but got nowhere.
Thanks!