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>
32 lines
915 B
TypeScript
32 lines
915 B
TypeScript
import { readFile, writeFile } from 'node:fs/promises'
|
|
import { join } from 'node:path'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const body = await readBody<{ chapters: { slug: string; order: number }[] }>(event)
|
|
|
|
if (!body?.chapters || !Array.isArray(body.chapters)) {
|
|
throw createError({ statusCode: 400, statusMessage: 'Missing chapters array' })
|
|
}
|
|
|
|
const bookDir = join(process.cwd(), 'content', 'book')
|
|
|
|
await Promise.all(
|
|
body.chapters.map(async ({ slug, order }) => {
|
|
const filePath = join(bookDir, `${slug}.md`)
|
|
const raw = await readFile(filePath, 'utf-8')
|
|
|
|
// Replace order in frontmatter
|
|
const updated = raw.replace(
|
|
/^(---\n[\s\S]*?)order:\s*\d+/,
|
|
`$1order: ${order}`,
|
|
)
|
|
|
|
await writeFile(filePath, updated, 'utf-8')
|
|
}),
|
|
)
|
|
|
|
gitSyncContent('Réorganisation chapitres', ['content/book/'])
|
|
|
|
return { ok: true }
|
|
})
|