I’m trying to setup a method to have multiple authors, an author page for each author, and be able to select a blog post’s author using the antimatter theme. I have an authors page with a custom authors.html.twig that shows all authors. I did this by creating a collection for the authors page for all descendants and then creating a subpage in /mysite/authors for each author. In user/config/site.yaml I’ve created an entry for each author, like so:
author:
joe:
name: Joe Sample
bio: Bio for Joe
peter:
name: Peter Sample
bio: Bio for Peter
In system/blueprints/pages/default.yaml I added
header.author:
type: textarea
label: Author
yaml: true
So I can easily add an author to each blog post from the page creation screen. The problem I’m having is with my authors pages. I have a custom authors_item.html.twig file as the default format for all author pages. I need to iterate over all others in site.yaml and see if it matches page.header.author. I’ve tried
{% for author in site.author if author == page.header.author %}
Which does not work and shows nothing. If I leave out the “if author == page.header.author” section, the for loop does iterate, but it iterates 4 times even though I only have 2 author entries in site.yaml. I’ve also tried
{% if page.header.author in site.author %}
Which doesn’t work and probably shouldn’t lol. Basically I’m trying to loop over all entries in the author section of site.yaml and compare it to the author in the header of a page. If I can loop over entires in the author section of site.yaml I could also take care of selecting an author for each page using the same. Does anyone know how to go about doing this? How do you iterate over something in site.yaml. Is there an alternative way to achieve what I’m trying to do? Am I making this way more complicated than it needs to be?