If a guest has been on multiple podcast episodes, show a list on an episode page linking to their other episodes. For this to work, each page needs `data.podcast_episodes` to be in scope, so `use: [podcast_episodes]` needs to be added to the episode. Whilst I could do this only for the specific episodes, adding it to all the episodes will make it clearer in the future that I need to have it instead of forgetting to add it and wondering why it doesn't work.
23 lines
600 B
Twig
23 lines
600 B
Twig
{% set other_episodes = [] %}
|
|
|
|
{% for episode in all_episodes %}
|
|
{% if episode.guests|first is same as(guest) and episode.topic is not same as(topic) %}
|
|
{% set other_episodes = other_episodes|merge([episode]) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if other_episodes is not empty %}
|
|
<section>
|
|
<h2>Other episodes with {{ guest }}</h2>
|
|
|
|
<ul>
|
|
{% for episode in other_episodes %}
|
|
<li>
|
|
<a href="{{ episode.url|trim('/', 'right') }}">{{ episode.topic }}</a>
|
|
- {{ episode.date|date('jS F Y') }}
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</section>
|
|
{% endif %}
|