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
@@ -10,7 +10,7 @@ Plenty of services exist that will host your podcast online — [Spotify][], [Ac
10
10
  [Buzzsprout]: https://www.buzzsprout.com
11
11
  [Blubrry]: https://blubrry.com
12
12
 
13
- But **Podcaster** will.
13
+ But Eleventy and **Podcaster** will.
14
14
 
15
15
  ## Installation
16
16
 
@@ -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 calculateSizeAndDuration from './src/calculateSizeAndDuration.js'
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
- eleventyConfig.addGlobalData('eleventyComputed.podcast.copyrightNotice', () => {
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(calculateSizeAndDuration, options)
115
+ eleventyConfig.addPlugin(calculateFilenameSizeAndDuration, options)
106
116
  eleventyConfig.addPlugin(excerpts, options)
107
117
  eleventyConfig.addPlugin(drafts, options)
108
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-podcaster",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "An Eleventy plugin that allows you to create a podcast and its accompanying website",
5
5
  "main": "eleventy.config.js",
6
6
  "exports": {
@@ -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
@@ -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 isPermalink="false">{{ post.data.guid }}</guid>
58
+ <guid isPermaLink="false">{{ post.data.guid }}</guid>
59
59
  {% else %}
60
- <guid isPermalink="true">{{ post.url | htmlBaseUrl(siteUrl) }}</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('&amp;', '&') %}
67
68
  {% elif post.data.episode.description %}
68
69
  {%- set episodeDescription = post.data.episode.description -%}
69
70
  {% else %}