Make Podcast RSS feed work with remote files.

This commit is contained in:
Fredrik Jonsson 2021-02-02 09:58:01 +01:00
commit 62c7a1d204
2 changed files with 5 additions and 0 deletions

View file

@ -214,6 +214,7 @@ params:
type: episodic/serial # Podcast type, defaults to episodic (iTunes).
newfeed: # Are you moving? Set the new feed url here (iTunes).
cdn: # CDN url, no slash on end (https://cdn.example.org).
local: false # Are the audio files local (true) or remote (false), default to true.
preload: none/metadata/auto # Set on the HTML5 audio tag, defaults to "metadata".
```

View file

@ -50,7 +50,11 @@
<author>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</author>
{{ end -}}
<description>{{ .Content | html }}</description>
{{ if $.Site.Params.Podcast.local | default true -}}
{{ with .Params.podcast.mp3 }}{{ $file_stat := os.Stat (add "/static" (. | relURL)) }}<enclosure url="{{ if $.Site.Params.Podcast.cdn }}{{ add $.Site.Params.Podcast.cdn (. | relURL) }}{{ else }}{{ . | absURL }}{{ end }}" length="{{ $file_stat.Size }}" type="audio/mpeg" />{{ end }}
{{ else -}}
{{ with .Params.podcast.mp3 }}<enclosure url="{{ if $.Site.Params.Podcast.cdn }}{{ add $.Site.Params.Podcast.cdn (. | relURL) }}{{ else }}{{ . | absURL }}{{ end }}" type="audio/mpeg" />{{ end }}
{{ end -}}
{{ with .Params.podcast.duration }}<itunes:duration>{{ . }}</itunes:duration>{{ end }}
{{ with .Params.podcast.image.src }}{{ $image := resources.Get . }}<itunes:image href="{{ $image.Permalink }}" />{{ end }}
{{ with .Params.podcast.episode }}<itunes:episode>{{ . }}</itunes:episode>{{ end }}