Files
klz-cables.com/src/payload/collections/Products.ts
T
mmintel 0487bd8ebe
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m44s
Build & Deploy / 🏗️ Build (push) Successful in 3m55s
Build & Deploy / 🚀 Deploy (push) Successful in 19s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 33m41s
Build & Deploy / ⚡ Performance & Accessibility (push) Successful in 8m15s
Build & Deploy / 🔔 Notify (push) Successful in 2s
feat: show draft posts and products on testing and staging
2026-02-26 02:59:30 +01:00

136 lines
3.1 KiB
TypeScript

import type { CollectionConfig } from 'payload';
import { lexicalEditor, BlocksFeature } from '@payloadcms/richtext-lexical';
import { StickyNarrative } from '../blocks/StickyNarrative';
import { ComparisonGrid } from '../blocks/ComparisonGrid';
import { VisualLinkPreview } from '../blocks/VisualLinkPreview';
import { TechnicalGrid } from '../blocks/TechnicalGrid';
import { HighlightBox } from '../blocks/HighlightBox';
import { AnimatedImage } from '../blocks/AnimatedImage';
import { ChatBubble } from '../blocks/ChatBubble';
import { PowerCTA } from '../blocks/PowerCTA';
import { Callout } from '../blocks/Callout';
import { Stats } from '../blocks/Stats';
import { SplitHeading } from '../blocks/SplitHeading';
import { ProductTabs } from '../blocks/ProductTabs';
export const Products: CollectionConfig = {
slug: 'products',
admin: {
defaultColumns: ['featuredImage', 'title', 'sku', 'updatedAt', '_status'],
},
versions: {
drafts: true,
},
access: {
read: ({ req: { user } }) => {
if (process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging') {
return true;
}
if (user) {
return true;
}
return {
_status: {
equals: 'published',
},
};
},
},
fields: [
{
name: 'title',
type: 'text',
required: true,
localized: true,
},
{
name: 'sku',
type: 'text',
required: true,
admin: {
position: 'sidebar',
},
},
{
// slug is shared: the cable name (e.g. "n2xy") is the same in DE and EN
name: 'slug',
type: 'text',
required: true,
admin: {
position: 'sidebar',
},
},
{
name: 'description',
type: 'textarea',
required: true,
localized: true,
},
{
name: 'categories',
type: 'array',
required: true,
fields: [
{
name: 'category',
type: 'text',
},
],
admin: {
position: 'sidebar',
},
},
{
name: 'featuredImage',
type: 'upload',
relationTo: 'media',
admin: {
position: 'sidebar',
description: 'The primary thumbnail used in list views.',
},
},
{
name: 'images',
type: 'upload',
relationTo: 'media',
hasMany: true,
admin: {
position: 'sidebar',
},
},
{
name: 'application',
type: 'richText',
localized: true,
editor: lexicalEditor({}),
},
{
name: 'content',
type: 'richText',
localized: true,
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,
BlocksFeature({
blocks: [
StickyNarrative,
ComparisonGrid,
VisualLinkPreview,
TechnicalGrid,
HighlightBox,
AnimatedImage,
ChatBubble,
PowerCTA,
Callout,
Stats,
SplitHeading,
ProductTabs,
],
}),
],
}),
},
],
};