56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
const PODCAST_DIR = path.join(process.cwd(), 'content', 'podcast')
|
|
const POSTS_DIR = path.join(process.cwd(), 'content', 'posts')
|
|
|
|
const podFiles = fs.readdirSync(PODCAST_DIR).filter(f => f.startsWith('ep-') && f.endsWith('.yaml')).sort()
|
|
|
|
// Define known commercial posts that already exist for specific episodes
|
|
const commercialPostsMap = {
|
|
'ep-001-systemprompt-und-prompting.yaml': '2025-11-21-eigentlich-muesste-ich-heute-etwas-ueber-den-omnibus-und-die-drohende-erosion-de.md'
|
|
}
|
|
|
|
podFiles.forEach(pf => {
|
|
const filepath = path.join(PODCAST_DIR, pf)
|
|
const content = fs.readFileSync(filepath, 'utf8')
|
|
|
|
const titleMatch = content.match(/^title:\s*"?(.+?)"?$/m)
|
|
const dateMatch = content.match(/^date:\s*(.+)$/m)
|
|
|
|
if (!titleMatch || !dateMatch) return
|
|
|
|
const title = titleMatch[1]
|
|
const date = dateMatch[1]
|
|
|
|
// If we have a known commercial post, skip
|
|
if (commercialPostsMap[pf]) {
|
|
console.log(`Skipping ${pf} (has commercial post)`)
|
|
return
|
|
}
|
|
|
|
// Create filename for new post
|
|
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '')
|
|
const postFilename = `${date}-${slug}.md`
|
|
const postFilepath = path.join(POSTS_DIR, postFilename)
|
|
|
|
if (!fs.existsSync(postFilepath)) {
|
|
const postContent = `---
|
|
title: '${title.replace(/'/g, "''")}'
|
|
date: ${date}
|
|
---
|
|
|
|
Eine neue Episode des **Almost Intelligent** Podcasts ist online!
|
|
|
|
🎙️ **Thema:** ${title.replace(/^\d{3}:\s*/, '')}
|
|
|
|
Hört euch die komplette Folge auf unserer [Podcast-Seite](/podcast) an!
|
|
`
|
|
fs.writeFileSync(postFilepath, postContent)
|
|
console.log(`Created article for ${pf}: ${postFilename}`)
|
|
} else {
|
|
console.log(`Article already exists for ${pf}`)
|
|
}
|
|
})
|
|
|