import { WEB_URL } from '@/app/(app)/src/constants'
import { BlocksFeature, lexicalEditor } from '@payloadcms/richtext-lexical'
import type { CollectionConfig } from 'payload'
export const Email: CollectionConfig = {
slug: 'Emails',
admin: {
useAsTitle: 'title',
livePreview: {
url: ({ data }) => {
return `${WEB_URL}/preview/email/${data.id}`
},
},
group: 'Emails',
enableRichTextLink: true,
enableRichTextRelationship: false,
},
versions: {
drafts: {
autosave: {
interval: 200,
},
},
},
fields: [
{
name: 'title',
type: 'text',
label: 'Title',
required: true,
admin: {
position: 'sidebar',
description: `The title of the email`,
},
},
{
name: 'previewText',
type: 'text',
label: 'Preview Text',
required: true,
admin: {
position: 'sidebar',
description: 'The preview text of the email',
},
},
{
name: 'footerContent',
type: 'text',
label: 'Footer Content',
required: true,
admin: {
position: 'sidebar',
description: 'The footer content of the email',
},
},
{
name: 'content',
type: 'richText',
label: 'Content',
required: true,
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,
],
}),
},
],
}