mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2026-05-22 11:19:01 +00:00
[PATCH] tpl: Allow using page resources on the images page parameter
for `opengraph`, `schema` and `twitter_cards` templates The page images selection order as follows: 1. Page's images parameter, image resources are supported. 2. Page's image resources that naming in *feature*, *cover* or *thumbnail* pattern. 3. If no page images specified, then the first one of site's images will be used as the fallback, supports site resources. cherry-picked from https://github.com/gohugoio/hugo/commit/14d85ec136413dcfc96ad8e4d31633f8f9cbf410 ++ compatibility fixes for PaperMod Co-authored-by: Aditya Telange <21258296+adityatelange@users.noreply.github.com>
This commit is contained in:
committed by
Aditya Telange
parent
b5f7118d82
commit
df330a05b5
@@ -10,18 +10,10 @@
|
||||
{{- end}}
|
||||
{{- else }}
|
||||
|
||||
{{- with $.Params.images -}}
|
||||
{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
|
||||
{{- else -}}
|
||||
{{- $images := $.Resources.ByType "image" -}}
|
||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||
{{- with $featured -}}
|
||||
<meta property="og:image" content="{{ $featured.Permalink }}"/>
|
||||
{{- else -}}
|
||||
{{- with site.Params.images }}<meta property="og:image" content="{{ index . 0 | absURL }}"/>{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $images := partial "partials/templates/_funcs/get-page-images" . -}}
|
||||
{{- range first 6 $images }}
|
||||
<meta property="og:image" content="{{ .Permalink }}" />
|
||||
{{ end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- if .IsPage }}
|
||||
|
||||
Reference in New Issue
Block a user