mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig.space.git
synced 2025-12-13 16:26:50 +00:00
🛠 Podcast eepisode pages
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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 }))
|
||||
|
||||
Reference in New Issue
Block a user