From 9dfeb7ac4e30d2e1cf2a6267d4c4cd26cc5ef85f Mon Sep 17 00:00:00 2001 From: JP Hastings-Spital Date: Sat, 1 Feb 2025 10:51:20 +0000 Subject: [PATCH] IMprove XSL and podcast XML --- layouts/_default/list.podcast.xml | 5 ++++- layouts/shortcodes/podcast.html | 2 ++ static/rss.xsl | 35 ++++++++++++++++++++++++------- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/layouts/_default/list.podcast.xml b/layouts/_default/list.podcast.xml index 3921b960..bc9fbd60 100644 --- a/layouts/_default/list.podcast.xml +++ b/layouts/_default/list.podcast.xml @@ -6,7 +6,7 @@ {{- end -}} {{- printf "" | safeHTML }} {{- printf "" | safeHTML }} - + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} {{ .Permalink | absURL }} @@ -19,6 +19,9 @@ {{ "profile-512.jpg" | absURL }}{{ with .Site.Copyright }} {{.}}{{end}}{{ if not .Date.IsZero }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{- with .OutputFormats.Get "Podcast" -}} + {{ printf "" (.Permalink | absURL) .MediaType | safeHTML }} + {{- end -}} {{- range $i, $page := $pages -}} {{- if not .Page.Params.Audio -}}{{ continue }}{{- end -}} {{ with .Title }} diff --git a/layouts/shortcodes/podcast.html b/layouts/shortcodes/podcast.html index 1fbf1af0..d3bab66a 100644 --- a/layouts/shortcodes/podcast.html +++ b/layouts/shortcodes/podcast.html @@ -9,11 +9,13 @@ const title = xmlDoc.querySelector('channel title')?.textContent const link = xmlDoc.querySelector('channel link')?.textContent const description = xmlDoc.querySelector('channel description')?.textContent + const image = xmlDoc.querySelector('channel image')?.textContent const tracks = [...xmlDoc.querySelectorAll('channel item')].map((item) => ({ title: item.querySelector('title')?.textContent, link: item.querySelector('link')?.textContent, artist: title, src: item.querySelector('enclosure[type^="audio/"]')?.getAttribute('url'), + cover: image, })).filter((track) => !!track.src) return { diff --git a/static/rss.xsl b/static/rss.xsl index 9241609c..63f334e6 100644 --- a/static/rss.xsl +++ b/static/rss.xsl @@ -1,5 +1,5 @@ - + @@ -79,12 +79,33 @@

- - - - - Visit this page on my site → - +

Recent Posts