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({ export const Audios = buildCollectionConfig({
slug: Collections.Audios, slug: Collections.Audios,
labels: { singular: "Audio", plural: "Audios" }, labels: { singular: "Audio", plural: "Audios" },
defaultSort: fields.updatedAt, defaultSort: fields.filename,
admin: { admin: {
group: CollectionGroups.Media, group: CollectionGroups.Media,
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/audios/${id}`, preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/audios/${id}`,

View File

@ -34,7 +34,7 @@ const fields = {
export const Videos = buildCollectionConfig({ export const Videos = buildCollectionConfig({
slug: Collections.Videos, slug: Collections.Videos,
labels: { singular: "Video", plural: "Videos" }, labels: { singular: "Video", plural: "Videos" },
defaultSort: fields.updatedAt, defaultSort: fields.filename,
admin: { admin: {
group: CollectionGroups.Media, group: CollectionGroups.Media,
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/videos/${id}`, 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 { CollectionGroups } from "../constants";
import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig"; import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig";
const fields = {
filename: "filename",
};
type BuildImageCollectionConfig = Omit<BuildCollectionConfig, "upload"> & { type BuildImageCollectionConfig = Omit<BuildCollectionConfig, "upload"> & {
upload: { imageSizes: ImageSize[] }; upload: { imageSizes: ImageSize[] };
}; };
@ -15,10 +19,10 @@ export const buildImageCollectionConfig = ({
}: BuildImageCollectionConfig): CollectionConfig => }: BuildImageCollectionConfig): CollectionConfig =>
buildCollectionConfig({ buildCollectionConfig({
...otherConfig, ...otherConfig,
defaultSort: "-updatedAt", defaultSort: fields.filename,
admin: { admin: {
disableDuplicate: true, disableDuplicate: true,
useAsTitle: "filename", useAsTitle: fields.filename,
group: CollectionGroups.Media, group: CollectionGroups.Media,
...admin, ...admin,
}, },