--- import Admin from '../../layouts/Admin.astro'; import { getDb } from '../../lib/db'; import { listAllPosts, listByAuthor } from '../../lib/posts'; import { listUsers } from '../../lib/auth'; export const prerender = false; const user = Astro.locals.user!; const isManager = user.role === 'superuser' || user.role === 'admin'; const posts = isManager ? listAllPosts(getDb()) : listByAuthor(getDb(), user.id); const nameById = new Map(listUsers(getDb()).map((u) => [u.id, u.username])); const fmt = new Intl.DateTimeFormat('it-IT', { dateStyle: 'short', timeStyle: 'short' }); ---

Articoli

+ Nuovo articolo

{isManager && } {posts.map((p) => ( {isManager && } ))}
TitoloCategoriaAutoreStatoAggiornato
{p.title} {p.category}{p.author_id ? (nameById.get(p.author_id) ?? 'Staff InsanityLab') : 'Staff InsanityLab'}{p.draft ? 'Bozza' : 'Pubblicato'} {fmt.format(new Date(p.updated_at.replace(' ', 'T') + 'Z'))}
{posts.length === 0 &&

Nessun articolo: creane uno nuovo.

}