Files
librodrome/server/api/admin/messages/[id].put.ts
Yvv 9525ed3953
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Bouton PDF par chapitre, badges morceaux améliorés, PDF configurable admin, git sync admin→prod
- 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>
2026-02-28 15:32:38 +01:00

25 lines
855 B
TypeScript

export default defineEventHandler(async (event) => {
const id = Number(getRouterParam(event, 'id'))
if (!id || isNaN(id)) {
throw createError({ statusCode: 400, statusMessage: 'ID invalide' })
}
const body = await readBody<{ text?: string; published?: boolean; author?: string }>(event)
const data = await readYaml<{ messages: any[] }>('messages.yml')
const message = data.messages.find(m => m.id === id)
if (!message) {
throw createError({ statusCode: 404, statusMessage: 'Message non trouvé' })
}
if (body.text !== undefined) message.text = body.text
if (body.published !== undefined) message.published = body.published
if (body.author !== undefined) message.author = body.author
await writeYaml('messages.yml', data)
gitSyncContent(`Mise à jour message #${id}`, ['site/messages.yml'])
return { ok: true }
})