Sorting page collections by first element of a front matter slice

Hi Greg,

I’m having exactly the same problem that you described in your closed pull request, so I wonder how you managed?


Build a slice of maps, where each map has two key/val pairs, then sort the slice of maps.

{{ $p := slice }}
{{ range where site.RegularPages "Section" "posts" }}
  {{ $m := dict "firstTag" (index .Params.tags 0) "page" . }}
  {{ $p = $p | append $m }}
{{ end }}

{{ range sort $p "firstTag" "asc" }}
  <h2><a href="{{ .page.RelPermalink }}">{{ .page.LinkTitle }}</a></h2>
{{ end }}

Thank you very much, it works perfectly :pray:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.