A fun part about how I’m approaching the switch to micro.blog is that I’m working on it in 30 minute chunks here and there. Today I stumbled through how to work with Hugo templates to display categories:
{{ if .Params.categories }}
{{ delimit .Params.categories ", " }}
{{ else }}
Post
{{ end }}
The learning portion of this is that the Hugu/micro.blog templating language is completely unfamiliar to me. Is .Params.categories
nil
when empty, or is it sometimes an empty array? Can I treat it as nullable, or do I have to check array length? Can I just call delimit
without any safety checks?
What I think I can rely on so far:
.Params.catagories
is nullable.Params.catagories
isnil
when empty, andif
should be reliabledelimit
will not guard against nullable values