Given a content structure as follows:
services
├── _index.md
└── serviceA
└── index.md //headless:true, weight: 3
└── resources
└── serviceB
└── index.md //headless:true, weight: 1
└── resources
└── serviceC
└── index.md //headless:true, weight: 2
└── resources
I want to create a “layouts/services/list.html” template that can range over the headless bundles where they are sorted by a param “weight”
I can get the content to display correctly with:
{{ define "main"}}
//content from _index.md
{{ .Content}}
{{ $page := . }}
{{ range (where (readDir (print "content/" .File.Dir)) ".IsDir" true ) }}
{{ with $page.GetPage .Name }}
//content from each index.md
{{ .Content}}
{{ end }}
{{ end }}
{{end}}
However I am not sure how to pull off the sort within the range.
Is there a better way to go about this?