Skip to content

Commit

Permalink
dont fail on remote r-ladies blog image unavailable (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
drmowinckels authored Apr 19, 2024
1 parent 19e79fe commit 8480ee5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 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
18 changes: 11 additions & 7 deletions themes/hugo-rladies/layouts/rladies-blogs/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
{{ end }}
{{ $descr := $data.Get "descr" }}

{{ $grav := ( md5 $rb.url ) }}
{{ $data.Set "photo" (printf "https://www.gravatar.com/avatar/%s?s=100&d=identicon" $grav )}}
{{ $data.Set "photo" (printf "https://www.gravatar.com/avatar/%s?s=100&d=identicon" ( md5 $rb.url ) ) }}
{{ 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 }}
{{ warnf "Unable to get remote resource %q" . }}
{{ end }}
{{ end }}

Expand Down

0 comments on commit 8480ee5

Please sign in to comment.