Features added: - Database schema for pages and media files with content types (Rich Text, HTML, Markdown) - Admin API routes for full page CRUD operations - Image upload functionality with file management - Rich text editor using TinyMCE with image insertion - Admin interface for creating/editing pages with SEO options - Dynamic navigation and footer integration - Public page display routes with proper SEO metadata - Support for featured images and content excerpts Admin features: - Create/edit/delete pages with rich content editor - Upload and manage images through media library - Configure pages to appear in navigation or footer - Set page status (Draft, Published, Archived) - SEO title and description management - Real-time preview of content changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
136 lines
3.3 KiB
TypeScript
136 lines
3.3 KiB
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
const keyMap: Record<string, string> = {
|
|
// OT
|
|
'geneza': 'genesis',
|
|
'exodul': 'exodus',
|
|
'leviticul': 'leviticus',
|
|
'numerii': 'numbers',
|
|
'numeri': 'numbers',
|
|
'deuteronomul': 'deuteronomy',
|
|
'deuteronom': 'deuteronomy',
|
|
'iosua': 'joshua',
|
|
'judecătorii': 'judges',
|
|
'judecători': 'judges',
|
|
'judecatori': 'judges',
|
|
'rut': 'ruth',
|
|
'1 samuel': '1_samuel',
|
|
'2 samuel': '2_samuel',
|
|
'1 împăraţi': '1_kings',
|
|
'2 împăraţi': '2_kings',
|
|
'1 imparati': '1_kings',
|
|
'2 imparati': '2_kings',
|
|
'1 cronici': '1_chronicles',
|
|
'2 cronici': '2_chronicles',
|
|
'ezra': 'ezra',
|
|
'neemia': 'nehemiah',
|
|
'estera': 'esther',
|
|
'iov': 'job',
|
|
'psalmii': 'psalms',
|
|
'proverbele': 'proverbs',
|
|
'proverbe': 'proverbs',
|
|
'eclesiastul': 'ecclesiastes',
|
|
'ecclesiastul': 'ecclesiastes',
|
|
'cântarea cântărilor': 'song_of_songs',
|
|
'cantarea cantarilor': 'song_of_songs',
|
|
'isaia': 'isaiah',
|
|
'ieremia': 'jeremiah',
|
|
'plângerile': 'lamentations',
|
|
'plangerile': 'lamentations',
|
|
'plângerile lui ieremia': 'lamentations',
|
|
'ezechiel': 'ezekiel',
|
|
'daniel': 'daniel',
|
|
'osea': 'hosea',
|
|
'ioel': 'joel',
|
|
'amos': 'amos',
|
|
'obadia': 'obadiah',
|
|
'iona': 'jonah',
|
|
'mica': 'micah',
|
|
'naum': 'nahum',
|
|
'habacuc': 'habakkuk',
|
|
'ţefania': 'zephaniah',
|
|
'țefania': 'zephaniah',
|
|
'tefania': 'zephaniah',
|
|
'hagai': 'haggai',
|
|
'zaharia': 'zechariah',
|
|
'maleahi': 'malachi',
|
|
// NT
|
|
'matei': 'matthew',
|
|
'marcu': 'mark',
|
|
'luca': 'luke',
|
|
'ioan': 'john',
|
|
'faptele apostolilor': 'acts',
|
|
'romani': 'romans',
|
|
'1 corinteni': '1_corinthians',
|
|
'2 corinteni': '2_corinthians',
|
|
'galateni': 'galatians',
|
|
'efeseni': 'ephesians',
|
|
'filipeni': 'philippians',
|
|
'coloseni': 'colossians',
|
|
'1 tesaloniceni': '1_thessalonians',
|
|
'2 tesaloniceni': '2_thessalonians',
|
|
'1 timotei': '1_timothy',
|
|
'2 timotei': '2_timothy',
|
|
'tit': 'titus',
|
|
'titus': 'titus',
|
|
'filimon': 'philemon',
|
|
'evrei': 'hebrews',
|
|
'iacov': 'james',
|
|
'iacob': 'james',
|
|
'1 petru': '1_peter',
|
|
'2 petru': '2_peter',
|
|
'1 ioan': '1_john',
|
|
'2 ioan': '2_john',
|
|
'3 ioan': '3_john',
|
|
'iuda': 'jude',
|
|
'apocalipsa': 'revelation',
|
|
'revelaţia': 'revelation',
|
|
'revelația': 'revelation',
|
|
}
|
|
|
|
function toCanonicalBookKey(name: string): string {
|
|
const k = name.trim().toLowerCase()
|
|
return keyMap[k] || k.replace(/\s+/g, '_')
|
|
}
|
|
|
|
async function main() {
|
|
try {
|
|
const roVersion = await prisma.bibleVersion.findFirst({
|
|
where: { language: { in: ['ro', 'RO'] } }
|
|
})
|
|
if (!roVersion) {
|
|
throw new Error('No Romanian BibleVersion found (language ro)')
|
|
}
|
|
|
|
const books = await prisma.bibleBook.findMany({
|
|
where: { versionId: roVersion.id },
|
|
orderBy: { orderNum: 'asc' }
|
|
})
|
|
|
|
let updated = 0
|
|
for (const b of books) {
|
|
const desiredKey = toCanonicalBookKey(b.name)
|
|
if (b.bookKey !== desiredKey) {
|
|
await prisma.bibleBook.update({
|
|
where: { id: b.id },
|
|
data: { bookKey: desiredKey }
|
|
})
|
|
updated++
|
|
console.log(`Updated ${b.name}: ${b.bookKey} -> ${desiredKey}`)
|
|
}
|
|
}
|
|
|
|
console.log(`Resync complete. Updated ${updated} book keys for RO.`)
|
|
} catch (err) {
|
|
console.error('Resync failed:', err)
|
|
process.exit(1)
|
|
} finally {
|
|
await prisma.$disconnect()
|
|
}
|
|
}
|
|
|
|
main()
|
|
|