Adds new plugin-import-export initial version.
Allows for direct download and creation of downloadable collection data
stored to a json or csv uses the access control of the user creating the
request to make the file.
config options:
```ts
/**
* Collections to include the Import/Export controls in
* Defaults to all collections
*/
collections?: string[]
/**
* Enable to force the export to run synchronously
*/
disableJobsQueue?: boolean
/**
* This function takes the default export collection configured in the plugin and allows you to override it by modifying and returning it
* @param collection
* @returns collection
*/
overrideExportCollection?: (collection: CollectionOverride) => CollectionOverride
// payload.config.ts:
plugins: [
importExportPlugin({
collections: ['pages', 'users'],
overrideExportCollection: (collection) => {
collection.admin.group = 'System'
collection.upload.staticDir = path.resolve(dirname, 'uploads')
return collection
},
disableJobsQueue: true,
}),
],
```
---------
Co-authored-by: Jessica Chowdhury <jessica@trbl.design>
Co-authored-by: Kendell Joseph <kendelljoseph@gmail.com>
118 lines
2.0 KiB
TypeScript
118 lines
2.0 KiB
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { pagesSlug } from '../shared.js'
|
|
|
|
export const Pages: CollectionConfig = {
|
|
slug: pagesSlug,
|
|
labels: {
|
|
singular: 'Page',
|
|
plural: 'Pages',
|
|
},
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
},
|
|
versions: {
|
|
drafts: true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
label: 'Title',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'localized',
|
|
type: 'text',
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'group',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'value',
|
|
type: 'text',
|
|
defaultValue: 'group value',
|
|
},
|
|
{
|
|
name: 'ignore',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'array',
|
|
type: 'array',
|
|
fields: [
|
|
{
|
|
name: 'field1',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'field2',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'array',
|
|
type: 'array',
|
|
fields: [
|
|
{
|
|
name: 'field1',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'field2',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'blocks',
|
|
type: 'blocks',
|
|
blocks: [
|
|
{
|
|
slug: 'hero',
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'content',
|
|
fields: [
|
|
{
|
|
name: 'richText',
|
|
type: 'richText',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'author',
|
|
type: 'relationship',
|
|
relationTo: 'users',
|
|
},
|
|
{
|
|
name: 'hasManyNumber',
|
|
type: 'number',
|
|
hasMany: true,
|
|
},
|
|
{
|
|
name: 'relationship',
|
|
type: 'relationship',
|
|
relationTo: 'users',
|
|
},
|
|
{
|
|
name: 'excerpt',
|
|
label: 'Excerpt',
|
|
type: 'text',
|
|
},
|
|
],
|
|
}
|