2024-03-01 16:48:52 +00:00
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
import { mongooseAdapter } from "@payloadcms/db-mongodb"; // database-adapter-import
|
|
|
|
import { slateEditor } from "@payloadcms/richtext-slate"; // editor-import
|
|
|
|
import { buildConfig } from "payload/config";
|
2024-03-05 21:38:45 +00:00
|
|
|
// import sharp from 'sharp'
|
2024-03-01 16:48:52 +00:00
|
|
|
|
|
|
|
export default buildConfig({
|
|
|
|
editor: slateEditor({}), // editor-config
|
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
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'test',
|
|
|
|
type: 'number',
|
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: {
|
|
|
|
outputFile: path.resolve(__dirname, "payload-types.ts"),
|
|
|
|
},
|
|
|
|
graphQL: {
|
|
|
|
schemaOutputFile: path.resolve(__dirname, "generated-schema.graphql"),
|
|
|
|
},
|
|
|
|
db: mongooseAdapter({
|
2024-03-05 00:52:10 +00:00
|
|
|
url: process.env.MONGODB_URI || '',
|
2024-03-01 16:48:52 +00:00
|
|
|
}),
|
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-05 21:38:45 +00:00
|
|
|
// sharp,
|
2024-03-01 16:48:52 +00:00
|
|
|
});
|