diff options
author | Sascha Brendel <mail@lednerb.eu> | 2020-07-27 21:31:15 +0300 |
---|---|---|
committer | Sascha Brendel <mail@lednerb.eu> | 2020-07-27 21:31:15 +0300 |
commit | 50c001e9298b9ad890161d9ecf6f08aa3b87019c (patch) | |
tree | c3c3ea08675a18757ccbce3f108630d41b6f8932 | |
parent | aea5365e218e854fd3fed6f15ac4f2b84fc34ef2 (diff) |
Fixed meta tags for open graph data. Part of #168
-rw-r--r-- | layouts/_default/baseof.html | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 8817f03..31761d4 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,9 +1,30 @@ -{{ if .Params.gallery }} - {{ .Scratch.Set "image" (index (.Params.gallery) 0 | relURL | absURL) }} +{{ if eq .Type "gallery" }} + {{ $image := (index (.Resources.ByType "image") 0 ) }} + {{ $imageUrl := "" }} + + {{ if and (.Site.Params.resizeImages | default true) (.Params.resizeImages | default true) }} + {{ $imageUrl = ($image.Fill "700x350 q95").Permalink }} + {{ else }} + {{ $imageUrl = $image.Permalink }} + {{ end }} + + {{ .Scratch.Set "image" $imageUrl }} + +{{ else if .Resources.GetMatch "featuredImage.*" }} + {{ $imageUrl := "" }} + + {{ if and (.Site.Params.resizeImages | default true) (.Params.resizeImages | default true) }} + {{ $imageUrl = ((.Resources.GetMatch "featuredImage.*").Fill "700x350 q95").Permalink }} + {{ else }} + {{ $imageUrl = (.Resources.GetMatch "featuredImage.*").Permalink }} + {{ end }} + + {{ .Scratch.Set "image" $imageUrl }} + {{ else if .Params.featuredImage }} - {{ .Scratch.Set "image" (.Params.featuredImage) }} + {{ .Scratch.Set "image" (.Params.featuredImage | absURL) }} {{ else if .Params.mp4videoImage }} - {{ .Scratch.Set "image" (.Params.mp4videoImage) }} + {{ .Scratch.Set "image" (.Params.mp4videoImage | absURL) }} {{ else }} {{ .Scratch.Set "image" (printf "https://www.gravatar.com/avatar/%s?size=200" (md5 .Site.Params.gravatarEMail)) }} {{ end }} @@ -17,10 +38,11 @@ {{ .Scratch.Set "description" (printf "%s - %s" (.Title) (.Site.Params.description)) }} {{- end -}} {{- end -}} + {{- if eq .Site.Title .Title -}} -{{ .Scratch.Set "title" (.Site.Params.subtitle) }} + {{ .Scratch.Set "title" (.Site.Params.subtitle) }} {{- else -}} -{{ .Scratch.Set "title" (.Title) }} + {{ .Scratch.Set "title" (.Title) }} {{- end -}} <!doctype html> |