PaperModX/layouts/partials/social_links.html

21 lines
659 B
HTML
Raw Normal View History

2022-05-05 09:23:55 +01:00
<div class="social-links">
{{ with .Params.socialLinks.twitter }}
2022-05-12 09:26:08 +01:00
{{ if (and .id .user) }}
2022-05-05 09:23:55 +01:00
<div class="tweet-container">
<div class="title">
Discuss on twitter
</div>
{{- template "render-tweet" (dict "id" .id "user" .user "dnt" true) -}}
</div>
2022-05-12 09:26:08 +01:00
{{ end }}
2022-05-05 09:23:55 +01:00
{{ end }}
</div>
{{- define "render-tweet" -}}
{{- $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 -}}
{{- $json := getJSON $request -}}
{{- replaceRE "<script.+/script>" "" $json.html | safeHTML -}}
{{- end -}}