diff --git a/src/app/(payload)/admin/importMap.js b/src/app/(payload)/admin/importMap.js index 2ed42a6..f30b09e 100644 --- a/src/app/(payload)/admin/importMap.js +++ b/src/app/(payload)/admin/importMap.js @@ -15,39 +15,25 @@ import { HeadingFeatureClient as HeadingFeatureClient_e70f5e05f09f93e00b997edb1e import { FolderTypeField as FolderTypeField_2b8867833a34864a02ddf429b0728a40 } from '@payloadcms/next/client' import { default as default_1a7510af427896d367a49dbf838d2de6 } from '@/components/BeforeDashboard' import { default as default_8a7ab0eb7ab5c511aba12e68480bfe5e } from '@/components/BeforeLogin' -import { S3ClientUploadHandler as S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24 } from '@payloadcms/storage-s3/client' import { CollectionCards as CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } from '@payloadcms/next/rsc' export const importMap = { - '@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell': - RscEntryLexicalCell_44fe37237e0ebf4470c9990d8cb7b07e, - '@payloadcms/richtext-lexical/rsc#RscEntryLexicalField': - RscEntryLexicalField_44fe37237e0ebf4470c9990d8cb7b07e, - '@payloadcms/richtext-lexical/rsc#LexicalDiffComponent': - LexicalDiffComponent_44fe37237e0ebf4470c9990d8cb7b07e, - '@payloadcms/richtext-lexical/client#InlineToolbarFeatureClient': - InlineToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/richtext-lexical/client#FixedToolbarFeatureClient': - FixedToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/richtext-lexical/client#ParagraphFeatureClient': - ParagraphFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/richtext-lexical/client#UnderlineFeatureClient': - UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/richtext-lexical/client#BoldFeatureClient': - BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/richtext-lexical/client#ItalicFeatureClient': - ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/richtext-lexical/client#LinkFeatureClient': - LinkFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/next/rsc#FolderTableCell': FolderTableCell_f9c02e79a4aed9a3924487c0cd4cafb1, - '@payloadcms/next/rsc#FolderField': FolderField_f9c02e79a4aed9a3924487c0cd4cafb1, - '@payloadcms/next/client#SlugField': SlugField_2b8867833a34864a02ddf429b0728a40, - '@payloadcms/richtext-lexical/client#HeadingFeatureClient': - HeadingFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - '@payloadcms/next/client#FolderTypeField': FolderTypeField_2b8867833a34864a02ddf429b0728a40, - '@/components/BeforeDashboard#default': default_1a7510af427896d367a49dbf838d2de6, - '@/components/BeforeLogin#default': default_8a7ab0eb7ab5c511aba12e68480bfe5e, - '@payloadcms/storage-s3/client#S3ClientUploadHandler': - S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24, - '@payloadcms/next/rsc#CollectionCards': CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1, + "@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell": RscEntryLexicalCell_44fe37237e0ebf4470c9990d8cb7b07e, + "@payloadcms/richtext-lexical/rsc#RscEntryLexicalField": RscEntryLexicalField_44fe37237e0ebf4470c9990d8cb7b07e, + "@payloadcms/richtext-lexical/rsc#LexicalDiffComponent": LexicalDiffComponent_44fe37237e0ebf4470c9990d8cb7b07e, + "@payloadcms/richtext-lexical/client#InlineToolbarFeatureClient": InlineToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/richtext-lexical/client#FixedToolbarFeatureClient": FixedToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/richtext-lexical/client#ParagraphFeatureClient": ParagraphFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/richtext-lexical/client#UnderlineFeatureClient": UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/richtext-lexical/client#LinkFeatureClient": LinkFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/next/rsc#FolderTableCell": FolderTableCell_f9c02e79a4aed9a3924487c0cd4cafb1, + "@payloadcms/next/rsc#FolderField": FolderField_f9c02e79a4aed9a3924487c0cd4cafb1, + "@payloadcms/next/client#SlugField": SlugField_2b8867833a34864a02ddf429b0728a40, + "@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "@payloadcms/next/client#FolderTypeField": FolderTypeField_2b8867833a34864a02ddf429b0728a40, + "@/components/BeforeDashboard#default": default_1a7510af427896d367a49dbf838d2de6, + "@/components/BeforeLogin#default": default_8a7ab0eb7ab5c511aba12e68480bfe5e, + "@payloadcms/next/rsc#CollectionCards": CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } diff --git a/src/globals/durianpy-website/HomepageConfig.ts b/src/globals/durianpy-website/HomepageConfig.ts new file mode 100644 index 0000000..0d2a111 --- /dev/null +++ b/src/globals/durianpy-website/HomepageConfig.ts @@ -0,0 +1,55 @@ +import { checkCollectionAccess } from '@/access/checkCollectionAccess' +import { getCollectionGroupLabel } from '@/constants/collections' +import { GlobalConfig } from 'payload' + +// We will let VS Code import these automatically! +// 1. Click on getCollectionGroupLabel below, press Ctrl + . (or Cmd + .), and click "Update import" or "Add import" +// 2. Click on checkCollectionAccess below, press Ctrl + . (or Cmd + .), and click "Add import" + +export const HomepageConfig: GlobalConfig = { + slug: 'homepage-config', + admin: { + group: getCollectionGroupLabel('durianpy-website'), + }, + access: { + read: () => true, + // We explicitly type args as 'any' to satisfy TS, and removed the invalid 'admin' access rule! + update: (args: any) => checkCollectionAccess(args, 'homepage-config' as any, 'update'), + }, + versions: { + // Globals use 'max' instead of 'maxPerDoc' + max: 50, + drafts: { + autosave: { + showSaveDraftButton: true, + }, + schedulePublish: true, + }, + }, + fields: [ + { + name: 'heroImageDesktop', + type: 'upload', + relationTo: 'media', + required: true, + label: 'Hero Image (Desktop)', + }, + { + name: 'heroImageMobile', + type: 'upload', + relationTo: 'media', + required: true, + label: 'Hero Image (Mobile)', + }, + { + name: 'heroTitle', + type: 'text', + label: 'Hero Title', + }, + { + name: 'heroSubtitle', + type: 'text', + label: 'Hero Subtitle', + }, + ], +} diff --git a/src/payload-types.ts b/src/payload-types.ts index 0a66d77..3a67024 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -103,8 +103,12 @@ export interface Config { defaultIDType: string; }; fallbackLocale: null; - globals: {}; - globalsSelect: {}; + globals: { + 'homepage-config': HomepageConfig; + }; + globalsSelect: { + 'homepage-config': HomepageConfigSelect | HomepageConfigSelect; + }; locale: null; widgets: { collections: CollectionsWidget; @@ -1095,6 +1099,34 @@ export interface PayloadMigrationsSelect { updatedAt?: T; createdAt?: T; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "homepage-config". + */ +export interface HomepageConfig { + id: string; + heroImageDesktop: string | Media; + heroImageMobile: string | Media; + heroTitle?: string | null; + heroSubtitle?: string | null; + _status?: ('draft' | 'published') | null; + updatedAt?: string | null; + createdAt?: string | null; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "homepage-config_select". + */ +export interface HomepageConfigSelect { + heroImageDesktop?: T; + heroImageMobile?: T; + heroTitle?: T; + heroSubtitle?: T; + _status?: T; + updatedAt?: T; + createdAt?: T; + globalType?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "collections_widget". @@ -1117,7 +1149,7 @@ export interface TaskSchedulePublish { relationTo: 'sample'; value: string | Sample; } | null; - global?: string | null; + global?: 'homepage-config' | null; user?: (string | null) | User; }; output?: unknown; diff --git a/src/payload.config.ts b/src/payload.config.ts index 261a467..05820b3 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -14,6 +14,7 @@ import { plugins } from './plugins' import { defaultLexical } from '@/fields/defaultLexical' import { getServerSideURL, getServerSideOrigin } from './utilities/getURL' import { Sample } from './collections/durianpy-website/sample-website-collection.index' +import { HomepageConfig } from './globals/durianpy-website/HomepageConfig' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) @@ -94,6 +95,7 @@ export default buildConfig({ }), }), collections: [Media, Categories, Users, Sample], + globals: [HomepageConfig], cors: [getServerSideOrigin()].filter(Boolean).map((url) => { try { const { origin } = new URL(url!)