Files
app.fellies.art/src/app/(normal)/galleries/[gallerySlug]/[albumSlug]/page.tsx
2025-07-12 13:16:40 +02:00

46 lines
1.3 KiB
TypeScript

import AlbumImageList from "@/components/lists/AlbumImageList";
import prisma from "@/lib/prisma";
export default async function GalleryPage({ params }: { params: { gallerySlug: string, albumSlug: string } }) {
const { gallerySlug, albumSlug } = await params;
const gallery = await prisma.gallery.findUnique({
where: { slug: gallerySlug },
select: { id: true },
});
if (!gallery) {
throw new Error("Gallery not found");
}
const album = await prisma.album.findUnique({
where: {
galleryId_slug: {
galleryId: gallery.id,
slug: albumSlug,
},
},
include: {
images: {
include: { colors: { include: { color: true } } },
orderBy: [{ sortIndex: 'asc' }, { creationDate: 'desc' }, { imageName: 'asc' }]
},
}
})
return (
<div className="max-w-7xl mx-auto px-4 py-12 space-y-12">
{album && (
<>
<section className="text-center space-y-4">
<h1 className="text-4xl font-bold tracking-tight">Album: {album.name}</h1>
<p className="text-lg text-muted-foreground">
{album.description}
</p>
</section>
<AlbumImageList images={album.images} gallerySlug={gallerySlug} albumSlug={albumSlug} />
</>
)}
</div>
);
}