diff options
| author | Bertrand Yuan <bert.yuan@outlook.com> | 2025-12-16 00:25:04 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-16 00:25:04 +0800 |
| commit | 39c83fbb69ef06d2d56790d75abc254ba7e34394 (patch) | |
| tree | dd006593448c3500bdcb414af3b4656f7a7683d4 /src/payload/collections | |
| parent | 48b07bc308a35734a6a7a305c8fdccbfa47de7d8 (diff) | |
| parent | 785371bb3eccca455e5ce5fccbe9b6e3752a03f6 (diff) | |
Merge pull request #1 from bertyuan/feat-introduce-payloadv1.0
Feat: introduce payload
Diffstat (limited to 'src/payload/collections')
| -rw-r--r-- | src/payload/collections/Media.ts | 23 | ||||
| -rw-r--r-- | src/payload/collections/Posts.ts | 93 | ||||
| -rw-r--r-- | src/payload/collections/Users.ts | 20 |
3 files changed, 136 insertions, 0 deletions
diff --git a/src/payload/collections/Media.ts b/src/payload/collections/Media.ts new file mode 100644 index 0000000..45525db --- /dev/null +++ b/src/payload/collections/Media.ts @@ -0,0 +1,23 @@ +import type { CollectionConfig } from 'payload'; + +export const Media: CollectionConfig = { + slug: 'media', + labels: { + singular: 'media', + plural: 'medias', + }, + access: { + read: () => true, + }, + upload: { + staticDir: 'public/media', + mimeTypes: ['image/*'], + }, + fields: [ + { + name: 'alt', + label: '替代文本', + type: 'text', + }, + ], +}; diff --git a/src/payload/collections/Posts.ts b/src/payload/collections/Posts.ts new file mode 100644 index 0000000..6ecf898 --- /dev/null +++ b/src/payload/collections/Posts.ts @@ -0,0 +1,93 @@ +import type { CollectionConfig } from 'payload'; + +export const Posts: CollectionConfig = { + slug: 'posts', + labels: { + singular: 'posts', + plural: 'posts', + }, + admin: { + useAsTitle: 'title', + defaultColumns: ['title', 'status', 'publishedAt', 'updatedAt'], + }, + access: { + read: () => true, + }, + fields: [ + { + name: 'title', + label: 'title', + type: 'text', + required: true, + }, + { + name: 'slug', + label: 'slug', + type: 'text', + required: true, + unique: true, + admin: { + description: 'example:my-first-post', + }, + }, + { + name: 'description', + label: 'description', + type: 'textarea', + }, + { + name: 'content', + label: 'content', + type: 'richText', + required: true, + }, + { + name: 'featuredImage', + label: 'image', + type: 'upload', + relationTo: 'media', + }, + { + name: 'author', + label: 'author', + type: 'text', + defaultValue: 'Admin', + }, + { + name: 'tags', + label: 'tag', + type: 'array', + fields: [ + { + name: 'tag', + label: 'tag', + type: 'text', + }, + ], + }, + { + name: 'status', + label: 'status', + type: 'select', + defaultValue: 'draft', + options: [ + { label: 'draft', value: 'draft' }, + { label: 'published', value: 'published' }, + ], + admin: { + position: 'sidebar', + }, + }, + { + name: 'publishedAt', + label: 'publishedAt', + type: 'date', + admin: { + position: 'sidebar', + date: { + pickerAppearance: 'dayAndTime', + }, + }, + }, + ], +}; diff --git a/src/payload/collections/Users.ts b/src/payload/collections/Users.ts new file mode 100644 index 0000000..730cde2 --- /dev/null +++ b/src/payload/collections/Users.ts @@ -0,0 +1,20 @@ +import type { CollectionConfig } from 'payload'; + +export const Users: CollectionConfig = { + slug: 'users', + labels: { + singular: 'users', + plural: 'users', + }, + admin: { + useAsTitle: 'email', + }, + auth: true, + fields: [ + { + name: 'name', + label: 'name', + type: 'text', + }, + ], +}; |
