I’m trying to insert thumbnails from a page bundle in the list page showing all posts. Consider the following content layout, where each leaf bundle is a blog post:
post/
|
+->leaf-bundle-dir/
| |
| +->index.md
| +->image.jpg
|
+->leaf-bundle-dir-2/
|
+->index.md
+->image.jpg
In the index.md
files I have front matter including:
resources:
-
src: image.jpg
name: thumbnail
From within the context of the single page template, the page resources can be accessed as expected. The following example works on that single page context:
{{ $thumbnail := .Resources.GetMatch "thumbnail" }}
{{ with $thumbnail }}
{{ $scaled := .Fit "600x400" }}
<img src="{{ $scaled.Permalink }}"/>
{{- end -}}
However, I have been unable to figure out how to access those page resources when iterating through the posts to create list page:
{{- $paginator := .Paginate (where .Data.Pages "Type" "post") -}}
{{- partial "header" . -}}
<section class="content list">
{{- range $index, $element := $paginator.Pages -}}
<article class="thumb">
<div class="imgthumb">
{{- if .Params.thumbnail -}}
<a href="{{ .URL }}">{{ partial "thumbnail" .Params }}</a>
{{- end -}}
</div>
<div class="prevtext">
<h1><a href="{{ .URL }}">{{ .Title }}</a></h1>
{{- partial "datetime" .Date -}}
<p>{{ .Params.excerpt }}</p>
</div>
</article>
{{- end -}}
</section>
{{- partial "footer" . -}}
The theme expects an old-style, pre-bundle type Params.thumbnail
, and I’m trying to convert it to use a thumbnail specified in the post bundle. That’s where I’m stuck.