Skip to content

Commit

Permalink
dont fail on remote r-ladies blog image unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
drmowinckels committed Apr 19, 2024
1 parent 19e79fe commit 19612a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
12 changes: 12 additions & 0 deletions data/rblogs/test2.org.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"title": "Google",
"url": "https://google.com",
"photo_url": "https://assets.stickpng.com/images/580b57fcd9996e24bc43c51f.png",
"description": "",
"authors": [
{
"name": "The whole world",
"social_media": [{}]
}
]
}
6 changes: 3 additions & 3 deletions data/rblogs/testing.com.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"title": "Google",
"title": "Google test",
"url": "https://google.com",
"photo_url": "https://assets.stickpng.com/images/580b57fcd9996e24bc43c51f.png",
"photo_url": "https://assets.stickpng.com/images/580b57fcd9996e24bc4f.png",
"description": "",
"authors": [
{
"name": "The whole world",
"name": "This should have no image",
"social_media": [{}]
}
]
Expand Down
14 changes: 9 additions & 5 deletions themes/hugo-rladies/layouts/rladies-blogs/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@
{{ $grav := ( md5 $rb.url ) }}
{{ $data.Set "photo" (printf "https://www.gravatar.com/avatar/%s?s=100&d=identicon" $grav )}}
{{ with $rb.photo_url }}
{{ $image := resources.GetRemote . }}
{{ with $image }}
{{ $img := . }}
{{ $img := $img.Fill "300x300" }}
{{ $data.Set "photo" $img.RelPermalink }}
{{ with resources.GetRemote . }}
{{ with .Err }}
{{ else }}
{{ $img := . }}
{{ $img := $img.Fill "300x300" }}
{{ $data.Set "photo" $img.RelPermalink }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" . }}
{{ end }}
{{ end }}

Expand Down

0 comments on commit 19612a2

Please sign in to comment.