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

github.com/mrmierzejewski/hugo-theme-console.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Mierzejewski <marcin@mierzejewski.net>2020-05-03 14:51:54 +0300
committerMarcin Mierzejewski <marcin@mierzejewski.net>2020-05-03 14:51:54 +0300
commit3184aed8b5f065557c3dccb6fe9dcbf3afdf42cf (patch)
tree508b21ad543367819db03921548f32b2ff066b37
parent512902121b2c48231bbbc9dfbe49c21f768a579c (diff)
twitter: add twitter cards
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/partials/twitter_cards.html19
2 files changed, 20 insertions, 1 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 0fa4cc4..2c71714 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -23,7 +23,7 @@
{{ printf `<link href="%s" rel="%s" type="%s" title="%s" />` .Permalink .Rel .MediaType.Type $.Site.Title | safeHTML }}
{{ end }}
{{- partial "opengraph.html" . -}}
- {{ template "_internal/twitter_cards.html" . }}
+ {{- partial "twitter_cards.html" . -}}
{{ template "_internal/google_analytics.html" . }}
</head>
<body class="terminal">
diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html
new file mode 100644
index 0000000..cac9672
--- /dev/null
+++ b/layouts/partials/twitter_cards.html
@@ -0,0 +1,19 @@
+{{- with .Params.image }}
+{{ $image := $.Resources.GetMatch . }}
+{{ with $image }}
+{{ $thumb := .Resize "400x" }}
+<meta name="twitter:card" content="summary_large_image"/>
+<meta name="twitter:image" content="{{ $thumb.Permalink }}">
+{{ end }}
+{{ end }}
+
+<meta name="twitter:title" content="{{ .Title }}"/>
+<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
+{{ with .Site.Social.twitter -}}
+<meta name="twitter:site" content="@{{ . }}"/>
+{{ end -}}
+{{ range .Site.Authors }}
+{{ with .twitter -}}
+<meta name="twitter:creator" content="@{{ . }}"/>
+{{ end -}}
+{{ end -}} \ No newline at end of file