feat(web): complete portfolio public filter and sort integration

This commit is contained in:
2026-02-12 23:08:25 +01:00
parent 60c9035743
commit a2bea6326e
7 changed files with 169 additions and 18 deletions

View File

@@ -9,15 +9,18 @@ import {
updateGroupingInputSchema,
updateMediaAssetInputSchema,
} from "@cms/content"
import type { Prisma } from "@prisma/client"
import { db } from "./client"
type PublicArtworkGroupType = "gallery" | "album" | "category" | "tag"
type PublicArtworkSort = "latest" | "title_asc" | "title_desc"
type ListPublishedArtworksInput = {
groupType?: PublicArtworkGroupType
groupSlug?: string
limit?: number
sort?: PublicArtworkSort
}
export async function listMediaAssets(limit = 24) {
@@ -431,6 +434,12 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput =
const where: Record<string, unknown> = {
isPublished: true,
}
const orderBy: Prisma.ArtworkOrderByWithRelationInput[] =
input.sort === "title_asc"
? [{ title: "asc" }, { updatedAt: "desc" }]
: input.sort === "title_desc"
? [{ title: "desc" }, { updatedAt: "desc" }]
: [{ updatedAt: "desc" }]
if (input.groupType && input.groupSlug) {
if (input.groupType === "gallery") {
@@ -474,7 +483,7 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput =
return db.artwork.findMany({
where,
orderBy: [{ updatedAt: "desc" }],
orderBy,
take,
include: {
renditions: {