summaryrefslogtreecommitdiff
path: root/layouts/partials
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-05-05 16:23:55 +0800
committerReorx <novoreorx@gmail.com>2022-05-05 16:23:55 +0800
commitba84d6857d3ac1a397ad896d0f40d9053a8f55de (patch)
tree6c2f0c53a323ad13567352da9841ac0b35b46371 /layouts/partials
parenta41eb685a9dc74b8cd51e79e288594f6b681d05d (diff)
add social_links partial
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/social_links.html18
1 files changed, 18 insertions, 0 deletions
diff --git a/layouts/partials/social_links.html b/layouts/partials/social_links.html
new file mode 100644
index 0000000..67501ee
--- /dev/null
+++ b/layouts/partials/social_links.html
@@ -0,0 +1,18 @@
+<div class="social-links">
+ {{ with .Params.socialLinks.twitter }}
+ <div class="tweet-container">
+ <div class="title">
+ Discuss on twitter
+ </div>
+ {{- template "render-tweet" (dict "id" .id "user" .user "dnt" true) -}}
+ </div>
+ {{ 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 -}}