feat: add localization and site settings
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { getApiLang, pickText } from "@/lib/api-locale";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const enabledOnly = request.nextUrl.searchParams.get("enabled") === "1";
|
||||
const lang = getApiLang(request);
|
||||
const where = enabledOnly ? { enabled: true } : {};
|
||||
const images = await prisma.galleryImage.findMany({
|
||||
where,
|
||||
orderBy: { sortOrder: "asc" },
|
||||
});
|
||||
return NextResponse.json(images);
|
||||
return NextResponse.json(
|
||||
images.map((img) => ({
|
||||
...img,
|
||||
title: pickText(img.title, img.titleEn, lang),
|
||||
titleZh: img.title,
|
||||
titleEn: img.titleEn,
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
@@ -23,6 +32,7 @@ export async function POST(request: NextRequest) {
|
||||
data: {
|
||||
imageUrl: body.imageUrl,
|
||||
title: body.title ?? "",
|
||||
titleEn: body.titleEn ?? "",
|
||||
sortOrder: body.sortOrder ?? 0,
|
||||
enabled: body.enabled ?? true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user