- id: steve
name: Steve Smith
- id: john
name: John Smith
$allElders - the Data file elders.yml array
$elders - is a single element array of a map
$elder - is the map of the desired elder element. Defining a variable at the top of the template provides access to the data within the template.
.Params.elder_id - page variable that contains the elder_id for this chapter.
Note: this reason for the separate elder.yml file is that elder data is read from multiple pages and partial templates and I wanted to keep all elder data in a single file because the end-users will be using Forestry.IO to edit their site content and data files.
{{ define "main" }}
{{ $allElders := index .Site.Data.elders }}
{{ $elders := where $allElders "id" .Params.elder_id }}
{{ $elder := index $elders 0 }}
<section class="container bg-containerBackground py-5 prose md:prose-md px-3">
<p>{{ $elder.id }}</p>
</section>
{{ end }}
Hope this helps someone, I’m learning a lot today!