nextload/payload.config.ts

96 lines
2.1 KiB
TypeScript
Raw Normal View History

import path from 'path'
import { en } from 'payload/i18n/en'
import {
2024-03-08 20:22:02 +00:00
AlignFeature,
2024-05-10 13:18:12 +00:00
BlockquoteFeature,
2024-03-08 20:22:02 +00:00
BlocksFeature,
BoldFeature,
2024-05-07 17:47:20 +00:00
ChecklistFeature,
2024-03-08 20:22:02 +00:00
HeadingFeature,
IndentFeature,
InlineCodeFeature,
ItalicFeature,
lexicalEditor,
2024-03-08 20:22:02 +00:00
LinkFeature,
OrderedListFeature,
ParagraphFeature,
2024-03-08 20:22:02 +00:00
RelationshipFeature,
UnorderedListFeature,
UploadFeature,
} from '@payloadcms/richtext-lexical'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { buildConfig } from 'payload/config'
import sharp from 'sharp'
import { fileURLToPath } from 'url'
2024-03-07 22:53:18 +00:00
2024-06-23 08:31:42 +00:00
import Media from '@payload/collections/Media'
import Authors from '@payload/collections/Authors'
import Posts from '@payload/collections/Posts'
import Users from '@payload/collections/Users'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
2024-03-01 16:48:52 +00:00
export default buildConfig({
2024-06-23 08:31:42 +00:00
admin: {
autoLogin: {
email: 'dev@payloadcms.com',
password: 'test',
prefillOnly: true,
},
},
2024-03-08 20:22:02 +00:00
editor: lexicalEditor(),
collections: [
2024-06-23 08:31:42 +00:00
Users,
Posts,
Authors,
Media,
{
slug: 'pages',
2024-03-05 00:52:10 +00:00
admin: {
useAsTitle: 'title',
2024-03-05 00:52:10 +00:00
},
fields: [
{
name: 'title',
type: 'text',
2024-03-05 00:52:10 +00:00
},
{
name: 'content',
type: 'richText',
2024-03-08 20:22:02 +00:00
},
],
2024-03-05 21:38:45 +00:00
},
],
secret: process.env.PAYLOAD_SECRET || '',
2024-03-01 16:48:52 +00:00
typescript: {
2024-06-23 08:31:42 +00:00
outputFile: path.resolve(dirname, 'types/payload-types.ts'),
2024-03-01 16:48:52 +00:00
},
2024-03-07 23:42:59 +00:00
db: mongooseAdapter({
url: process.env.MONGODB_URI || '',
2024-03-07 23:42:59 +00:00
}),
2024-03-01 18:21:15 +00:00
async onInit(payload) {
const existingUsers = await payload.find({
collection: 'users',
2024-03-01 18:21:15 +00:00
limit: 1,
})
2024-03-01 18:21:15 +00:00
if (existingUsers.docs.length === 0) {
await payload.create({
collection: 'users',
2024-03-01 18:21:15 +00:00
data: {
email: 'dev@payloadcms.com',
password: 'test',
2024-03-08 20:22:02 +00:00
},
})
2024-03-01 18:21:15 +00:00
}
},
2024-03-08 00:00:06 +00:00
// Sharp is now an optional dependency -
2024-03-08 20:22:02 +00:00
// if you want to resize images, crop, set focal point, etc.
2024-03-08 00:00:06 +00:00
// 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,
})