{{- $pc := .Page.Site.Config.Privacy.Twitter -}} {{- $sc := .Page.Site.Config.Services.Twitter -}} {{- if not $pc.Disable -}} {{- $id := or (.Get "id") "" -}} {{- $user := or (.Get "user") "" -}} {{- if and $id $user -}} {{- template "render-simple-tweet" (dict "id" $id "user" $user "dnt" $pc.EnableDNT "name" .Name "position" .Position) -}} {{- else -}} {{- errorf "The %q shortcode requires two named parameters: user and id. See %s" .Name .Position -}} {{- end -}} {{- end -}} {{- define "render-simple-tweet" -}} {{- $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 .Err -}} {{- errorf "%s" . -}} {{- else -}} {{- (. | transform.Unmarshal).html | safeHTML -}} {{- end -}} {{- else -}} {{- warnidf "shortcode-twitter-simple-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}} {{- end -}} {{- end -}} {{- define "__h_simple_twitter_css" -}} {{- if not (.Page.Scratch.Get "__h_simple_twitter_css") -}} {{/* Only include once */}} {{- .Page.Scratch.Set "__h_simple_twitter_css" true -}} {{- end -}} {{- end -}}