github.com/neohugo/neohugo@v0.123.8/tpl/tplimpl/embedded/templates/shortcodes/twitter.html (about) 1 {{- $pc := .Page.Site.Config.Privacy.Twitter -}} 2 {{- if not $pc.Disable -}} 3 {{- if $pc.Simple -}} 4 {{- template "_internal/shortcodes/twitter_simple.html" . -}} 5 {{- else -}} 6 {{- $id := or (.Get "id") "" -}} 7 {{- $user := or (.Get "user") "" -}} 8 {{- if and $id $user -}} 9 {{- template "render-tweet" (dict "id" $id "user" $user "dnt" $pc.EnableDNT "name" .Name "position" .Position) -}} 10 {{- else -}} 11 {{- errorf "The %q shortcode requires two named parameters: user and id. See %s" .Name .Position -}} 12 {{- end -}} 13 {{- end -}} 14 {{- end -}} 15 16 {{- define "render-tweet" -}} 17 {{- $url := printf "https://twitter.com/%v/status/%v" .user .id -}} 18 {{- $query := querify "url" $url "dnt" .dnt -}} 19 {{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}} 20 {{- with resources.GetRemote $request -}} 21 {{- with .Err -}} 22 {{- errorf "%s" . -}} 23 {{- else -}} 24 {{- (. | transform.Unmarshal).html | safeHTML -}} 25 {{- end -}} 26 {{- else -}} 27 {{- warnidf "shortcode-twitter-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}} 28 {{- end -}} 29 {{- end -}}