Navigation Menu

Skip to content

Commit

Permalink
fix: adjust thumbnail look up order.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: page's `images` parameter no longer accepts page resources.
  • Loading branch information
ElanHasson authored and razonyang committed Feb 6, 2022
1 parent 7251f78 commit c08bca7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 1 addition & 3 deletions layouts/partials/list-item.html
Expand Up @@ -13,9 +13,7 @@ <h2 class="card-title post-title">
</h2>
</div>
<div class="card-body">
{{ if .Page.Params.Images }}
{{ partial "helpers/image" (dict "filename" (index .Page.Params.Images 0) "alt" .Page.Title "class" "img-fluid" "resources" .Page.Resources) }}
{{ end }}
{{- partial "post/thumbnail" .Page -}}
{{- partial "post/meta" .Page -}}
<div class="post-summary">
{{ partial "post/excerpt" .Page }}
Expand Down
10 changes: 10 additions & 0 deletions layouts/partials/post/thumbnail.html
@@ -0,0 +1,10 @@
{{ if .Params.images }}
<img class="img-fluid" alt="{{ .Title }}" src="{{ index .Params.images 0 | absURL }}" loading="lazy"/>
{{- else -}}
{{- $images := .Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- with $featured -}}
<img class="img-fluid" alt="{{ .Title }}" src="{{ $featured.Permalink }}" loading="lazy"/>
{{- end -}}
{{- end -}}

0 comments on commit c08bca7

Please sign in to comment.