eleventy-plugin-podcaster 1.2.1 → 1.4.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.
@@ -93,14 +93,18 @@ export default function (eleventyConfig, options = {}) {
93
93
  })
94
94
  }
95
95
 
96
- eleventyConfig.addFilter('readableDuration', function (seconds) {
96
+ eleventyConfig.addFilter('readableDuration', (seconds, omitLeadingZero) => {
97
97
  if (!seconds) return '0:00:00'
98
-
98
+ if (omitLeadingZero && seconds < 3600) {
99
+ return Duration.fromMillis(seconds * 1000).toFormat('mm:ss')
100
+ }
99
101
  return Duration.fromMillis(seconds * 1000).toFormat('h:mm:ss')
100
102
  })
101
103
 
102
- eleventyConfig.addFilter('readableSize', bytes =>
103
- hr.fromBytes(bytes)
104
+ eleventyConfig.addFilter('readableSize', (bytes, fixedPrecision) =>
105
+ (fixedPrecision)
106
+ ? hr.fromBytes(bytes, { fixedPrecision })
107
+ : hr.fromBytes(bytes)
104
108
  )
105
109
 
106
110
  const podcastFeedPath = path.join(import.meta.dirname, './src/podcastFeed.njk')
@@ -112,6 +116,20 @@ export default function (eleventyConfig, options = {}) {
112
116
  }
113
117
  })
114
118
 
119
+ if (options.handleEpisodePermalinks) {
120
+ eleventyConfig.addGlobalData('eleventyComputed.permalink', () => {
121
+ return data => {
122
+ if (data.tags?.includes('podcastEpisode')) {
123
+ if (data.episode?.seasonNumber) {
124
+ return `/s${data.episode.seasonNumber}/e${data.episode.episodeNumber}/`
125
+ } else {
126
+ return `/${data.episode.episodeNumber}/`
127
+ }
128
+ }
129
+ }
130
+ })
131
+ }
132
+
115
133
  eleventyConfig.addPlugin(calculateFilenameSizeAndDuration, options)
116
134
  eleventyConfig.addPlugin(excerpts, options)
117
135
  eleventyConfig.addPlugin(drafts, options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-podcaster",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
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": {
@@ -8,7 +8,8 @@ import chalk from 'chalk'
8
8
 
9
9
  const convertSecondsToReadableDuration = seconds =>
10
10
  Duration.fromMillis(seconds * 1000)
11
- .toFormat("d 'd' h 'h' m 'm' s.SSS 's'")
11
+ .shiftTo('days', 'hours', 'minutes', 'seconds')
12
+ .toHuman()
12
13
 
13
14
  export default function (eleventyConfig, options = {}) {
14
15
  let firstRun = true