Block:
import { Block } from "payload";
import { IdentifierField } from "@/fields/Identifer";
export const ProductsBlock: Block = {
slug: 'products-block',
interfaceName: 'BlockProducts',
labels: {
singular: 'Product',
plural: 'Products',
},
fields: [
{
name: 'items',
label: 'Products',
type: 'relationship',
relationTo: 'products',
hasMany: true,
admin: {
description: 'Select products to display.',
},
maxDepth: 20,
},
// etc,
],
}Products:
import type { CollectionConfig } from 'payload';
export const Products: CollectionConfig = {
slug: 'products',
dbName: 'products',
timestamps: true,
labels: {
singular: 'Product',
plural: 'Products',
},
versions: {
drafts: false,
maxPerDoc: 10,
},
fields: [
{
type: 'tabs',
tabs: [
{
label: 'Content',
fields: [
{
name: 'partner',
label: 'Partner',
type: 'relationship',
relationTo: 'partners',
hasMany: false,
admin: {
description: 'Select the partner that this product belongs to.',
},
maxDepth: 20,
},
],
},
],
},
],
};Partners:
import type { CollectionConfig } from 'payload';
export const Partners: CollectionConfig = {
slug: 'partners',
dbName: 'partners',
timestamps: true,
labels: {
singular: 'Partner',
plural: 'Partners',
},
versions: {
drafts: false,
maxPerDoc: 10,
},
fields: [
{
type: 'tabs',
tabs: [
{
label: 'Content',
fields: [
{
name: 'logo',
label: 'Logo',
type: 'upload',
relationTo: 'media',
maxDepth: 20,
},
],
},
],
},
],
};