summaryrefslogtreecommitdiff
path: root/layouts/partials
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-05-18 14:24:29 +0800
committerReorx <novoreorx@gmail.com>2022-05-18 14:24:29 +0800
commitecaf84c7c79c1b4bcf22e19b8b2fd30fbf3489af (patch)
treeaa479732f0cdbea0e3ba998a1b7fcc66f0d3c54b /layouts/partials
parent7c253d3fee18ff79c1fd446126bc577cb2658456 (diff)
refactor social-quote-tweet and social_links to use social_quote_tweet partial
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/social_links.html23
-rw-r--r--layouts/partials/social_quote_tweet.html13
2 files changed, 18 insertions, 18 deletions
diff --git a/layouts/partials/social_links.html b/layouts/partials/social_links.html
index 5eaee1c..e0f5415 100644
--- a/layouts/partials/social_links.html
+++ b/layouts/partials/social_links.html
@@ -1,20 +1,7 @@
<div class="social-links">
- {{ with .Params.socialLinks.twitter }}
- {{ if (and .id .user) }}
- <div class="tweet social-quote">
- <div class="title">
- Discuss on twitter
- </div>
- {{- template "render-tweet" (dict "id" .id "user" .user "dnt" true) -}}
- </div>
- {{ end }}
- {{ end }}
+ {{- with .Params.socialLinks.twitter }}
+ {{- if (and .id .user) }}
+ {{ partial "social_quote_tweet.html" (dict "user" .user "id" .id "title" "Discuss on Twitter") }}
+ {{- end }}
+ {{- 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 -}}
diff --git a/layouts/partials/social_quote_tweet.html b/layouts/partials/social_quote_tweet.html
new file mode 100644
index 0000000..b3068aa
--- /dev/null
+++ b/layouts/partials/social_quote_tweet.html
@@ -0,0 +1,13 @@
+<div class="tweet social-quote">
+ <div class="title">
+ {{ safeHTML (index site.Data.svg "twitter-simple") }}
+ {{ with .title }}<span>{{ . }}</span>{{ end }}
+ </div>
+
+ {{ $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 -}}
+ {{- $json := getJSON $request -}}
+ {{- replaceRE "<script.+/script>" "" $json.html | safeHTML -}}
+</div>