eleventy-plugin-podcaster 1.1.0 → 1.2.1
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
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
|
@@ -55,15 +55,16 @@ eleventyAllowMissingExtension: true
|
|
|
55
55
|
{%- endif %}
|
|
56
56
|
<link>{{ post.url | htmlBaseUrl(siteUrl) }}</link>
|
|
57
57
|
{%- if post.data.guid != undefined %}
|
|
58
|
-
<guid
|
|
58
|
+
<guid isPermaLink="false">{{ post.data.guid }}</guid>
|
|
59
59
|
{% else %}
|
|
60
|
-
<guid
|
|
60
|
+
<guid isPermaLink="true">{{ post.url | htmlBaseUrl(siteUrl) }}</guid>
|
|
61
61
|
{% endif -%}
|
|
62
62
|
<pubDate>{{ post.date | dateToRfc3339 }}</pubDate>
|
|
63
63
|
{% if podcast.episodeDescriptionTemplate %}
|
|
64
64
|
{%- set episodeDescription -%}
|
|
65
65
|
{% include podcast.episodeDescriptionTemplate %}
|
|
66
66
|
{%- endset -%}
|
|
67
|
+
{%- set episodeDescription = episodeDescription | replace('&', '&') %}
|
|
67
68
|
{% elif post.data.episode.description %}
|
|
68
69
|
{%- set episodeDescription = post.data.episode.description -%}
|
|
69
70
|
{% else %}
|