-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpayload.config.ts
67 lines (61 loc) · 2.03 KB
/
payload.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { buildConfig } from 'payload/config';
import { webpackBundler } from '@payloadcms/bundler-webpack';
import { mongooseAdapter } from '@payloadcms/db-mongodb';
import { slateEditor } from '@payloadcms/richtext-slate';
import { addAuthorFields } from '../../src/';
import path from 'path';
import Categories from './collections/Categories';
import Posts from './collections/Posts';
import Tags from './collections/Tags';
import Users from './collections/Users';
import Media from './collections/Media';
export default buildConfig({
serverURL: 'http://localhost:3000',
plugins: [
addAuthorFields({
// Exclude some collections
// excludedCollections: ['users', 'tags'],
// The 'Created By' field should be editable for posts
createdByFieldEditable: (slug: string) => slug === 'posts',
// Use a function to determine the 'Created By' label
createdByLabel: (slug: string) => {
if (slug === 'posts') {
return { en: 'Posted By', es: 'Publicado por' };
}
return { en: 'Created By', es: 'Creado por' };
},
// Internationalisation of labels is also supported
updatedByLabel: { en: 'Updated By', es: 'Actualizado por' },
}),
],
collections: [Categories, Posts, Tags, Users, Media],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
db: mongooseAdapter({
url: process.env.DATABASE_URI,
}),
editor: slateEditor({}),
admin: {
bundler: webpackBundler(),
user: Users.slug,
webpack: (config) => {
const newConfig = {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
react: path.join(__dirname, '../node_modules/react'),
'react-dom': path.join(__dirname, '../node_modules/react-dom'),
payload: path.join(__dirname, '../node_modules/payload'),
},
},
};
return newConfig;
},
},
});