Add "More podcast episodes with..." block
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.
This commit is contained in:
parent
e1c216fa91
commit
076802cb5b
27 changed files with 55 additions and 0 deletions
22
source/_includes/podcast/other-episodes.html.twig
Normal file
22
source/_includes/podcast/other-episodes.html.twig
Normal file
|
@ -0,0 +1,22 @@
|
|||
{% 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 %}
|
Loading…
Add table
Add a link
Reference in a new issue