diff options
| author | Reorx <novoreorx@gmail.com> | 2022-05-18 13:46:15 +0800 |
|---|---|---|
| committer | Reorx <novoreorx@gmail.com> | 2022-05-18 13:46:15 +0800 |
| commit | 7c253d3fee18ff79c1fd446126bc577cb2658456 (patch) | |
| tree | 50cf8d3263f63c7cc984bb0798c603afe47546e5 /layouts | |
| parent | 570601c2a7a89893ad7bb8eb1f740dff260b2b3d (diff) | |
new shortcode: social-quote-tweet; enhance h2, h3 margin
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/partials/social_links.html | 2 | ||||
| -rw-r--r-- | layouts/shortcodes/social-quote-tweet.html | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/layouts/partials/social_links.html b/layouts/partials/social_links.html index 3dba7e1..5eaee1c 100644 --- a/layouts/partials/social_links.html +++ b/layouts/partials/social_links.html @@ -1,7 +1,7 @@ <div class="social-links"> {{ with .Params.socialLinks.twitter }} {{ if (and .id .user) }} - <div class="tweet-container"> + <div class="tweet social-quote"> <div class="title"> Discuss on twitter </div> diff --git a/layouts/shortcodes/social-quote-tweet.html b/layouts/shortcodes/social-quote-tweet.html new file mode 100644 index 0000000..d8b21ca --- /dev/null +++ b/layouts/shortcodes/social-quote-tweet.html @@ -0,0 +1,16 @@ +<div class="tweet social-quote"> + <div class="title"> + {{ safeHTML (index $.Site.Data.svg "twitter-simple") }} + {{ with .Inner }}<span>{{ . }}</span>{{ end }} + </div> + {{ $user := .Get "user" }} + {{ $id := .Get "id" }} + {{ $dnt := true }} + {{- .Inner -}}{{/* not required, only to not break Obsidian highlight by adding `/` before `>` */}} + + {{- $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 -}} +</div> |
