Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Failing after 1m24s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
122 lines
2.8 KiB
TypeScript
122 lines
2.8 KiB
TypeScript
import type { CollectionConfig } from "payload";
|
|
import { lexicalEditor, BlocksFeature } from "@payloadcms/richtext-lexical";
|
|
import { payloadBlocks } from "../blocks/allBlocks";
|
|
|
|
export const Posts: CollectionConfig = {
|
|
slug: "posts",
|
|
admin: {
|
|
useAsTitle: "title",
|
|
defaultColumns: ["featuredImage", "title", "date", "updatedAt", "_status"],
|
|
},
|
|
versions: {
|
|
drafts: true,
|
|
},
|
|
access: {
|
|
read: () => true, // Publicly readable API
|
|
},
|
|
fields: [
|
|
{
|
|
name: "aiOptimizer",
|
|
type: "ui",
|
|
admin: {
|
|
position: "sidebar",
|
|
components: {
|
|
Field: "@mintel/payload-ai/components/OptimizeButton#OptimizeButton",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "title",
|
|
type: "text",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "slug",
|
|
type: "text",
|
|
required: true,
|
|
unique: true,
|
|
admin: {
|
|
position: "sidebar",
|
|
components: {
|
|
afterInput: [
|
|
"@mintel/payload-ai/components/GenerateSlugButton#GenerateSlugButton",
|
|
],
|
|
},
|
|
},
|
|
hooks: {
|
|
beforeValidate: [
|
|
({ value, data }) => {
|
|
if (value) return value;
|
|
if (data?.title) {
|
|
return data.title
|
|
.toLowerCase()
|
|
.replace(/ /g, "-")
|
|
.replace(/[^\w-]+/g, "");
|
|
}
|
|
return value;
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
name: "description",
|
|
type: "text",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "date",
|
|
type: "date",
|
|
required: true,
|
|
admin: {
|
|
position: "sidebar",
|
|
description:
|
|
"Set a future date and save as 'Published' to schedule this post. It will not appear on the frontend until this date is reached.",
|
|
},
|
|
},
|
|
{
|
|
name: "tags",
|
|
type: "array",
|
|
required: true,
|
|
admin: {
|
|
position: "sidebar",
|
|
},
|
|
fields: [
|
|
{
|
|
name: "tag",
|
|
type: "text",
|
|
admin: {
|
|
description: "Kategorisiere diesen Post mit einem eindeutigen Tag",
|
|
components: { Field: "@/src/payload/components/TagSelector" },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: "featuredImage",
|
|
type: "upload",
|
|
relationTo: "media",
|
|
admin: {
|
|
description: "The main hero image for the blog post.",
|
|
position: "sidebar",
|
|
components: {
|
|
afterInput: [
|
|
"@mintel/payload-ai/components/GenerateThumbnailButton#GenerateThumbnailButton",
|
|
],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "content",
|
|
type: "richText",
|
|
editor: lexicalEditor({
|
|
features: ({ defaultFeatures }) => [
|
|
...defaultFeatures,
|
|
BlocksFeature({
|
|
blocks: payloadBlocks,
|
|
}),
|
|
],
|
|
}),
|
|
},
|
|
],
|
|
};
|