Consider the following template code:
{{ $downloads := where .Site.Pages ".Params.type" "download" }}
{{ $apple := where $downloads ".Params.product" "apple" }}
{{ $android := where $downloads ".Params.product" "android" }}
{{ range first 1 $apple }}
<h2>{{ .Params.product }}</h2>
{{ .Render "download" }}
{{ end }}
{{ range first 1 $android }}
<h2>{{ .Params.product }}</h2>
{{ .Render "download" }}
{{ end }}
Is there a way to shorten this to dynamically generate sections for each product
front matter entry?
Additionally, in the above example, .Params.product
would just render apple
. How would I turn that into a more descriptive title, like “Apple-specific Product Downloads” when it is rendered.