add: Layout, working permissions for papers

This commit is contained in:
Dominik Natter
2025-03-26 20:56:56 +01:00
parent c5c9cc37af
commit 6951e662c9
12 changed files with 308 additions and 146 deletions

View File

@@ -1,6 +1,11 @@
import type { CollectionConfig } from 'payload'
import path from 'path'
import { fileURLToPath } from 'url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export const Technologies: CollectionConfig = {
slug: 'technologies',
labels: {
@@ -11,7 +16,10 @@ export const Technologies: CollectionConfig = {
useAsTitle: 'name',
},
access: {
read: () => true,
create: ({ req: { user } }) => Boolean(user),
update: ({ req: { user } }) => Boolean(user?.type === "admin"),
delete: ({ req: { user } }) => Boolean(user?.type === "admin"),
},
fields: [
{
@@ -24,11 +32,22 @@ export const Technologies: CollectionConfig = {
type: 'textarea',
required: true,
},
{
name: 'icon',
type: 'upload',
relationTo: 'media',
required: true,
},
],
upload: {
// Upload to the public/media directory in Next.js making them publicly accessible even outside of Payload
staticDir: path.resolve(dirname, '../../public/technology-icons'),
adminThumbnail: 'thumbnail',
focalPoint: true,
imageSizes: [
{
name: 'thumbnail',
width: 300,
},
{
name: 'square',
width: 500,
height: 500,
},
],
},
}