refactor: Move thumbnail list template to partial template file
This commit is contained in:
parent
9ba447b23e
commit
56aed1a86d
2 changed files with 20 additions and 18 deletions
|
@ -15,24 +15,8 @@
|
|||
|
||||
|
||||
<div class="card-body">
|
||||
{{/* Thumbnail images should be stored as 'thumbnail'.* in the page bundle, but
|
||||
historically they might have been referenced as 'thumbnail' in the front
|
||||
matter, or (even more historically) as 'cardImage'. Use scratch to
|
||||
normalize all these different systems.
|
||||
*/}}
|
||||
{{ $bundleGlob := "thumbnail.*" }}
|
||||
{{ $frontThumbGlob := print "images/" (.Params.thumbnail) ".*" }}
|
||||
{{ $frontCardGlob := print "images/" (.Params.cardImage) ".jpg" }}
|
||||
{{ $allThumbnailGlob := print "{" $frontThumbGlob "," $frontCardGlob "," $bundleGlob "}" }}
|
||||
{{ with .Resources.GetMatch $allThumbnailGlob }}
|
||||
{{ $thumbnail := . }}
|
||||
{{ $thumbnailResized := $thumbnail.Resize "600x" }}
|
||||
<img
|
||||
class="img img-thumbnail float-start me-3 md-max-width-33"
|
||||
src="{{ $thumbnailResized.RelPermalink }}"
|
||||
alt="Thumbnail of {{ .Title }}"
|
||||
/>
|
||||
{{ end }}
|
||||
{{ partial "list-item-thumbnail" . }}
|
||||
|
||||
{{/* Prefer full-text links over local ones */}}
|
||||
{{ $link := default .RelPermalink (index .Params "link") }}
|
||||
<a href="{{ $link }}"><h3 class="card-title">{{ .Title }}</h3></a>
|
||||
|
|
18
layouts/partials/list-item-thumbnail.html
Normal file
18
layouts/partials/list-item-thumbnail.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{{/* Thumbnail images should be stored as 'thumbnail'.* in the page bundle, but
|
||||
historically they might have been referenced as 'thumbnail' in the front
|
||||
matter, or (even more historically) as 'cardImage'. Use scratch to
|
||||
normalize all these different systems.
|
||||
*/}}
|
||||
{{ $bundleGlob := "thumbnail.*" }}
|
||||
{{ $frontThumbGlob := print "images/" (.Params.thumbnail) ".*" }}
|
||||
{{ $frontCardGlob := print "images/" (.Params.cardImage) ".jpg" }}
|
||||
{{ $allThumbnailGlob := print "{" $frontThumbGlob "," $frontCardGlob "," $bundleGlob "}" }}
|
||||
{{ with .Resources.GetMatch $allThumbnailGlob }}
|
||||
{{ $thumbnail := . }}
|
||||
{{ $thumbnailResized := $thumbnail.Resize "600x" }}
|
||||
<img
|
||||
class="img img-thumbnail float-start me-3 md-max-width-33"
|
||||
src="{{ $thumbnailResized.RelPermalink }}"
|
||||
alt="Thumbnail of {{ .Title }}"
|
||||
/>
|
||||
{{ end }}
|
Loading…
Reference in a new issue