Переглянути джерело

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.
George Cushen 5 роки тому
батько
коміт
9d842f584f
1 змінених файлів з 6 додано та 4 видалено
  1. 6 4
      layouts/partials/site_head.html

+ 6 - 4
layouts/partials/site_head.html

@@ -147,11 +147,16 @@
 
   <link rel="canonical" href="{{ .Permalink }}">
 
+  {{/* 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" }}