Add Portfolio collection with 7 fields
Create Portfolio collection for managing website portfolio items. Includes title, slug, url, image, description, websiteType, and tags fields. Configured access control for authenticated create/ update/delete operations with public read access.
This commit is contained in:
75
apps/backend/src/collections/Portfolio/index.ts
Normal file
75
apps/backend/src/collections/Portfolio/index.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import { authenticated } from '../../access/authenticated'
|
||||
import { anyone } from '../../access/anyone'
|
||||
import { slugField } from '@/fields/slug'
|
||||
|
||||
export const Portfolio: CollectionConfig = {
|
||||
slug: 'portfolio',
|
||||
access: {
|
||||
create: authenticated,
|
||||
read: anyone,
|
||||
update: authenticated,
|
||||
delete: authenticated,
|
||||
},
|
||||
admin: {
|
||||
useAsTitle: 'title',
|
||||
defaultColumns: ['title', 'websiteType', 'updatedAt'],
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'url',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Website URL (e.g., https://example.com)',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'image',
|
||||
type: 'upload',
|
||||
relationTo: 'media',
|
||||
required: true,
|
||||
admin: {
|
||||
description: 'Preview image stored in R2',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
type: 'textarea',
|
||||
},
|
||||
{
|
||||
name: 'websiteType',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '企業官網', value: 'corporate' },
|
||||
{ label: '電商網站', value: 'ecommerce' },
|
||||
{ label: '活動頁面', value: 'landing' },
|
||||
{ label: '品牌網站', value: 'brand' },
|
||||
{ label: '其他', value: 'other' },
|
||||
],
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'tags',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{
|
||||
name: 'tag',
|
||||
type: 'text',
|
||||
},
|
||||
],
|
||||
},
|
||||
...slugField(),
|
||||
],
|
||||
versions: {
|
||||
drafts: {
|
||||
autosave: true,
|
||||
},
|
||||
maxPerDoc: 10,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user