diff --git a/layouts/partials/microformats/opengraph.html b/layouts/partials/microformats/opengraph.html
index bd4b5a9..574420c 100644
--- a/layouts/partials/microformats/opengraph.html
+++ b/layouts/partials/microformats/opengraph.html
@@ -1,28 +1,20 @@
{{- if not (eq .Kind "home") }}
-
+
{{- end }}
{{- with .Site.Title }}
-
+
+{{- end }}
+{{- with partial "utils/featured" . }}
+
{{- end }}
{{- with partial "utils/description" . }}
-
+
{{- end }}
-
-{{- with $.Params.images }}
- {{- range first 6 . }}{{ end -}}
-{{- else }}
- {{- $featured := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" -}}
- {{- with $featured }}
-
- {{- else }}
- {{- with $.Site.Params.images }}
-
- {{- end }}
- {{- end }}
-{{- end }}
-
{{- with .Params.audio }}
{{- end }}
diff --git a/layouts/partials/microformats/schema.html b/layouts/partials/microformats/schema.html
index 9175cef..b72a8c7 100644
--- a/layouts/partials/microformats/schema.html
+++ b/layouts/partials/microformats/schema.html
@@ -1,19 +1,17 @@
-{{- if .IsHome -}}
- {{- $thumbnail := default (default "brand.svg" .Site.Params.logo) (index (default slice .Site.Params.images) 0) | absURL }}
-
+{{- if eq .Kind "home" }}
{{- else if .IsPage }}
@@ -22,18 +20,28 @@
"@context": "http://schema.org",
"@type": "TechArticle",
"articleSection": "{{ .Section | humanize | title }}",
- "name": "{{ (partial "utils/title" .) | safeJS }}",
- "headline": "{{ (partial "utils/title" .) | safeJS }}",
- "alternativeHeadline": "{{ .Params.lead }}",
- {{- with partial "utils/description" . }}
- "description": "{{ trim (. | plainify) "\n" | safeHTML }}",
+ "name": {{ partial "utils/title" . }},
+ "url" : {{ .Permalink }},
+ "headline": {{ partial "utils/title" . }},
+ {{- with .Params.lead }}
+ "alternativeHeadline": {{ . }},
{{- end }}
- "inLanguage": {{ .Site.Language.Lang }},
+ {{- with partial "utils/description" . }}
+ "description": "{{ . | plainify | htmlUnescape | chomp }}",
+ {{- end }}
+ {{- with partial "utils/featured" . }}
+ "thumbnailUrl": {{ . }},
+ {{- end }}
+ "wordCount" : "{{ .WordCount }}",
+ "inLanguage": {{ .Lang }},
"isFamilyFriendly": "true",
"mainEntityOfPage": {
"@type": "WebPage",
- "@id": "{{ .Permalink }}"
+ "@id": {{ .Permalink }}
},
+ {{- with $tags := .Params.tags }}
+ "keywords" : [ {{ range $i, $tag := $tags }}{{ if $i }}, {{ end }}"{{ $tag }}" {{ end }}],
+ {{- end }}
"copyrightHolder" : "{{ .Site.Title }}",
"copyrightYear" : "{{ .Date.Format "2006" }}",
"dateCreated": "{{ .Date.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
@@ -45,23 +53,11 @@
"url": {{ .Site.BaseURL }},
"logo": {
"@type": "ImageObject",
- "url": "{{ (default "brand.svg" .Site.Params.logo) | absURL }}",
+ "url": {{ (default "brand.svg" .Site.Params.logo) | absURL }},
"width":"32",
"height":"32"
}
- },
- {{- with $images := $.Resources.ByType "image" }}
- "image": [ {{ range $i, $image := $images }}{{ if $i }}, {{ end }}"{{ $image.Permalink | absURL }}" {{ end }}],
- {{- else }}
- {{- with $images := .Params.images }}
- "image": [ {{ range $i, $image := $images }}{{ if $i }}, {{ end }}"{{ $image | absURL }}" {{ end }}],
- {{- end }}
- {{- end }}
- "url" : "{{ .Permalink }}",
- "wordCount" : "{{ .WordCount }}",
- {{- with $tags := .Params.tags }}
- "genre" : [ {{ range $i, $tag := $tags }}{{ if $i }}, {{ end }}"{{ $tag }}" {{ end }}]
- {{- end }}
+ }
}
{{- end }}
diff --git a/layouts/partials/microformats/twitter_cards.html b/layouts/partials/microformats/twitter_cards.html
index 86f96d4..a2cc08c 100644
--- a/layouts/partials/microformats/twitter_cards.html
+++ b/layouts/partials/microformats/twitter_cards.html
@@ -1,27 +1,14 @@
-{{- with $.Params.images -}}
+{{- with partial "utils/featured" . }}
-
{{- else }}
- {{- $images := $.Resources.ByType "image" -}}
- {{- $featured := $images.GetMatch "*feature*" -}}
- {{- if not $featured }}
- {{- $featured = $images.GetMatch "{*cover*,*thumbnail*}" -}}
- {{- end }}
- {{- with $featured }}
-
-
- {{- else }}
- {{- with $.Site.Params.images }}
-
-
- {{- else }}
-
- {{- end }}
- {{- end }}
+
+{{- end }}
+
+{{- with partial "utils/featured" . }}
+
{{- end }}
-
{{- with partial "utils/description" . }}
-
+
{{- end }}
{{- with .Site.Social.twitter -}}
diff --git a/layouts/partials/utils/featured.html b/layouts/partials/utils/featured.html
new file mode 100644
index 0000000..33c4be8
--- /dev/null
+++ b/layouts/partials/utils/featured.html
@@ -0,0 +1,12 @@
+{{ $img := "" }}
+
+{{ with $source := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
+ {{ $featured := .Fill (printf "1200x630 %s" (default "Smart" .Params.anchor)) }}
+ {{ $img = $featured.Permalink }}
+{{ else }}
+ {{ with default $.Site.Params.images $.Params.images }}
+ {{ $img = index . 0 | absURL }}
+ {{ end }}
+{{ end }}
+
+{{ return $img }}