summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-09-06 01:43:08 +0800
committerReorx <novoreorx@gmail.com>2022-09-06 01:43:08 +0800
commit8d679ad58d6930eb9dfe2be5c03086af0a0dd992 (patch)
treec0d7bcc8e30493b0633aafaa031051e1d6068fa4 /layouts
parenta316c983a6e3118a5278b0522381217f31c7b47c (diff)
add shortcode tweet-ref for creating tweet reference in footnotes
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/social_quote_tweet.html2
-rw-r--r--layouts/shortcodes/tweet-ref.html10
2 files changed, 11 insertions, 1 deletions
diff --git a/layouts/partials/social_quote_tweet.html b/layouts/partials/social_quote_tweet.html
index b3068aa..d0bd66d 100644
--- a/layouts/partials/social_quote_tweet.html
+++ b/layouts/partials/social_quote_tweet.html
@@ -4,7 +4,7 @@
{{ with .title }}<span>{{ . }}</span>{{ end }}
</div>
- {{ $dnt := true }}
+ {{- $dnt := true -}}
{{- $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 -}}
diff --git a/layouts/shortcodes/tweet-ref.html b/layouts/shortcodes/tweet-ref.html
new file mode 100644
index 0000000..cf02c4c
--- /dev/null
+++ b/layouts/shortcodes/tweet-ref.html
@@ -0,0 +1,10 @@
+<div class="tweet-ref">
+ {{- $url := .Get 0 -}}
+ From <a href="{{ $url }}">{{ strings.TrimPrefix "https://" $url }}</a>:
+
+ {{- $dnt := true -}}
+ {{- $query := querify "url" $url "dnt" $dnt -}}
+ {{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}}
+ {{- $json := getJSON $request -}}
+ {{- replaceRE "<script.+/script>" "" $json.html | safeHTML -}}
+</div>