mirror of
https://github.com/jgonyea/grav-plugin-podcast.git
synced 2025-12-05 16:00:02 +01:00
57 lines
3.2 KiB
Twig
57 lines
3.2 KiB
Twig
{# Need to find if we're at the channel or a series page #}
|
|
{% if page.name == 'podcast-channel.md' %}
|
|
{% set channel = page %}
|
|
{% elseif page.name == 'podcast-series.md' %}
|
|
{% set channel = page.parent %}
|
|
{% endif %}
|
|
{% if channel %}
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
|
|
<channel>
|
|
<title>{{ channel.title }}</title>
|
|
<link>{{ header.podcast.link }}</link>
|
|
<language>{{ channel.header.podcast.channelLanguage }}</language>
|
|
<copyright>{{ channel.header.podcast.copyright }}</copyright>
|
|
<itunes:subtitle>{{ channel.header.podcast.itunes.subtitle }}</itunes:subtitle>
|
|
<itunes:author>{{ channel.header.podcast.itunes.author }}</itunes:author>
|
|
<itunes:summary>{{ (channel.content ? channel.content : channel.header.podcast.description)|striptags }}</itunes:summary>
|
|
<description>{{ channel.header.podcast.description|striptags }}</description>
|
|
<itunes:owner>
|
|
<itunes:name>{{ channel.header.podcast.itunes.owner.name }}</itunes:name>
|
|
<itunes:email>{{ channel.header.podcast.itunes.owner.email }}</itunes:email>
|
|
</itunes:owner>
|
|
<itunes:image href="{{ base_url_absolute}}/{{ ((channel.header.podcast.itunes.image)|first.path) }}"/>
|
|
<itunes:category text="{{ channel.header.podcast.itunes.category }}">
|
|
<itunes:category text="{{ channel.header.podcast.itunes.subcategory }}"/>
|
|
</itunes:category>
|
|
<itunes:explicit>{{ channel.header.podcast.itunes.explicit }}</itunes:explicit>
|
|
{% set episodes = page.collection({ 'items': '@self.descendants', 'order': {'by': 'date', 'dir': 'desc'}} ).ofType('podcast-episode') %}
|
|
{% for episode in episodes %}
|
|
{% if episode.header.podcast.audio.meta %}
|
|
<item>
|
|
<title>{{ episode.title }}</title>
|
|
<link>{{ episode.url(true) }}</link>
|
|
{% if episode.header.podcast.episode_number %}
|
|
<itunes:episode>{{ episode.header.podcast.episode_number }}</itunes:episode>
|
|
{% endif %}
|
|
<itunes:author>{{ episode.header.podcast.itunes.author }}</itunes:author>
|
|
<itunes:subtitle>{{ episdoe.header.podcast.subtitle }}</itunes:subtitle>
|
|
<itunes:summary>{{episode.content|striptags|truncate(120, true, " ", "…")}}</itunes:summary>
|
|
<itunes:image href="{{base_url_absolute}}/{{ (episode.header.podcast.itunes.image)|first.path|absolute_url }}"/>
|
|
{% if (episode.header.podcast.audio.remote) %}
|
|
<enclosure length="{{episode.header.podcast.audio.meta.enclosure_length}}" type="{{episode.header.podcast.audio.meta.type}}" url="{{episode.header.podcast.audio.remote}}"/>
|
|
<guid>{{episode.header.podcast.audio.remote}}</guid>
|
|
{% else %}
|
|
<enclosure length="{{episode.header.podcast.audio.meta.enclosure_length}}" type="{{episode.header.podcast.audio.meta.type}}" url="{{base_url_absolute}}/{{episode.header.podcast.audio.meta.guid|absolute_url}}"/>
|
|
<guid>{{base_url_absolute}}/{{episode.header.podcast.audio.meta.guid|absolute_url}}</guid>
|
|
{% endif %}
|
|
<pubDate>{{ episode.header.publish_date ? episode.header.publish_date|date('r') : episode.date|date('r')}}</pubDate>
|
|
<itunes:duration>{{episode.header.podcast.audio.meta.duration}}</itunes:duration>
|
|
<itunes:explicit>{{episode.header.podcast.itunes.explicit}}</itunes:explicit>
|
|
</item>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</channel>
|
|
</rss>
|
|
{% endif %}
|