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,3 +1,5 @@
|
||||
const EMPTY = { messages: [] as any[] }
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
|
||||
@@ -5,7 +7,7 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 400, statusMessage: 'ID invalide' })
|
||||
}
|
||||
|
||||
const data = await readYaml<{ messages: any[] }>('messages.yml')
|
||||
const data = await readDataYaml<{ messages: any[] }>('messages.yml', EMPTY)
|
||||
|
||||
const index = data.messages.findIndex(m => m.id === id)
|
||||
if (index === -1) {
|
||||
@@ -13,8 +15,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
data.messages.splice(index, 1)
|
||||
await writeYaml('messages.yml', data)
|
||||
gitSyncContent(`Suppression message #${id}`, ['site/messages.yml'])
|
||||
await writeDataYaml('messages.yml', data)
|
||||
|
||||
return { ok: true }
|
||||
})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const EMPTY = { messages: [] as any[] }
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
|
||||
@@ -5,8 +7,15 @@ export default defineEventHandler(async (event) => {
|
||||
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 body = await readBody<{
|
||||
text?: string
|
||||
published?: boolean
|
||||
author?: string
|
||||
type?: string
|
||||
reply?: string | null
|
||||
}>(event)
|
||||
|
||||
const data = await readDataYaml<{ messages: any[] }>('messages.yml', EMPTY)
|
||||
|
||||
const message = data.messages.find(m => m.id === id)
|
||||
if (!message) {
|
||||
@@ -16,9 +25,14 @@ export default defineEventHandler(async (event) => {
|
||||
if (body.text !== undefined) message.text = body.text
|
||||
if (body.published !== undefined) message.published = body.published
|
||||
if (body.author !== undefined) message.author = body.author
|
||||
if (body.type !== undefined) message.type = body.type
|
||||
if ('reply' in body) {
|
||||
message.reply = body.reply
|
||||
? { text: body.reply, publishedAt: new Date().toISOString() }
|
||||
: null
|
||||
}
|
||||
|
||||
await writeYaml('messages.yml', data)
|
||||
gitSyncContent(`Mise à jour message #${id}`, ['site/messages.yml'])
|
||||
await writeDataYaml('messages.yml', data)
|
||||
|
||||
return { ok: true }
|
||||
})
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
const EMPTY = { messages: [] as any[] }
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
const data = await readYaml<{ messages: any[] }>('messages.yml')
|
||||
const data = await readDataYaml<{ messages: any[] }>('messages.yml', EMPTY)
|
||||
return data.messages.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user