Workaround because of search bug in relationshipfields

This commit is contained in:
DrMint 2024-05-05 08:09:14 +02:00
parent 87a2ca1bc3
commit 0890d0c3f8
3 changed files with 8 additions and 4 deletions

View File

@ -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}`,

View File

@ -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}`,

View File

@ -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<BuildCollectionConfig, "upload"> & {
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,
},