eleventy-plugin-podcaster 2.0.0-alpha.0 → 2.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-podcaster",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.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": {
@@ -21,31 +21,34 @@ export default function (eleventyConfig) {
21
21
  if (!existsSync(episodesDir)) return
22
22
 
23
23
  const episodes = await readdir(episodesDir)
24
- const episodesData = {}
25
- let totalEpisodes = 0
24
+ const episodeData = {}
25
+ let numberOfEpisodes = 0
26
26
  let totalSize = 0
27
27
  let totalDuration = 0
28
28
 
29
29
  for (const episode of episodes) {
30
30
  if (!episode.endsWith('.mp3')) continue
31
31
 
32
- totalEpisodes++
32
+ numberOfEpisodes++
33
33
  const episodePath = path.join(episodesDir, episode)
34
34
  const episodeSize = (await stat(episodePath)).size
35
35
  totalSize += episodeSize
36
36
  const episodeMetadata = await parseFile(episodePath, { duration: true })
37
37
  const episodeDuration = episodeMetadata.format.duration
38
38
  totalDuration += episodeDuration
39
- episodesData[episode] = {
39
+ episodeData[episode] = {
40
40
  size: episodeSize,
41
- duration: episodeDuration
41
+ duration: Math.round(episodeDuration * 1000) / 1000
42
42
  }
43
+ totalDuration = Math.round(totalDuration * 1000) / 1000
43
44
  }
45
+ const podcastData = { numberOfEpisodes, totalSize, totalDuration }
44
46
 
45
47
  const dataDir = path.join(process.cwd(), directories.data)
46
- await writeFile(path.join(dataDir, 'episodeData.json'), JSON.stringify(episodesData, null, 2))
48
+ await writeFile(path.join(dataDir, 'episodeData.json'), JSON.stringify(episodeData, null, 2))
49
+ await writeFile(path.join(dataDir, 'podcastData.json'), JSON.stringify(podcastData, null, 2))
47
50
 
48
- console.log(chalk.yellow(`${totalEpisodes} episodes; ${hr.fromBytes(totalSize)}; ${convertSecondsToReadableDuration(totalDuration)}.`))
51
+ console.log(chalk.yellow(`${numberOfEpisodes} episodes; ${hr.fromBytes(totalSize)}; ${convertSecondsToReadableDuration(totalDuration)}.`))
49
52
  })
50
53
 
51
54
  const filenameSeasonAndEpisodePattern =