From c65a313004cd991d7da77587dc73e7ff04083986 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 21 Feb 2018 14:03:32 +0000 Subject: [PATCH] Generate image urls for resources in metadata --- layouts/partials/metadata.html | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/layouts/partials/metadata.html b/layouts/partials/metadata.html index c16a6b2..520c9e8 100644 --- a/layouts/partials/metadata.html +++ b/layouts/partials/metadata.html @@ -1,28 +1,47 @@ +{{ if .Params.image }} + {{ if hasPrefix .Params.image "resource:" }} + {{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }} + {{ .Scratch.Set "image" ($resource.Fill "800x418").Permalink }} + {{ else }} + {{ .Scratch.Set "image" .Params.image}} + {{ end }} +{{ end }} + +{{ $image := .Scratch.Get "image" }} + + +{{/* Twitter-specific tags */}} -{{ if .Params.image }} - + +{{ if $image }} + {{ end }} + +{{/* OpenGraph tags*/}} -{{ if .Params.image }} - -{{ end }} +{{ if $image }} + +{{ end }} + + -{{ if .Params.image }} - + +{{ if $image }} + {{ end }} @@ -33,6 +52,7 @@ + {{ range .AlternativeOutputFormats }} {{ end }}