Skip to content

Commit

Permalink
start work on new Rogue Scholar API
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Oct 21, 2024
1 parent 75b7ba2 commit 07d5352
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions themes/ropensci/layouts/partials/blogs/doi.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{{ $roguescholar := (resources.GetRemote "https://api.rogue-scholar.org/blogs/ropensci") | unmarshal }}
{{ $url := (printf "https://ropensci.org%s" .RelPermalink | replaceRE "/$" "" ) }}
{{ $url := (printf "https://ropensci.org%s" .RelPermalink ) }}
{{ $apiurl := (printf "https://beta.rogue-scholar.org/api/records?q=metadata.identifiers.identifier:'%s'" $url) | replaceRE "'" "%22" }}
{{ $roguescholar := (resources.GetRemote $apiurl) | unmarshal }}
{{ $doi := "" }}

{{ with $roguescholar }}
{{ $rightpage := ( where $roguescholar.items "url" $url ) }}
{{ with $rightpage }}{{ range ( first 1 . ) }}{{ $doi = .doi }}{{ end }}{{ end }}
{{ $hits := $roguescholar.hits }}
{{ if gt $hits.total 0 }}
{{ $post := ( first 1 $hits.hits ) }}
{{ range $post }}
{{ $doi = .pids.doi.identifier }}
{{ end }}
{{ end }}
{{ end }}
{{ return $doi }}

0 comments on commit 07d5352

Please sign in to comment.