2024-03-13 02:12:46 +00:00
|
|
|
import path from 'path'
|
2024-04-10 21:43:51 +00:00
|
|
|
import { en } from 'payload/i18n/en'
|
2024-03-08 04:47:08 +00:00
|
|
|
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,
|
2024-03-08 04:47:08 +00:00
|
|
|
lexicalEditor,
|
2024-03-08 20:22:02 +00:00
|
|
|
LinkFeature,
|
|
|
|
OrderedListFeature,
|
2024-03-08 04:47:08 +00:00
|
|
|
ParagraphFeature,
|
2024-03-08 20:22:02 +00:00
|
|
|
RelationshipFeature,
|
|
|
|
UnorderedListFeature,
|
2024-03-08 04:47:08 +00:00
|
|
|
UploadFeature,
|
2024-03-13 02:12:46 +00:00
|
|
|
} 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'
|
2024-06-23 20:23:06 +00:00
|
|
|
import Pages from '@payload/collections/Pages'
|
2024-06-24 09:53:43 +00:00
|
|
|
import { COLLECTION_SLUG_PAGE, COLLECTION_SLUG_POST } from '@/app/(payload)/collections/config'
|
2024-06-23 08:31:42 +00:00
|
|
|
|
2024-03-13 02:12:46 +00:00
|
|
|
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 23:22:01 +00:00
|
|
|
collections: [Users, Posts, Authors, Media, Pages],
|
2024-06-23 08:31:42 +00:00
|
|
|
admin: {
|
|
|
|
autoLogin: {
|
2024-07-06 17:49:50 +00:00
|
|
|
email: 'admin@nextload.test',
|
2024-06-23 08:31:42 +00:00
|
|
|
password: 'test',
|
|
|
|
prefillOnly: true,
|
|
|
|
},
|
2024-06-24 09:53:43 +00:00
|
|
|
livePreview: {
|
2024-06-24 11:52:06 +00:00
|
|
|
url: ({ data, locale, collectionConfig }) =>
|
2024-07-06 20:19:52 +00:00
|
|
|
`${process.env.BASE_URL}/${collectionConfig?.slug || ''}/preview${data.path}${
|
2024-06-24 11:52:06 +00:00
|
|
|
locale ? `?locale=${locale.code}` : ''
|
|
|
|
}`,
|
2024-06-24 11:39:37 +00:00
|
|
|
collections: [COLLECTION_SLUG_PAGE, COLLECTION_SLUG_POST],
|
2024-06-24 09:53:43 +00:00
|
|
|
},
|
2024-06-23 08:31:42 +00:00
|
|
|
},
|
2024-03-08 20:22:02 +00:00
|
|
|
editor: lexicalEditor(),
|
2024-03-13 02:12:46 +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({
|
2024-03-13 02:12:46 +00:00
|
|
|
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({
|
2024-03-13 02:12:46 +00:00
|
|
|
collection: 'users',
|
2024-07-05 21:26:50 +00:00
|
|
|
limit: 2,
|
2024-03-13 02:12:46 +00:00
|
|
|
})
|
2024-03-01 18:21:15 +00:00
|
|
|
|
2024-07-05 21:26:50 +00:00
|
|
|
if (existingUsers.docs.length === 0 || existingUsers.docs.length === 1) {
|
2024-03-01 18:21:15 +00:00
|
|
|
await payload.create({
|
2024-03-13 02:12:46 +00:00
|
|
|
collection: 'users',
|
2024-03-01 18:21:15 +00:00
|
|
|
data: {
|
2024-07-05 21:26:50 +00:00
|
|
|
email: 'admin@nextload.test',
|
2024-03-13 02:12:46 +00:00
|
|
|
password: 'test',
|
2024-06-23 08:52:32 +00:00
|
|
|
roles: ['admin'],
|
2024-03-08 20:22:02 +00:00
|
|
|
},
|
2024-03-13 02:12:46 +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,
|
2024-03-13 02:12:46 +00:00
|
|
|
})
|