eleventy-plugin-podcaster 2.1.0 → 2.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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npx ava:*)"
5
+ ]
6
+ }
7
+ }
@@ -5,7 +5,7 @@ import podcastData from './src/podcastData.js'
5
5
  import episodeData from './src/episodeData.js'
6
6
  import calculateEpisodeSizeAndDuration from './src/calculateEpisodeSizeAndDuration.js'
7
7
  import calculateEpisodeFilename from './src/calculateEpisodeFilename.js'
8
-
8
+ import validation from './src/validation.js'
9
9
  import readableFilters from './src/readableFilters.js'
10
10
  import chapters from './src/chapters.js'
11
11
  import excerpts from './src/excerpts.js'
@@ -23,6 +23,7 @@ export default function (eleventyConfig, options = {}) {
23
23
  eleventyConfig.addPlugin(episodeData, options)
24
24
  eleventyConfig.addPlugin(calculateEpisodeSizeAndDuration, options)
25
25
  eleventyConfig.addPlugin(calculateEpisodeFilename, options)
26
+ eleventyConfig.addPlugin(validation, options)
26
27
 
27
28
  // Filters
28
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-podcaster",
3
- "version": "2.1.0",
3
+ "version": "2.2.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": {
@@ -1,4 +1,4 @@
1
- export default function (eleventyConfig) {
1
+ export default function (eleventyConfig, options = {}) {
2
2
  eleventyConfig.addGlobalData('eleventyComputed.podcast.feedPath', () => {
3
3
  return data => data.podcast.feedPath || '/feed/podcast.xml'
4
4
  })
@@ -10,10 +10,8 @@ export default function (eleventyConfig) {
10
10
  eleventyConfig.addGlobalData('eleventyComputed.podcast.episodeUrlBase', () => {
11
11
  return data => {
12
12
  if (data.podcast.episodeUrlBase) return data.podcast.episodeUrlBase
13
- let siteUrl
14
- try {
15
- siteUrl = data.podcast.siteUrl || data.site.url
16
- } catch (e) {
13
+ const siteUrl = data.podcast.siteUrl || data.site?.url
14
+ if (!siteUrl && !options.validation) {
17
15
  console.error('[eleventy-plugin-podcaster] No site URL found. Please set `siteUrl` in your podcast data.')
18
16
  }
19
17
  return URL.parse('episodes/', siteUrl)
@@ -5,7 +5,7 @@ import isEpisodePost from './isEpisodePost.js'
5
5
 
6
6
  export default function (eleventyConfig, options = {}) {
7
7
  if (!('addTemplate' in eleventyConfig)) {
8
- console.error('[eleventy-plugin-podcasting] Eleventy plugin compatibility: Virtual Templates are required for this plugin — please use Eleventy v3.0 or newer.')
8
+ console.error('[podcaster] Eleventy plugin compatibility: Virtual Templates are required for this plugin — please use Eleventy v3.0 or newer.')
9
9
  }
10
10
 
11
11
  const podcastFeedPath = path.join(import.meta.dirname, './podcastFeed.njk')
@@ -29,8 +29,10 @@ eleventyAllowMissingExtension: true
29
29
  {%- else %}
30
30
  <itunes:category text="{{ podcast.category }}" />
31
31
  {%- endif %}
32
- {% if podcast.explicit !== undefined %}
33
- <itunes:explicit>{{ podcast.explicit }}</itunes:explicit>
32
+ {% if podcast.explicit == true %}
33
+ <itunes:explicit>true</itunes:explicit>
34
+ {% else %}
35
+ <itunes:explicit>false</itunes:explicit>
34
36
  {% endif -%}
35
37
  <itunes:author>{{ podcast.author }}</itunes:author>
36
38
  {%- if podcast.type %}
@@ -0,0 +1,62 @@
1
+ import isEpisodePost from './isEpisodePost.js'
2
+
3
+ function warn (message) {
4
+ console.warn(`[podcaster] ${message}`)
5
+ }
6
+
7
+ function warnOrThrow (message) {
8
+ if (process.env.ELEVENTY_RUN_MODE === 'build') {
9
+ throw new Error(`[podcaster] ${message}`)
10
+ } else {
11
+ console.warn(`[podcaster] ${message}`)
12
+ }
13
+ }
14
+
15
+ export default function (eleventyConfig, options = {}) {
16
+ eleventyConfig.addGlobalData('eleventyDataSchema', () => {
17
+ return (data) => {
18
+ if (!options.validation) return
19
+
20
+ // podcast data
21
+
22
+ if (!(data.podcast.siteUrl || data.site?.url)) {
23
+ warnOrThrow('Site URL is required')
24
+ }
25
+ if (!data.podcast.title) {
26
+ warnOrThrow('Podcast title is required')
27
+ }
28
+ if (!data.podcast.description) {
29
+ warnOrThrow('Podcast description is required')
30
+ }
31
+ if (!data.podcast.language) {
32
+ warnOrThrow('Podcast language is required')
33
+ }
34
+ if (!data.podcast.category) {
35
+ warnOrThrow('Podcast category is required')
36
+ }
37
+ if (!data.podcast.author) {
38
+ warnOrThrow('Podcast author is required')
39
+ }
40
+
41
+ // episode data
42
+
43
+ if (isEpisodePost(data, options)) {
44
+ if (!data.title) {
45
+ warnOrThrow(`Episode title is required (${data.page.inputPath})`)
46
+ }
47
+ if (!data.episode.filename) {
48
+ warnOrThrow(`Episode filename is required (${data.page.inputPath})`)
49
+ }
50
+ if (!data.episode.size) {
51
+ warnOrThrow(`Episode size is required (${data.page.inputPath})`)
52
+ }
53
+ if (!data.episode.episodeNumber) {
54
+ warn(`Episode number is recommended (${data.page.inputPath})`)
55
+ }
56
+ if (!data.episode.duration) {
57
+ warn(`Episode duration is recommended (${data.page.inputPath})`)
58
+ }
59
+ }
60
+ }
61
+ })
62
+ }