x.html - hugo - [fork] hugo port for 9front
 (HTM) git clone https://git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
       x.html (1227B)
       ---
            1 {{- $pc := site.Config.Privacy.X -}}
            2 {{- if not $pc.Disable -}}
            3   {{- if $pc.Simple -}}
            4     {{- template "_shortcodes/x_simple.html" . -}}
            5   {{- else -}}
            6     {{- $id := or (.Get "id") "" -}}
            7     {{- $user := or (.Get "user") "" -}}
            8     {{- if and $id $user -}}
            9       {{- template "render-x" (dict "id" $id "user" $user "dnt" $pc.EnableDNT "ctx" .) -}}
           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-x" -}}
           17   {{- $url := printf "https://x.com/%v/status/%v" .user .id -}}
           18   {{- $query := querify "url" $url "dnt" .dnt -}}
           19   {{- $request := printf "https://publish.x.com/oembed?%s" $query -}}
           20   {{- with try (resources.GetRemote $request) -}}
           21     {{- with .Err -}}
           22       {{- warnidf "shortcode-x-getremote" "The %q shortcode was unable to retrieve the remote data: %s. See %s" $.ctx.Name . $.ctx.Position -}}
           23     {{- else with .Value -}}
           24       {{- (. | transform.Unmarshal).html | safeHTML -}}
           25     {{- else -}}
           26       {{- warnidf "shortcode-x-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" $.ctx.Name $.ctx.Position -}}
           27     {{- end -}}
           28   {{- end -}}
           29 {{- end -}}