Polish admin articles: card grid, thumbnails, author, slug field
Local Build and Deploy / deploy (push) Successful in 1m14s

Replace the plain articles table with a responsive card grid showing
thumbnails, title, date and author. Add a slug field to the article form
with live auto-suggestion, i18n-driven labels, a larger image preview and
delete confirmation. Persist a user-provided slug (falls back to an
auto-generated one) on create and update.
This commit is contained in:
openhands committed 2026-07-18 17:38:01 +02:00
1 parent a07d438987
commit 6215074331
4 files changed
+182 -85

No files matched your search

+6 -1
View File
@@ -36,13 +36,14 @@ export async function createArticle(formData: FormData): Promise<void> {
const image = String(formData.get("image") ?? "")
.normalize("NFC")
.trim();
const rawSlug = String(formData.get("slug") ?? "").trim();
if (!title) return;
try {
const now = new Date();
await prisma.websiteArticles.create({
data: {
slug: await uniqueSlug(title),
slug: rawSlug ? await uniqueSlug(rawSlug) : await uniqueSlug(title),
title: title.slice(0, 255),
shortStory: shortStory.slice(0, 255),
fullStory,
@@ -64,6 +65,7 @@ export async function createArticle(formData: FormData): Promise<void> {
export async function updateArticle(formData: FormData): Promise<void> {
await requirePermission(PERMS.NEWS_EDIT);
const id = BigInt(String(formData.get("id")));
const rawSlug = String(formData.get("slug") ?? "").trim();
try {
await prisma.websiteArticles.update({
where: { id },
@@ -72,6 +74,9 @@ export async function updateArticle(formData: FormData): Promise<void> {
.normalize("NFC")
.trim()
.slice(0, 255),
...(rawSlug
? { slug: await uniqueSlug(rawSlug) }
: {}),
shortStory: String(formData.get("shortStory") ?? "")
.normalize("NFC")
.trim()