From 8d679ad58d6930eb9dfe2be5c03086af0a0dd992 Mon Sep 17 00:00:00 2001 From: Reorx Date: Tue, 6 Sep 2022 01:43:08 +0800 Subject: add shortcode tweet-ref for creating tweet reference in footnotes --- layouts/partials/social_quote_tweet.html | 2 +- layouts/shortcodes/tweet-ref.html | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 layouts/shortcodes/tweet-ref.html (limited to 'layouts') 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 }}{{ . }}{{ end }} - {{ $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 @@ +
+ {{- $url := .Get 0 -}} + From {{ strings.TrimPrefix "https://" $url }}: + + {{- $dnt := true -}} + {{- $query := querify "url" $url "dnt" $dnt -}} + {{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}} + {{- $json := getJSON $request -}} + {{- replaceRE "" "" $json.html | safeHTML -}} +
-- cgit v1.2.3