Can you point to your code? I have big json data which I treat with range and sort from field inside data in the manner I write in the first post without problems.
{{ $json := getJSON "data/uchwaly.json" }}
{{ range sort $json ".data" "desc" }}
do staff....
{{ end }}
From the error, you don’t have author field in your data.Can you show example of your data?
[[references]]
id = "byron1905complete"
type = "book"
title = "The complete poetical works"
publisher = "Houghton Mifflin"
[[references.author]]
family = "Byron"
given = "George Gordon Byron Baron"
[[references.issued]]
year = "1905"
The file is called bibliography.toml located in the data folder, so that references seems to be obsolete in the template file.
The problem here is that you have map, not array. Try to save bibliograffy as array
[id1]
id = "byron1905complete"
type = "book"
title = "The complete poetical works"
publisher = "Houghton Mifflin"
family = "Byron"
given = "George Gordon Byron Baron"
year = "1905"
[id2]
...
Ok… I think is a little ugly, but it works. It will return sorted map.
Biblio data (\data\bibliography.toml)
[[references]]
id = "1"
type = "book"
title = "Book 1"
publisher = "Publisher 1"
[[references.author]]
family = "Author 3"
given = "a1"
[[references.issued]]
year = "1905"
[[references]]
id = "2"
type = "book"
title = "Book 2"
publisher = "Publisher 2"
[[references.author]]
family = "Author 1"
given = "a2"
[[references.issued]]
year = "5091"
[[references]]
id = "3"
type = "book"
title = "Book 3"
publisher = "Publisher 3"
[[references.author]]
family = "Author 2"
given = "a3"
[[references.issued]]
year = "1905"
and the code
{{$k := .Site.Data.bibliography.references}}
{{ range $i, $v := $k }}
{{- if $i -}}{{- end -}}
{{$a := slice .id .title .type .publisher}}
{{$b := .author}}
{{ range $o, $p := $b }}
{{- if $o -}}{{- end -}}
{{$c := slice .family .given}}
{{$d := union $a $c}}
{{$d0 := index $d 0}}
{{$d1 := index $d 1}}
{{$d2 := index $d 2}}
{{$d3 := index $d 3}}
{{$d4 := index $d 4}}
{{$d5 := index $d 5}}
{{$.Scratch.SetInMap "biblio" $d4 (dict "id" $d0 "type" $d1 "family" $d4) }}
{{end}}
{{end}}
{{$.Scratch.GetSortedMapValues "biblio"}}
The clue is to range twice, build a two slice, marge it, and used $.Scratch.SetInMap and $.Scratch.GetSortedMapValues to get the map sorted. All later taken randomly, sort are made with value of $d4.
Wow! That is gorgeous. I could not have solved it that way.
Thank you very, very much for your effort!
Inline Frontmatter can be sorted directly by a secondary field, Frontmatter from the data folder can’t. Maybe, it makes sense to add a pull request to GitHub for this.