From 2e26dd2000fd88b9ee172d96aa90ae0bf8abf91a Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Mon, 11 Nov 2024 15:20:03 -0600 Subject: [PATCH] update layouts --- content/feeds/full.njk | 47 -------------------- content/feeds/podcast.11ty.js | 81 ----------------------------------- layouts/podcast.11ty.js | 4 +- 3 files changed, 2 insertions(+), 130 deletions(-) delete mode 100644 content/feeds/full.njk delete mode 100644 content/feeds/podcast.11ty.js diff --git a/content/feeds/full.njk b/content/feeds/full.njk deleted file mode 100644 index 3648913..0000000 --- a/content/feeds/full.njk +++ /dev/null @@ -1,47 +0,0 @@ ---- -permalink: /feeds/full.xml -eleventyExcludeFromCollections: true -metadata: - title: Crew of the Kahuna - subtitle: A FFG Star Wars RPG Story - description: This is an RPG podcast. - language: en - categories: - - Fiction - - Comedy - - Lesiure - - Games ---- - - - - {{ metadata.title }} - {{ site.url | addPathPrefixToFullUrl }} - - {{ metadata.description }} - {{ metadata.language or page.lang }} - {{metadata.subtitle}} - {{site.author.name}} - {%- for category in metadata.categories %} - - {%- endfor %} - - {{ site.author.name }} - {{ site.author.email }} - - - {{eleventy.generator}} - - {%- for post in collections.episode | reverse %} - {%- set absolutePostUrl = post.url | htmlBaseUrl(site.url) %} - {% if post.data.podcast %} - {{ post.data.title }} - {{ absolutePostUrl }} - {{ post.content | renderTransforms(post.data.page, site.url) }} - {{ post.date.toUTCString() | dateToRfc822 }} - {{ absolutePostUrl }} - - {% endif %} - {%- endfor %} - - \ No newline at end of file diff --git a/content/feeds/podcast.11ty.js b/content/feeds/podcast.11ty.js deleted file mode 100644 index 90c2e90..0000000 --- a/content/feeds/podcast.11ty.js +++ /dev/null @@ -1,81 +0,0 @@ -const { Podcast } = require('podcast'); -const music_metadata = require('music-metadata'); -const fs = require('fs'); - -const PODCAST_CDN_ROOT="https://podcast.rpg.cdn.ascorrea.com" - -async function getMp3Duration(filePath) { - try { - const metadata = await music_metadata.parseFile(filePath); - console.log('Duration:', metadata.format.duration, 'seconds'); - return metadata.format.duration; // Duration in seconds - } catch (error) { - console.error('Error reading file:', error.message); - return null; - } -} - -class PodcastFeed { - data() { - return { - // Writes to "/my-permalink/hello/index.html" - permalink: (data) => `${data.page.filePathStem}.xml`, - }; - } - - async render(data) { - const feed = new Podcast({ - title: 'title', - description: 'description', - feedUrl: `${data.site.url}${data.page.filePathStem}.xml`, - siteUrl: data.site.url, - imageUrl: 'http://example.com/icon.png', - author: `${data.site.author.name}`, - copyright: '2013 Dylan Greene', - language: 'en', - categories: ['Category 1','Category 2','Category 3'], - pubDate: 'May 20, 2012 04:00:00 GMT', - ttl: 60, - itunesAuthor: `${data.site.author.name}`, - itunesSubtitle: 'I am a sub title', - itunesSummary: 'I am a summary', - itunesOwner: { name: `${data.site.author.name}`, email: `${data.site.author.email}` }, - itunesExplicit: false, - itunesCategory: [{ - text: 'Entertainment', - subcats: [{ - text: 'Television' - }] - }], - itunesImage: 'http://example.com/image.png' - }); - - data.collections.episode.forEach(episode=>{ - const episode_data = episode.data - const zero_pad_season = episode_data.season.toString().padStart(2, '0') - // const duration = getMp3Duration(`../episodes/s${zero_pad_season}/s${zero_pad_season}e${episode_data.episode}.mp3`) - /* loop over data and add to feed */ - feed.addItem({ - title: `S${zero_pad_season}E${episode_data.episode}: ${episode_data.title}`, - description: episode.content, - url: episode.url, // link to the item - guid: episode.url, // optional - defaults to url - categories: episode_data.categories, - author: data.site.author.name, - date: episode_data.date, // any format that js Date can parse. - // enclosure : {url:`${data.site.url}/episodes/s${zero_pad_season}/s${zero_pad_season}e${episode_data.episode}.mp3`}, // optional enclosure - enclosure : {url:`${PODCAST_CDN_ROOT}/s${zero_pad_season}e${episode_data.episode}.mp3`}, // optional enclosure - itunesAuthor: data.site.author, - itunesExplicit: episode_data.itunesExplicit, - // itunesDuration: duration, - }); - }) - - - // cache the xml to send to clients - const xml = feed.buildXml(); - return xml - } -} - -module.exports = PodcastFeed \ No newline at end of file diff --git a/layouts/podcast.11ty.js b/layouts/podcast.11ty.js index e0fe8e2..54a8321 100644 --- a/layouts/podcast.11ty.js +++ b/layouts/podcast.11ty.js @@ -29,7 +29,7 @@ class PodcastFeed { description: data.description, feedUrl: `${data.site.url}${data.page.filePathStem}.xml`, siteUrl: data.site.url, - imageUrl: 'http://example.com/icon.png', + imageUrl: data.site.imageUrl || `${data.site.url}${data.page.filePathStem}.jpg`, author: data.author || `${data.site.author.name}`, copyright: data.copyright || `${new Date().getFullYear()} ${data.site.author.name}`, language: 'en', @@ -45,7 +45,7 @@ class PodcastFeed { }, itunesExplicit: data.itunes?.explicit || false, itunesCategory: [], - itunesImage: data.itunes?.image || 'http://example.com/image.png' + itunesImage: data.itunes?.image || data.site.imageUrl || `${data.site.url}${data.page.filePathStem}.jpg` }); const episodes = data.collections.episode.filter(episode=>episode.data.podcast==true)