hi i created a authors taxonomy where i add name and pictures in my blog with cards design on for listing all articles. If i have 2 authors i add two name’s authors but picture of first author only.
i search one best solution . because i call same range after for others informations. i wish call this range only one upon time for best performance or best practice
i use this code pour create this situation :
my code :)
{{ define “main” }}
{{ range .Pages }}
<!-- top image carte -->
<div>
<img src="{{with .Params.featured_image}}{{.}}{{else}}{{ .Site.Params.featured_image }}{{end}}" alt=""
class="object-fill w-full h-40">
</div>
<div class=" m-2 text-justify text-sm ">
<div class="flex flex-wrap items-center -mt-8 pb-3 ">
<img class="block h-8 w-8 rounded-full bg-white mt-1 mr-2 ml-3 border-2 border-white "
src='{{ range first 1 .Params.authors }}
{{with $.Site.GetPage "taxonomyTerm" (printf "authors/%s" (urlize .)) }}{{ with .Params.photo }}{{ . }}{{ else }}{{ .Site.Params.authorimage }}{{ end }}{{ end }}{{ end }}'
alt="image de l'auteur">
{{ range .Params.authors }}
{{with $.Site.GetPage "taxonomyTerm" (printf "authors/%s" (urlize .)) }}
<a href='{{ .Permalink }}'><span
class="block text-lg font-bold text-white">{{ with .Params.name }}{{ . }}{{else}}{{ .Site.Params.author }}{{end}}{{ end }}{{ end }}</span></a>
</div>
<div class=" ">
<p class=" text-right -mt-4 text-xs"> <i class=" mr-1 far fa-calendar-alt"></i>
<!-- date en Fr via data/mois.yaml merci https://www.christopheducamp.com/ ;) -->
<time class="post-date dt-published"
datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}'>{{ .Date.Day }}
{{ index $.Site.Data.mois (printf "%d" .Date.Month) }} {{ .Date.Year }}</time> </p>
<p class=" text-right text-xs"> <i class=" mr-1 fas fa-clock"></i>
{{.ReadingTime }} minutes
</p>
<h2 class=" font-bold mb-1 text-center"> <a href="{{ .Permalink }}">{{ .Title }}</a> </h2>
<p class=" h-32 md:h-40 text-xs p-3"> {{ with .Params.description }}
{{ . }}
{{ else }}
{{ .Summary }}
{{ end }}
</p>
</div>
</div>
<a href="{{ .Permalink }}">
<div class=" absolute bottom-0 w-full py-2 text-center bg-blue-500 hover:bg-blue-900 text-white ">
Lire
</div>
</a>
</div> {{ end }} {{ end }}