I’m working on a custom theme and a config option to show full-sized images on the home page if you add the category to a list in config.json
. I’m then comparing the contents of that list to the categories attributed to a post. I can’t seem to get it to work, and set a boolean to true
when there’s a match. My Hugo skills aren’t great, so would appreciate a hand here. Here’s some code:
{{ $fullcats := .Site.Params.categoriesFullImgsHome }}
{{ $fullimg := false }}
{{ $cats := .Params.categories }}
{{ range $category := $fullcats }}
{{ if in $category $cats }}
{{ $fullimg = true }}
{{ end }}
{{ end }}
...
<div class="post-image" {{ if not $fullimg }} style="max-height: 250px; overflow: hidden;" {{ end }}>
Printing $cats
and $fullcats
proves that they are identical for certain posts, but I never see a post-image
rendered without the style.
Feel like maybe I’m misunderstanding something! Would appreciate a hand working it out if anybody has the time!