In the dashboard, I want to list category pages with cover images of their latest posts. If defined, I look for the cover image, if not I take the first one available. Here’s how:
site.yml:
image:
query: page.children.listed.last.cover.toFile ?? page.children.listed.last.images.first
^^^^^^^
post.yml:
Cover: - file://anJ8qVtKZK7JQ8eJ
This works for one kind of template. For another kind of template .toFile
must be omitted to make it work.
How’s that?