feat: media library with image picker for article forms, browse/upload from folder

This commit is contained in:
remco committed 2026-07-01 17:00:35 +02:00
1 parent d35c495539
commit 12576cc113
9 files changed
+392 -19

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import { NextResponse } from "next/server";
import { readdirSync, existsSync } from "fs";
import path from "path";
export const dynamic = "force-dynamic";
const MEDIA_DIR = "assets/images/media";
export async function GET() {
const dir = path.join(process.cwd(), "public", MEDIA_DIR);
if (!existsSync(dir)) {
return NextResponse.json({ files: [] });
}
const files = readdirSync(dir)
.filter((f) => /\.(png|jpg|jpeg|gif|webp|svg|bmp)$/i.test(f))
.map((f) => ({
name: f,
url: `/${MEDIA_DIR}/${f}`,
}))
.sort((a, b) => a.name.localeCompare(b.name));
return NextResponse.json({ files });
}