Add Uploads collection
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ src/media
|
|||||||
.eslintcache
|
.eslintcache
|
||||||
.*.swp
|
.*.swp
|
||||||
public/output.css
|
public/output.css
|
||||||
|
src/uploads
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const EventTypes: CollectionConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const pickColour = (str) => {
|
const pickColour = (str) => {
|
||||||
return `hsl(${hashCode(str) % 360}, 100%, 50%)`;
|
return `hsl(${hashCode(str) % 360}, 100%, 65%)`;
|
||||||
};
|
};
|
||||||
|
|
||||||
doc.backgroundColour = pickColour(doc.name);
|
doc.backgroundColour = pickColour(doc.name);
|
||||||
|
|||||||
@@ -118,6 +118,23 @@ const Events: CollectionConfig = {
|
|||||||
name: 'notes',
|
name: 'notes',
|
||||||
label: 'Notes',
|
label: 'Notes',
|
||||||
type: 'textarea'
|
type: 'textarea'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'uploads',
|
||||||
|
label: 'Uploads',
|
||||||
|
type: 'array',
|
||||||
|
labels: {
|
||||||
|
singular: 'file',
|
||||||
|
plural: 'files'
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'upload',
|
||||||
|
type: 'upload',
|
||||||
|
relationTo: 'uploads',
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
12
src/collections/Uploads.ts
Normal file
12
src/collections/Uploads.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
|
const Uploads: CollectionConfig = {
|
||||||
|
slug: 'uploads',
|
||||||
|
upload: {
|
||||||
|
staticURL: '/uploads',
|
||||||
|
staticDir: 'uploads'
|
||||||
|
},
|
||||||
|
fields: []
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Uploads;
|
||||||
@@ -43,4 +43,21 @@ export interface Event {
|
|||||||
end?: string;
|
end?: string;
|
||||||
location?: string;
|
location?: string;
|
||||||
notes?: string;
|
notes?: string;
|
||||||
|
uploads: {
|
||||||
|
upload: string | Upload;
|
||||||
|
id?: string;
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "uploads".
|
||||||
|
*/
|
||||||
|
export interface Upload {
|
||||||
|
id: string;
|
||||||
|
url?: string;
|
||||||
|
filename?: string;
|
||||||
|
mimeType?: string;
|
||||||
|
filesize?: number;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import path from 'path';
|
|||||||
|
|
||||||
import EventTypes from './collections/EventTypes';
|
import EventTypes from './collections/EventTypes';
|
||||||
import Events from './collections/Events';
|
import Events from './collections/Events';
|
||||||
|
import Uploads from './collections/Uploads';
|
||||||
import Users from './collections/Users';
|
import Users from './collections/Users';
|
||||||
|
|
||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
@@ -13,7 +14,8 @@ export default buildConfig({
|
|||||||
collections: [
|
collections: [
|
||||||
Users,
|
Users,
|
||||||
EventTypes,
|
EventTypes,
|
||||||
Events
|
Events,
|
||||||
|
Uploads,
|
||||||
],
|
],
|
||||||
typescript: {
|
typescript: {
|
||||||
outputFile: path.resolve(__dirname, 'payload-types.ts')
|
outputFile: path.resolve(__dirname, 'payload-types.ts')
|
||||||
|
|||||||
Reference in New Issue
Block a user