Skip to content

Commit

Permalink
start adding editors to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Oct 8, 2024
1 parent 7c8be7b commit 60c7c2d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions themes/ropensci/layouts/blog/list.json.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,28 @@
{{ $data.Set "authors" .Params.author }}
{{ else }}
{{ $data.Set "authors" (slice .Params.author) }}
{{ end }}
{{ if eq (substr (jsonify .Params.editor) 0 1) "[" }}
{{ $data.Set "editors" .Params.editor }}
{{ else }}
{{ $data.Set "editors" (slice .Params.editor) }}
{{ end }}
{
"id": "{{ .Permalink }}",
"title": "{{ .Title }}",
"language" : "{{ .Lang }}",
"authors": [{{ range $i, $e := ($data.Get "authors") }}{{ range first 1 (where ($data.Get "pages") ".Params.name" $e) }}{{ $params := .Params }}{{ $name := $params.name }}{{ if $i }}, {{ end }}{{ range first 1 (where ($data.Get "pages") ".Params.name" $e) }}
"authors": [{{ $editors := ($data.Get "editors") }}{{ if gt (len $editors) 0 }}{{ range $i, $e := ($data.Get "editors") }}{{ range first 1 (where ($data.Get "pages") ".Params.name" $e) }}{{ $params := .Params }}{{ $name := $params.name }}{{ range first 1 (where ($data.Get "pages") ".Params.name" $e) }}
{
"name": "{{ $name }}",
"url": "{{ if isset .Params "orcid" }}https://orcid.org/{{ .Params.orcid }}{{ else }}{{ .Permalink }}{{ end }}",
"avatar": "{{ ( partial "blogs/author-img" . ) }}",
"_role": "editor"
},{{ end }}{{ end }}{{ end }}{{ end }}{{ range $i, $e := ($data.Get "authors") }}{{ range first 1 (where ($data.Get "pages") ".Params.name" $e) }}{{ $params := .Params }}{{ $name := $params.name }}{{ if $i }}, {{ end }}{{ range first 1 (where ($data.Get "pages") ".Params.name" $e) }}
{
"name": "{{ $name }}",
"url": "{{ if isset .Params "orcid" }}https://orcid.org/{{ .Params.orcid }}{{ else }}{{ .Permalink }}{{ end }}",
"avatar": "{{ ( partial "blogs/author-img" . ) }}"
"avatar": "{{ ( partial "blogs/author-img" . ) }}",
"_role": "author"
}{{ end }}{{ end }}{{ end }}],
{{ with .Params.tags }} "tags": {{ . | uniq | jsonify}},{{ end }}
"content_html": {{ .Content | replaceRE "\n" "" | jsonify }},
Expand Down

0 comments on commit 60c7c2d

Please sign in to comment.