eleventy-plugin-podcaster 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -45,3 +45,6 @@ Detailed and specific information about how to install and use **Podcaster** can
|
|
|
45
45
|
**Podcaster** is an Eleventy plugin. You install it in your config file in the usual way. You usually provide it with information about your podcast — like its title, description and category — by creating a `podcast.json` file in the data directory. For each episode, you create a template with information in the front matter about that episode — its name, release date, filename, duration and so on.
|
|
46
46
|
|
|
47
47
|
Once you do this, **Podcaster** can create the RSS feed for your podcast. You can also create templates for various pages on your website and include on those pages the information you have provided about the podcast and its episodes.
|
|
48
|
+
|
|
49
|
+
> [!WARNING]
|
|
50
|
+
> **Podcaster** only works with Node 20 and later.
|
package/eleventy.config.js
CHANGED
|
@@ -3,7 +3,7 @@ import hr from '@tsmx/human-readable'
|
|
|
3
3
|
import rssPlugin from '@11ty/eleventy-plugin-rss'
|
|
4
4
|
import { readFileSync } from 'node:fs'
|
|
5
5
|
import path from 'node:path'
|
|
6
|
-
import
|
|
6
|
+
import calculateFilenameSizeAndDuration from './src/calculateFilenameSizeAndDuration.js'
|
|
7
7
|
import excerpts from './src/excerpts.js'
|
|
8
8
|
import drafts from './src/drafts.js'
|
|
9
9
|
|
|
@@ -26,7 +26,7 @@ export default function (eleventyConfig, options = {}) {
|
|
|
26
26
|
return data => data.podcast.imagePath || '/img/podcast-logo.jpg'
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
function calculateCopyrightNotice () {
|
|
30
30
|
return data => {
|
|
31
31
|
const thisYear = DateTime.now().year
|
|
32
32
|
let yearRange
|
|
@@ -37,7 +37,17 @@ export default function (eleventyConfig, options = {}) {
|
|
|
37
37
|
}
|
|
38
38
|
return `© ${yearRange} ${data.podcast.copyright || data.podcast.author}`
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
eleventyConfig.addGlobalData(
|
|
43
|
+
'eleventyComputed.podcast.copyrightNotice',
|
|
44
|
+
calculateCopyrightNotice
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
eleventyConfig.addGlobalData(
|
|
48
|
+
'eleventyComputed.copyrightNotice',
|
|
49
|
+
calculateCopyrightNotice
|
|
50
|
+
)
|
|
41
51
|
|
|
42
52
|
eleventyConfig.addGlobalData(
|
|
43
53
|
'podcast.feedLastBuildDate',
|
|
@@ -102,7 +112,7 @@ export default function (eleventyConfig, options = {}) {
|
|
|
102
112
|
}
|
|
103
113
|
})
|
|
104
114
|
|
|
105
|
-
eleventyConfig.addPlugin(
|
|
115
|
+
eleventyConfig.addPlugin(calculateFilenameSizeAndDuration, options)
|
|
106
116
|
eleventyConfig.addPlugin(excerpts, options)
|
|
107
117
|
eleventyConfig.addPlugin(drafts, options)
|
|
108
118
|
}
|
package/package.json
CHANGED
|
@@ -48,6 +48,29 @@ export default function (eleventyConfig, options = {}) {
|
|
|
48
48
|
console.log(chalk.yellow(`${totalEpisodes} episodes; ${hr.fromBytes(totalSize)}; ${convertSecondsToReadableDuration(totalDuration)}.`))
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
+
if (options.episodeFilenamePattern) {
|
|
52
|
+
eleventyConfig.addGlobalData('eleventyComputed.episode.filename', () => {
|
|
53
|
+
return data => {
|
|
54
|
+
if (data.episode.filename) return data.episode.filename
|
|
55
|
+
|
|
56
|
+
if (data.tags?.includes('podcastEpisode') && data.episodesData) {
|
|
57
|
+
for (const file of Object.keys(data.episodesData)) {
|
|
58
|
+
const match = file.match(options.episodeFilenamePattern)
|
|
59
|
+
const matchedSeasonNumber = parseInt(match?.groups.seasonNumber)
|
|
60
|
+
const matchedEpisodeNumber = parseInt(match?.groups.episodeNumber)
|
|
61
|
+
if (isNaN(matchedSeasonNumber) && matchedEpisodeNumber ===
|
|
62
|
+
data.episode.episodeNumber) {
|
|
63
|
+
return file
|
|
64
|
+
} else if (matchedSeasonNumber === data.episode.seasonNumber &&
|
|
65
|
+
matchedEpisodeNumber === data.episode.episodeNumber) {
|
|
66
|
+
return file
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
51
74
|
eleventyConfig.addGlobalData('eleventyComputed.episode.size', () => {
|
|
52
75
|
return data => {
|
|
53
76
|
if (data.episode.size) return data.episode.size
|
package/src/podcastFeed.njk
CHANGED
|
@@ -50,6 +50,9 @@ eleventyAllowMissingExtension: true
|
|
|
50
50
|
{% for post in collections.podcastEpisode | reverse %}
|
|
51
51
|
<item>
|
|
52
52
|
<title>{{ post.data.episode.title or post.data.title }}</title>
|
|
53
|
+
{% if post.data.episode.itunesTitle %}
|
|
54
|
+
<itunes:title>{{ post.data.episode.itunesTitle }}</title>
|
|
55
|
+
{%- endif %}
|
|
53
56
|
<link>{{ post.url | htmlBaseUrl(siteUrl) }}</link>
|
|
54
57
|
{%- if post.data.guid != undefined %}
|
|
55
58
|
<guid isPermalink="false">{{ post.data.guid }}</guid>
|
|
@@ -61,10 +64,11 @@ eleventyAllowMissingExtension: true
|
|
|
61
64
|
{%- set episodeDescription -%}
|
|
62
65
|
{% include podcast.episodeDescriptionTemplate %}
|
|
63
66
|
{%- endset -%}
|
|
67
|
+
{%- set episodeDescription = episodeDescription | replace('&', '&') %}
|
|
64
68
|
{% elif post.data.episode.description %}
|
|
65
69
|
{%- set episodeDescription = post.data.episode.description -%}
|
|
66
70
|
{% else %}
|
|
67
|
-
{%- set episodeDescription = post.content | striptags(true) | truncate(800) -%}
|
|
71
|
+
{%- set episodeDescription = post.content | safe | striptags(true) | truncate(800) -%}
|
|
68
72
|
{%- endif %}
|
|
69
73
|
<description>{{ episodeDescription | trim }}</description>
|
|
70
74
|
<itunes:summary>{{ episodeDescription | trim }}</itunes:summary>
|