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

github.com/mattstratton/castanet.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Stratton <matt.stratton@gmail.com>2016-09-25 14:46:04 +0300
committerMatt Stratton <matt.stratton@gmail.com>2016-09-25 14:46:04 +0300
commit4867e651468d375ead275200f5d077fa19286e45 (patch)
tree1c93dcf8997da18ff0e1513bd7e3c5fda1d109ba /layouts/partials
parent3822093e6a2c986ff54c1387b35bd09bbd1dd248 (diff)
Implement default social sharing image
If the value for the social image starts with “http” it will NOT prepend the homepage to it. Fixes #17
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/head/seo/open_graph.html6
-rw-r--r--layouts/partials/head/seo/schema.html8
-rw-r--r--layouts/partials/head/seo/twitter_cards.html8
3 files changed, 17 insertions, 5 deletions
diff --git a/layouts/partials/head/seo/open_graph.html b/layouts/partials/head/seo/open_graph.html
index 3d63152..f27cc38 100644
--- a/layouts/partials/head/seo/open_graph.html
+++ b/layouts/partials/head/seo/open_graph.html
@@ -4,7 +4,11 @@
<meta property="og:type" content="{{ if .Params.type }}{{ .Params.type }}{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
{{ with .Params.images }}{{ range first 1 . }}
- <meta property="og:image" content="{{ . }}" />
+ {{ if (eq (slicestr . 0 4) "http") }}
+ <meta property="og:image" content="{{ . }}" file= {{ slicestr . 0 4 }}/>
+ {{ else }}
+ <meta property="og:image" content="{{ $.Site.Params.homepage}}{{ . }}" />
+ {{ end }}
{{ end }}{{ end }}
<!-- Optional Open Graph Markup -->
diff --git a/layouts/partials/head/seo/schema.html b/layouts/partials/head/seo/schema.html
index e348834..01698b2 100644
--- a/layouts/partials/head/seo/schema.html
+++ b/layouts/partials/head/seo/schema.html
@@ -4,7 +4,11 @@
<!-- Output images -->
{{ with .Params.images }}{{ range first 6 . }}
- <meta itemprop="image" content="{{ . }}">
+ {{ if (eq (slicestr . 0 4) "http") }}
+ <meta itemprop="image" content="{{ . }}">
+ {{ else }}
+ <meta itemprop="image" content="{{ $.Site.Params.homepage}}{{ . }}">
+ {{ end }}
{{ end }}{{ end }}
<!-- Output all taxonomies as schema.org keywords -->
@@ -12,4 +16,4 @@
{{if .IsPage}}
<meta itemprop="wordCount" content="{{ .WordCount }}">
-{{ end }} \ No newline at end of file
+{{ end }}
diff --git a/layouts/partials/head/seo/twitter_cards.html b/layouts/partials/head/seo/twitter_cards.html
index 876f583..d18919b 100644
--- a/layouts/partials/head/seo/twitter_cards.html
+++ b/layouts/partials/head/seo/twitter_cards.html
@@ -1,7 +1,11 @@
{{ with .Params.images }}
<!-- Twitter summary card with large image must be at least 280x150px -->
<meta name="twitter:card" content="summary_large_image"/>
- <meta name="twitter:image:src" content="{{ index . 0 }}"/>
+ {{ if (eq (slicestr (index . 0) 0 4) "http") }}
+ <meta name="twitter:image:src" content="{{ index . 0 }}"/>
+ {{ else }}
+ <meta name="twitter:image:src" content="{{ $.Site.Params.homepage}}{{ index . 0 }}"/>
+ {{ end }}
{{ else }}
<meta name="twitter:card" content="summary"/>
{{ end }}
@@ -14,4 +18,4 @@
{{ if isset .Params "author" }}
{{ $author := index .Site.Params.authors .Params.author }}
{{ with $author.twitter }}<meta name="twitter:creator" content="@{{ $author.twitter }}"/>{{ end }}
-{{ end }} \ No newline at end of file
+{{ end }}