Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cntrump/hugo-notepadium.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvvveiii <cntrump@gmail.com>2020-04-16 12:52:49 +0300
committervvveiii <cntrump@gmail.com>2020-04-16 12:52:49 +0300
commit8941daa07022e9dbc22aa5e295ef13d3edc6bf67 (patch)
tree6c41655a9f178bc6845c7e0e1f318d4890937f01 /layouts
parentecd1293e6d12113d8afaa97e32a2df423aface18 (diff)
Add twitter-card.html partial
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/head.html1
-rw-r--r--layouts/partials/twitter-card.html17
2 files changed, 18 insertions, 0 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 375951e..cf34a67 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -19,4 +19,5 @@
{{- partial "style.html" . -}}
{{- partial "rss-feed.html" . -}}
+{{- partial "twitter-card.html" . -}}
{{- partial "head-extra.html" . -}} \ No newline at end of file
diff --git a/layouts/partials/twitter-card.html b/layouts/partials/twitter-card.html
new file mode 100644
index 0000000..a4eb9c1
--- /dev/null
+++ b/layouts/partials/twitter-card.html
@@ -0,0 +1,17 @@
+<meta name="twitter:card" content="summary" />
+<meta name="twitter:title" content="{{- .Title -}}" />
+{{- $imgurl := "" -}}
+
+{{- if .Params.cover -}}
+ {{- $imgurl = .Params.cover -}}
+{{- else if .Params.imgs -}}
+ {{- $imgurl = index .Params.imgs 0 -}}
+{{- end -}}
+
+{{- if gt (len $imgurl) 0 -}}
+ {{- $imgurl = lower $imgurl -}}
+ {{- if and (not (hasPrefix $imgurl "http://")) (not (hasPrefix $imgurl "https://")) -}}
+ {{- $imgurl = print .Permalink $imgurl -}}
+ {{- end -}}
+<meta name="twitter:image" content="{{- $imgurl -}}" />
+{{- end -}} \ No newline at end of file