feat: payload cms

This commit is contained in:
2026-02-26 01:32:22 +01:00
parent 1963a93123
commit 7d65237ee9
67 changed files with 3179 additions and 760 deletions

View File

@@ -1,44 +1,65 @@
import { CollectionConfig } from 'payload';
import { lexicalEditor } from '@payloadcms/richtext-lexical';
import { lexicalEditor, BlocksFeature } from '@payloadcms/richtext-lexical';
import { payloadBlocks } from '../blocks/allBlocks';
export const Pages: CollectionConfig = {
slug: 'pages',
admin: {
useAsTitle: 'title',
defaultColumns: ['title', 'slug', 'locale', 'updatedAt'],
defaultColumns: ['title', 'slug', 'layout', '_status', 'updatedAt'],
},
versions: {
drafts: true,
},
access: {
read: () => true,
read: ({ req: { user } }) => {
if (process.env.NODE_ENV === 'development') {
return true;
}
if (user) {
return true;
}
return {
_status: {
equals: 'published',
},
};
},
},
fields: [
{
name: 'title',
type: 'text',
required: true,
localized: true,
},
{
name: 'slug',
type: 'text',
required: true,
localized: true,
admin: {
position: 'sidebar',
description: 'The URL slug for this locale (e.g. "impressum" for DE, "imprint" for EN).',
},
},
{
name: 'locale',
name: 'layout',
type: 'select',
defaultValue: 'default',
options: [
{ label: 'English', value: 'en' },
{ label: 'German', value: 'de' },
{ label: 'Default (Article)', value: 'default' },
{ label: 'Full Bleed (Blocks Only)', value: 'fullBleed' },
],
required: true,
admin: {
position: 'sidebar',
description: 'Full Bleed pages render blocks edge-to-edge without a generic hero wrapper.',
},
},
{
name: 'excerpt',
type: 'textarea',
localized: true,
admin: {
position: 'sidebar',
},
@@ -54,7 +75,15 @@ export const Pages: CollectionConfig = {
{
name: 'content',
type: 'richText',
editor: lexicalEditor({}),
localized: true,
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,
BlocksFeature({
blocks: payloadBlocks,
}),
],
}),
required: true,
},
],

View File

@@ -19,22 +19,16 @@ export const Posts: CollectionConfig = {
defaultColumns: ['featuredImage', 'title', 'date', 'updatedAt', '_status'],
},
versions: {
drafts: true, // Enables Draft/Published workflows
drafts: true,
},
access: {
read: ({ req: { user } }) => {
// In local development, always show everything (including Drafts and scheduled future posts)
if (process.env.NODE_ENV === 'development') {
return true;
}
// If an Admin user is logged in, they can view everything
if (user) {
return true;
}
// For public unauthenticated visitors in PROD/STAGING contexts:
// Only serve Posts where Status = "published" AND the publish Date is in the past!
return {
and: [
{
@@ -56,19 +50,20 @@ export const Posts: CollectionConfig = {
name: 'title',
type: 'text',
required: true,
localized: true,
},
{
name: 'slug',
type: 'text',
required: true,
unique: true,
localized: true,
admin: {
position: 'sidebar',
description: 'Unique slug per locale (e.g. same slug can exist in DE and EN).',
},
hooks: {
beforeValidate: [
({ value, data }) => {
// Auto-generate slug from title if left blank
if (value || !data?.title) return value;
return data.title
.toLowerCase()
@@ -81,6 +76,7 @@ export const Posts: CollectionConfig = {
{
name: 'excerpt',
type: 'text',
localized: true,
admin: {
description: 'A short summary for blog feed cards and SEO.',
},
@@ -104,22 +100,10 @@ export const Posts: CollectionConfig = {
description: 'The primary Hero image used for headers and OpenGraph previews.',
},
},
{
name: 'locale',
type: 'select',
required: true,
admin: {
position: 'sidebar',
},
options: [
{ label: 'English', value: 'en' },
{ label: 'German', value: 'de' },
],
defaultValue: 'en',
},
{
name: 'category',
type: 'text',
localized: true,
admin: {
position: 'sidebar',
description: 'Used for tag bucketing (e.g. "Kabel Technologie").',
@@ -128,6 +112,7 @@ export const Posts: CollectionConfig = {
{
name: 'content',
type: 'richText',
localized: true,
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,

View File

@@ -17,7 +17,7 @@ import { ProductTabs } from '../blocks/ProductTabs';
export const Products: CollectionConfig = {
slug: 'products',
admin: {
defaultColumns: ['featuredImage', 'title', 'sku', 'locale', 'updatedAt', '_status'],
defaultColumns: ['featuredImage', 'title', 'sku', 'updatedAt', '_status'],
},
versions: {
drafts: true,
@@ -42,6 +42,7 @@ export const Products: CollectionConfig = {
name: 'title',
type: 'text',
required: true,
localized: true,
},
{
name: 'sku',
@@ -52,6 +53,7 @@ export const Products: CollectionConfig = {
},
},
{
// slug is shared: the cable name (e.g. "n2xy") is the same in DE and EN
name: 'slug',
type: 'text',
required: true,
@@ -63,19 +65,7 @@ export const Products: CollectionConfig = {
name: 'description',
type: 'textarea',
required: true,
},
{
name: 'locale',
type: 'select',
required: true,
admin: {
position: 'sidebar',
},
options: [
{ label: 'English', value: 'en' },
{ label: 'German', value: 'de' },
],
defaultValue: 'de',
localized: true,
},
{
name: 'categories',
@@ -112,11 +102,13 @@ export const Products: CollectionConfig = {
{
name: 'application',
type: 'richText',
localized: true,
editor: lexicalEditor({}),
},
{
name: 'content',
type: 'richText',
localized: true,
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,