Skip to content

Commit

Permalink
fix: use cover image for opengraph
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokaiser committed Nov 23, 2024
1 parent 696ac99 commit 8829b3e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion layouts/partials/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
<meta property="og:url" content="{{ .Permalink }}" />

{{- $images := $.Resources.ByType "image" -}}
{{ $featured := ($images.GetMatch (.Params.featured_image | default "*feature*")) | default (index $images 0) }}
{{ $index := 0 }}
{{ range $i, $image := $images }}
{{ if index $image.Params "cover" }}
{{ $index = $i }}
{{ end }}
{{ end }}
{{ $featured := ($images.GetMatch (.Params.featured_image | default "*feature*")) | default (index $images $index) }}
{{- with $featured -}}
<meta property="og:image" content="{{ $featured.Permalink }}" />
{{- end -}}
Expand Down

0 comments on commit 8829b3e

Please sign in to comment.