Trying to order a list of page resources

Hey! That looks like it’s working.

It took some fun experimentation to figure out what the things should be, so for completeness sake, here’s my solution:

  {{ range sort (.Resources.ByType "page") "Params.weight" }}
    {{ .Render "listing" }}
  {{ end }}

And an example of the frontmatter for the resources:

---
title: "Google"
date: 2018-03-31T12:25:14+11:00
draft: false
weight: 5
params:
  url: "https://google.com/"
---

Confusingly, to access params for a resource it’s actually .Params.params.foo instead of .Params.foo, hence the ability to directly access weight in the sort field.

4 Likes