From 9d842f584f876613e56a2b10a3a01d3fae355fb5 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sun, 5 Apr 2020 12:27:00 +0100 Subject: [PATCH] fix: social sharing image for author pages The social sharing logic was attempting to use the legacy system of defining the avatar image name in `site.Params.avatar`, however since the author system was added to Academic, `site.Params.avatar` is now a group of params and the avatar itself is stored in the author's page bundle. Hence, use the avatar in the author's page bundle (if it exists) to represent an author page. This bug could affect the image used to represent a page in social sharing and RSS. --- layouts/partials/site_head.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/layouts/partials/site_head.html b/layouts/partials/site_head.html index 79137ba1..695bd07f 100644 --- a/layouts/partials/site_head.html +++ b/layouts/partials/site_head.html @@ -147,11 +147,16 @@ + {{/* Get page image for sharing. */}} {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} + {{ $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" }} {{ $has_logo := fileExists "assets/images/logo.png" | or (fileExists "assets/images/logo.svg") }} {{ $og_image := "" }} {{ $twitter_card := "summary_large_image" }} - {{ if $featured_image }} + {{ if (and (eq .Kind "taxonomy") $avatar_image) }} + {{ $og_image = ($avatar_image.Fill "270x270 Center").Permalink }}{{/* Match image proc in About widget. */}} + {{ $twitter_card = "summary" }} + {{ else if $featured_image }} {{ $og_image = $featured_image.Permalink }} {{ else if .Params.header.image }} {{ $og_image = printf "img/%s" .Params.header.image | absURL }} @@ -160,9 +165,6 @@ {{ else if $has_logo }} {{ $og_image = (partial "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }} {{ $twitter_card = "summary" }} - {{ else if site.Params.avatar }} - {{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }} - {{ $twitter_card = "summary" }} {{ else }} {{ $og_image = (partial "functions/get_icon" 512).Permalink }} {{ $twitter_card = "summary" }}