From 0890d0c3f82b55b5d3a32e96d1cb9581d0fada80 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sun, 5 May 2024 08:09:14 +0200 Subject: [PATCH] Workaround because of search bug in relationshipfields --- src/collections/Audios/Audios.ts | 2 +- src/collections/Videos/Videos.ts | 2 +- src/utils/imageCollectionConfig.ts | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/collections/Audios/Audios.ts b/src/collections/Audios/Audios.ts index f7c62fe..9e6a5e8 100644 --- a/src/collections/Audios/Audios.ts +++ b/src/collections/Audios/Audios.ts @@ -25,7 +25,7 @@ const fields = { export const Audios = buildCollectionConfig({ slug: Collections.Audios, labels: { singular: "Audio", plural: "Audios" }, - defaultSort: fields.updatedAt, + defaultSort: fields.filename, admin: { group: CollectionGroups.Media, preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/audios/${id}`, diff --git a/src/collections/Videos/Videos.ts b/src/collections/Videos/Videos.ts index 76cf779..53c8c4e 100644 --- a/src/collections/Videos/Videos.ts +++ b/src/collections/Videos/Videos.ts @@ -34,7 +34,7 @@ const fields = { export const Videos = buildCollectionConfig({ slug: Collections.Videos, labels: { singular: "Video", plural: "Videos" }, - defaultSort: fields.updatedAt, + defaultSort: fields.filename, admin: { group: CollectionGroups.Media, preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/videos/${id}`, diff --git a/src/utils/imageCollectionConfig.ts b/src/utils/imageCollectionConfig.ts index dec4e99..8137bd8 100644 --- a/src/utils/imageCollectionConfig.ts +++ b/src/utils/imageCollectionConfig.ts @@ -4,6 +4,10 @@ import { publicAccess } from "../accesses/publicAccess"; import { CollectionGroups } from "../constants"; import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig"; +const fields = { + filename: "filename", +}; + type BuildImageCollectionConfig = Omit & { upload: { imageSizes: ImageSize[] }; }; @@ -15,10 +19,10 @@ export const buildImageCollectionConfig = ({ }: BuildImageCollectionConfig): CollectionConfig => buildCollectionConfig({ ...otherConfig, - defaultSort: "-updatedAt", + defaultSort: fields.filename, admin: { disableDuplicate: true, - useAsTitle: "filename", + useAsTitle: fields.filename, group: CollectionGroups.Media, ...admin, },