organise media

This commit is contained in:
Tom Elliott 2025-04-13 16:03:23 +12:00
parent 239b67719a
commit b1c2720d85
12 changed files with 130 additions and 115 deletions

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

View File

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

View File

@ -34,6 +34,9 @@
},
"pnpm": {
"onlyBuiltDependencies": [
"@swc/core",
"core-js",
"es5-ext",
"sharp"
]
}

View File

@ -69,7 +69,7 @@ export interface Config {
collections: {
projects: Project;
news: News;
media: Media;
images: Image;
documents: Document;
data: Datum;
users: User;
@ -81,7 +81,7 @@ export interface Config {
collectionsSelect: {
projects: ProjectsSelect<false> | ProjectsSelect<true>;
news: NewsSelect<false> | NewsSelect<true>;
media: MediaSelect<false> | MediaSelect<true>;
images: ImagesSelect<false> | ImagesSelect<true>;
documents: DocumentsSelect<false> | DocumentsSelect<true>;
data: DataSelect<false> | DataSelect<true>;
users: UsersSelect<false> | UsersSelect<true>;
@ -201,9 +201,9 @@ export interface News {
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media".
* via the `definition` "images".
*/
export interface Media {
export interface Image {
id: number;
alt?: string | null;
description?: string | null;
@ -319,8 +319,8 @@ export interface PayloadLockedDocument {
value: number | News;
} | null)
| ({
relationTo: 'media';
value: number | Media;
relationTo: 'images';
value: number | Image;
} | null)
| ({
relationTo: 'documents';
@ -410,9 +410,9 @@ export interface NewsSelect<T extends boolean = true> {
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media_select".
* via the `definition` "images_select".
*/
export interface MediaSelect<T extends boolean = true> {
export interface ImagesSelect<T extends boolean = true> {
alt?: T;
description?: T;
updatedAt?: T;

View File

@ -7,7 +7,9 @@ import { Home } from '@/globals/Home'
import { News } from './src/collections/News'
import { Projects } from '@/collections/Projects'
import { Data, Documents, Media } from '@/collections/Files'
import { Images } from '@/collections/media/Images'
import { Documents } from '@/collections/media/Documents'
import { Data } from '@/collections/media/Data'
export default buildConfig({
// If you'd like to use Rich Text, pass your editor here
@ -23,7 +25,7 @@ export default buildConfig({
globals: [Home],
// Define and configure your collections in this array
collections: [Projects, News, Media, Documents, Data],
collections: [Projects, News, Images, Documents, Data],
// Your Payload secret - should be a complex and secure string, unguessable
secret: process.env.PAYLOAD_SECRET || '',

28
pnpm-lock.yaml generated
View File

@ -13,10 +13,10 @@ importers:
version: 3.31.0(@types/react@19.0.12)(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react@19.0.0)
'@payloadcms/next':
specifier: ^3.31.0
version: 3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
version: 3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
'@payloadcms/richtext-lexical':
specifier: ^3.31.0
version: 3.31.0(@faceless-ui/modal@3.0.0-beta.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@faceless-ui/scroll-info@2.0.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@payloadcms/next@3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2))(@types/react@19.0.12)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)(yjs@13.6.24)
version: 3.31.0(@faceless-ui/modal@3.0.0-beta.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@faceless-ui/scroll-info@2.0.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@payloadcms/next@3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2))(@types/react@19.0.12)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)(yjs@13.6.24)
cross-env:
specifier: ^7.0.3
version: 7.0.3
@ -1834,8 +1834,8 @@ packages:
minimist@1.2.8:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
monaco-editor@0.52.2:
resolution: {integrity: sha512-GEQWEZmfkOGLdd3XK8ryrfWz3AIP8YymVXiPHEdewrUq7mh0qrKrfHLNCXcbB6sTnMLnOZ3ztSiKcciFUkIJwQ==}
monaco-editor@0.38.0:
resolution: {integrity: sha512-11Fkh6yzEmwx7O0YoLxeae0qEGFwmyPRlVxpg7oF9czOOCB/iCjdJrG5I67da5WiXK3YJCxoz9TJFE8Tfq/v9A==}
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
@ -3102,10 +3102,10 @@ snapshots:
dependencies:
state-local: 1.0.7
'@monaco-editor/react@4.7.0(monaco-editor@0.52.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)':
'@monaco-editor/react@4.7.0(monaco-editor@0.38.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)':
dependencies:
'@monaco-editor/loader': 1.5.0
monaco-editor: 0.52.2
monaco-editor: 0.38.0
react: 19.0.0
react-dom: 19.0.0(react@19.0.0)
@ -3228,12 +3228,12 @@ snapshots:
transitivePeerDependencies:
- typescript
'@payloadcms/next@3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)':
'@payloadcms/next@3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)':
dependencies:
'@dnd-kit/core': 6.0.8(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@payloadcms/graphql': 3.31.0(graphql@16.10.0)(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(typescript@5.8.2)
'@payloadcms/translations': 3.31.0
'@payloadcms/ui': 3.31.0(@types/react@19.0.12)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
'@payloadcms/ui': 3.31.0(@types/react@19.0.12)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
busboy: 1.6.0
dequal: 2.0.3
file-type: 19.3.0
@ -3256,7 +3256,7 @@ snapshots:
- supports-color
- typescript
'@payloadcms/richtext-lexical@3.31.0(@faceless-ui/modal@3.0.0-beta.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@faceless-ui/scroll-info@2.0.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@payloadcms/next@3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2))(@types/react@19.0.12)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)(yjs@13.6.24)':
'@payloadcms/richtext-lexical@3.31.0(@faceless-ui/modal@3.0.0-beta.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@faceless-ui/scroll-info@2.0.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(@payloadcms/next@3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2))(@types/react@19.0.12)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)(yjs@13.6.24)':
dependencies:
'@faceless-ui/modal': 3.0.0-beta.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@faceless-ui/scroll-info': 2.0.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
@ -3270,9 +3270,9 @@ snapshots:
'@lexical/selection': 0.28.0
'@lexical/table': 0.28.0
'@lexical/utils': 0.28.0
'@payloadcms/next': 3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
'@payloadcms/next': 3.31.0(@types/react@19.0.12)(graphql@16.10.0)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
'@payloadcms/translations': 3.31.0
'@payloadcms/ui': 3.31.0(@types/react@19.0.12)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
'@payloadcms/ui': 3.31.0(@types/react@19.0.12)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)
'@types/uuid': 10.0.0
acorn: 8.12.1
bson-objectid: 2.0.4
@ -3302,7 +3302,7 @@ snapshots:
dependencies:
date-fns: 4.1.0
'@payloadcms/ui@3.31.0(@types/react@19.0.12)(monaco-editor@0.52.2)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)':
'@payloadcms/ui@3.31.0(@types/react@19.0.12)(monaco-editor@0.38.0)(next@15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.77.4))(payload@3.31.0(graphql@16.10.0)(typescript@5.8.2))(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(typescript@5.8.2)':
dependencies:
'@date-fns/tz': 1.2.0
'@dnd-kit/core': 6.0.8(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
@ -3310,7 +3310,7 @@ snapshots:
'@faceless-ui/modal': 3.0.0-beta.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@faceless-ui/scroll-info': 2.0.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@faceless-ui/window-info': 3.0.1(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@monaco-editor/react': 4.7.0(monaco-editor@0.52.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@monaco-editor/react': 4.7.0(monaco-editor@0.38.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@payloadcms/translations': 3.31.0
bson-objectid: 2.0.4
date-fns: 4.1.0
@ -4227,7 +4227,7 @@ snapshots:
minimist@1.2.8: {}
monaco-editor@0.52.2: {}
monaco-editor@0.38.0: {}
ms@2.1.3: {}

View File

@ -1 +0,0 @@
import type { CollectionConfig } from "payload";

View File

@ -1,90 +0,0 @@
import type { CollectionConfig } from "payload";
export const Media: CollectionConfig = {
slug: 'media',
upload: {
staticDir: 'media',
imageSizes: [
{
name: 'thumbnail',
width: 400,
height: 300,
position: 'centre',
},
{
name: 'card',
width: 768,
height: 1024,
position: 'centre',
},
{
name: 'tablet',
width: 1024,
height: undefined,
position: 'centre',
}
],
adminThumbnail: 'thumbnail',
mimeTypes: ['image/*'],
},
fields: [
{
name: 'alt',
label: 'Alt Text',
type: 'text',
},
{
name: 'description',
label: 'Description',
type: 'textarea',
}
]
}
export const Documents: CollectionConfig = {
slug: 'documents',
upload: {
staticDir: 'documents',
mimeTypes: ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
required: true,
},
{
name: 'description',
label: 'Description',
type: 'textarea',
},
]
}
export const Data: CollectionConfig = {
slug: 'data',
upload: {
staticDir: 'data',
mimeTypes: ['application/json', 'text/csv', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/plain'],
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
required: true,
},
{
name: 'description',
label: 'Description',
type: 'textarea',
},
{
name: 'source',
label: 'Source',
type: 'text',
required: true,
},
],
}

View File

@ -0,0 +1,31 @@
import type { CollectionConfig } from "payload";
export const Data: CollectionConfig = {
slug: 'data',
upload: {
staticDir: 'data',
mimeTypes: ['application/json', 'text/csv', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/plain'],
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
required: true,
},
{
name: 'description',
label: 'Description',
type: 'textarea',
},
{
name: 'source',
label: 'Source',
type: 'text',
required: true,
},
],
admin: {
group: 'Media',
}
}

View File

@ -0,0 +1,25 @@
import type { CollectionConfig } from "payload";
export const Documents: CollectionConfig = {
slug: 'documents',
upload: {
staticDir: 'media/documents',
mimeTypes: ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
required: true,
},
{
name: 'description',
label: 'Description',
type: 'textarea',
},
],
admin: {
group: 'Media',
}
}

View File

@ -0,0 +1,45 @@
import type { CollectionConfig } from "payload";
export const Images: CollectionConfig = {
slug: 'images',
upload: {
staticDir: 'media/images',
imageSizes: [
{
name: 'thumbnail',
width: 400,
height: 300,
position: 'centre',
},
{
name: 'card',
width: 768,
height: 1024,
position: 'centre',
},
{
name: 'tablet',
width: 1024,
height: undefined,
position: 'centre',
}
],
adminThumbnail: 'thumbnail',
mimeTypes: ['image/*'],
},
fields: [
{
name: 'alt',
label: 'Alt Text',
type: 'text',
},
{
name: 'description',
label: 'Description',
type: 'textarea',
}
],
admin: {
group: 'Media',
}
}