Messages : types, réponses, sauts de ligne, data volume
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- HomeMessages : type pill (Réaction/Question/Suggestion/Retour) + sélecteur dans le formulaire (sans Réaction) - HomeMessages : white-space: pre-line sur les messages - Page /messages : type pill + white-space: pre-line (idem home) - Admin : badge type coloré + sélecteur d'édition + formulaire réponse - API : type et reply dans PUT ; readDataYaml/writeDataYaml (data/ volume Docker) - main.css : overrides light mode text-white/55, /75, /90 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,24 +1,28 @@
|
||||
const EMPTY = { messages: [] as any[] }
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<{ author: string; email?: string; text: string }>(event)
|
||||
const body = await readBody<{ author: string; email?: string; text: string; type?: string }>(event)
|
||||
|
||||
if (!body.text?.trim()) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Message requis' })
|
||||
}
|
||||
|
||||
const data = await readYaml<{ messages: any[] }>('messages.yml')
|
||||
const data = await readDataYaml<{ messages: any[] }>('messages.yml', EMPTY)
|
||||
|
||||
const maxId = data.messages.reduce((max, m) => Math.max(max, m.id || 0), 0)
|
||||
|
||||
data.messages.push({
|
||||
id: maxId + 1,
|
||||
author: body.author.trim(),
|
||||
author: body.author?.trim() || 'Anonyme',
|
||||
email: body.email?.trim() || '',
|
||||
text: body.text.trim(),
|
||||
type: body.type || 'reaction',
|
||||
published: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
reply: null,
|
||||
})
|
||||
|
||||
await writeYaml('messages.yml', data)
|
||||
await writeDataYaml('messages.yml', data)
|
||||
|
||||
return { ok: true }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user