🛠 Podcast eepisode pages

This commit is contained in:
Dennis Reimann
2020-10-05 16:58:31 +02:00
parent 11a56902cb
commit 583dc71677
9 changed files with 36 additions and 22 deletions

View File

@@ -4,15 +4,22 @@ const Parser = require('rss-parser')
const dir = resolve(__dirname, '..', 'generated')
const write = (name, data) => writeFileSync(join(dir, `${name}.json`), JSON.stringify(data, null, 2))
const slugify = str => str.toLowerCase()
.replace('ä', 'ae').replace('ö', 'oe').replace('ü', 'ue')
.replace(/\s+/g, '-').replace(/[^\w\-]+/g, '')
.replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '')
const parseInfo = e => {
const titleMatch = e.title.match(/([\w\s]+?)?\s?#(\d+) - (.*)/)
const [, categoryName = 'News', number, titlePlain] = titleMatch ? titleMatch : [,,,e.title]
const blockMatch = e.contentSnippet.match(/Blockzeit\s(\d+)/)
const block = blockMatch ? parseInt(blockMatch[1]) : null
const category = categoryName.toLowerCase().replace(/\W/, '-')
const category = slugify(categoryName)
const slug = slugify(`${categoryName} ${number} ${titlePlain}`)
return { block, category, categoryName, number, titlePlain }
return { block, category, categoryName, number, titlePlain, slug }
}
;(async () => {

View File

@@ -27,3 +27,5 @@ renderPage('category', 'podcast/news', { navCurrent: 'podcast', categoryName: 'N
renderPage('category', 'podcast/interviews', { navCurrent: 'podcast', categoryName: 'Interviews', episodes: episodes.filter(e => e.category === 'interview') })
renderPage('category', 'podcast/lesestunde', { navCurrent: 'podcast', categoryName: 'Lesestunde', episodes: episodes.filter(e => e.category === 'lesestunde') })
renderPage('category', 'podcast/der-weg', { navCurrent: 'podcast', categoryName: 'Der Weg', episodes: episodes.filter(e => e.category === 'der-weg') })
episodes.forEach(episode => renderPage('episode', `podcast/${episode.slug}`, { navCurrent: 'podcast', episode }))