mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
resources: Replace error handling in GetRemote with try (note)
Closes #13216
This commit is contained in:
@@ -17,13 +17,13 @@
|
||||
{{- $url := printf "https://twitter.com/%v/status/%v" .user .id -}}
|
||||
{{- $query := querify "url" $url "dnt" .dnt -}}
|
||||
{{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}}
|
||||
{{- with resources.GetRemote $request -}}
|
||||
{{- with try (resources.GetRemote $request) -}}
|
||||
{{- with .Err -}}
|
||||
{{- errorf "%s" . -}}
|
||||
{{- else -}}
|
||||
{{- else with .Value -}}
|
||||
{{- (. | transform.Unmarshal).html | safeHTML -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- else -}}
|
||||
{{- warnidf "shortcode-twitter-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@@ -14,14 +14,14 @@
|
||||
{{- $url := printf "https://twitter.com/%v/status/%v" .user .id -}}
|
||||
{{- $query := querify "url" $url "dnt" .dnt "omit_script" true -}}
|
||||
{{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}}
|
||||
{{- with resources.GetRemote $request -}}
|
||||
{{- with try (resources.GetRemote $request) -}}
|
||||
{{- with .Err -}}
|
||||
{{- errorf "%s" . -}}
|
||||
{{- else -}}
|
||||
{{- else with .Value -}}
|
||||
{{- (. | transform.Unmarshal).html | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- warnidf "shortcode-twitter-simple-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- warnidf "shortcode-twitter-simple-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -31,7 +31,16 @@
|
||||
{{- .Page.Scratch.Set "__h_simple_twitter_css" true -}}
|
||||
<style type="text/css">
|
||||
.twitter-tweet {
|
||||
font: 14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
|
||||
font:
|
||||
14px/1.45 -apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
Roboto,
|
||||
Oxygen-Sans,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
"Helvetica Neue",
|
||||
sans-serif;
|
||||
border-left: 4px solid #2b7bb9;
|
||||
padding-left: 1.5em;
|
||||
color: #555;
|
||||
|
@@ -23,10 +23,10 @@
|
||||
{{- $url := urls.JoinPath "https://vimeo.com" .id -}}
|
||||
{{- $query := querify "url" $url "dnt" $dnt -}}
|
||||
{{- $request := printf "https://vimeo.com/api/oembed.json?%s" $query -}}
|
||||
{{- with resources.GetRemote $request -}}
|
||||
{{- with try (resources.GetRemote $request) -}}
|
||||
{{- with .Err -}}
|
||||
{{- errorf "%s" . -}}
|
||||
{{- else -}}
|
||||
{{- else with .Value -}}
|
||||
{{- with . | transform.Unmarshal -}}
|
||||
{{- $class := printf "%s %s" "s_video_simple" "__h_video" -}}
|
||||
{{- with $.class -}}
|
||||
@@ -45,8 +45,8 @@
|
||||
</a>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- warnidf "shortcode-vimeo-simple" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- warnidf "shortcode-vimeo-simple" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
Reference in New Issue
Block a user