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:
2026-01-31 12:54:36 +08:00
parent e632a9d010
commit 2d3d144a66
4 changed files with 186 additions and 383 deletions

View 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,
},
}