All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Bouton PDF blanc par chapitre avec numéro de page (ChapterHeader) - Badges morceaux plus visibles (bordure, poids, hover) dans ChapterHeader et SongBadges - PDF viewer : page cible + panneau signets ouverts par défaut (BookPdfReader) - Config YAML : pdfFile dans book, chapterPages pour le mapping chapitre→page - Admin book : section PDF du livre avec chemin éditable et sauvegarde - Git sync automatique : chaque sauvegarde admin commit+push en prod (ADMIN_GIT_SYNC=true) - Docker : git installé en prod, volumes pour .git/site/content/public Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
799 B
TypeScript
25 lines
799 B
TypeScript
import { writeFile } from 'node:fs/promises'
|
|
import { join } from 'node:path'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const slug = getRouterParam(event, 'slug')
|
|
|
|
if (!slug || !/^[a-z0-9-]+$/.test(slug)) {
|
|
throw createError({ statusCode: 400, statusMessage: 'Invalid slug' })
|
|
}
|
|
|
|
const body = await readBody<{ frontmatter: string; body: string }>(event)
|
|
|
|
if (!body?.frontmatter && !body?.body) {
|
|
throw createError({ statusCode: 400, statusMessage: 'Missing content' })
|
|
}
|
|
|
|
const filePath = join(process.cwd(), 'content', 'book', `${slug}.md`)
|
|
const content = `---\n${body.frontmatter.trim()}\n---\n${body.body}`
|
|
|
|
await writeFile(filePath, content, 'utf-8')
|
|
gitSyncContent(`Mise à jour chapitre ${slug}`, [`content/book/${slug}.md`])
|
|
|
|
return { ok: true }
|
|
})
|