2024-03-01 16:48:52 +00:00
|
|
|
import path from "path";
|
2024-03-07 23:42:59 +00:00
|
|
|
// import { postgresAdapter } from '@payloadcms/db-postgres'
|
2024-03-08 04:47:08 +00:00
|
|
|
import {
|
|
|
|
AlignFeature, BlockQuoteFeature,
|
|
|
|
BlocksFeature, BoldFeature, CheckListFeature, HeadingFeature, IndentFeature, InlineCodeFeature, ItalicFeature,
|
|
|
|
lexicalEditor,
|
|
|
|
LinkFeature, OrderedListFeature,
|
|
|
|
ParagraphFeature,
|
|
|
|
RelationshipFeature, UnorderedListFeature,
|
|
|
|
UploadFeature,
|
|
|
|
} from '@payloadcms/richtext-lexical'
|
|
|
|
//import { slateEditor } from '@payloadcms/richtext-slate'
|
2024-03-08 00:00:06 +00:00
|
|
|
import { mongooseAdapter } from "@payloadcms/db-mongodb";
|
2024-03-01 16:48:52 +00:00
|
|
|
import { buildConfig } from "payload/config";
|
2024-03-05 22:16:05 +00:00
|
|
|
import sharp from 'sharp'
|
2024-03-07 22:53:18 +00:00
|
|
|
import { fileURLToPath } from "url";
|
|
|
|
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
|
|
const dirname = path.dirname(filename)
|
2024-03-01 16:48:52 +00:00
|
|
|
|
|
|
|
export default buildConfig({
|
2024-03-08 04:47:08 +00:00
|
|
|
//editor: slateEditor({}),
|
|
|
|
editor: lexicalEditor(),
|
2024-03-04 21:49:44 +00:00
|
|
|
collections: [
|
|
|
|
{
|
|
|
|
slug: 'pages',
|
2024-03-05 00:52:10 +00:00
|
|
|
admin: {
|
|
|
|
useAsTitle: 'title',
|
|
|
|
},
|
2024-03-04 21:49:44 +00:00
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: 'title',
|
|
|
|
type: 'text',
|
2024-03-05 00:52:10 +00:00
|
|
|
},
|
|
|
|
{
|
2024-03-06 21:18:34 +00:00
|
|
|
name: 'content',
|
|
|
|
type: 'richText',
|
2024-03-04 21:49:44 +00:00
|
|
|
}
|
|
|
|
]
|
2024-03-05 21:38:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
slug: 'media',
|
|
|
|
upload: true,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: 'text',
|
|
|
|
type: 'text',
|
|
|
|
}
|
|
|
|
]
|
2024-03-04 21:49:44 +00:00
|
|
|
}
|
|
|
|
],
|
2024-03-05 00:52:10 +00:00
|
|
|
secret: process.env.PAYLOAD_SECRET || '',
|
2024-03-01 16:48:52 +00:00
|
|
|
typescript: {
|
2024-03-07 22:53:18 +00:00
|
|
|
outputFile: path.resolve(dirname, "payload-types.ts"),
|
2024-03-01 16:48:52 +00:00
|
|
|
},
|
2024-03-07 23:42:59 +00:00
|
|
|
// db: postgresAdapter({
|
|
|
|
// pool: {
|
|
|
|
// connectionString: process.env.POSTGRES_URI || ''
|
|
|
|
// }
|
2024-03-07 22:53:18 +00:00
|
|
|
// }),
|
2024-03-07 23:42:59 +00:00
|
|
|
db: mongooseAdapter({
|
|
|
|
url: process.env.MONGODB_URI || '',
|
|
|
|
}),
|
2024-03-08 04:47:08 +00:00
|
|
|
admin: {
|
|
|
|
autoLogin: {
|
|
|
|
email: 'dev@payloadcms.com',
|
|
|
|
password: 'test',
|
|
|
|
prefillOnly: true,
|
|
|
|
}
|
|
|
|
},
|
2024-03-01 18:21:15 +00:00
|
|
|
async onInit(payload) {
|
|
|
|
const existingUsers = await payload.find({
|
|
|
|
collection: 'users',
|
|
|
|
limit: 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
if (existingUsers.docs.length === 0) {
|
|
|
|
await payload.create({
|
|
|
|
collection: 'users',
|
|
|
|
data: {
|
|
|
|
email: 'dev@payloadcms.com',
|
|
|
|
password: 'test',
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2024-03-08 00:00:06 +00:00
|
|
|
// Sharp is now an optional dependency -
|
|
|
|
// if you want to resize images, crop, set focal point, etc.
|
|
|
|
// make sure to install it and pass it to the config.
|
|
|
|
|
|
|
|
// This is temporary - we may make an adapter pattern
|
|
|
|
// for this before reaching 3.0 stable
|
2024-03-05 22:16:05 +00:00
|
|
|
sharp,
|
2024-03-01 16:48:52 +00:00
|
|
|
});
|