cms.c2sgmbh/src/blocks/PostsListBlock.ts
Martin Porwoll 95c9d2a4bc feat: add content blocks and global settings
Blocks for page builder:
- HeroBlock: hero sections with CTA
- TextBlock: rich text content
- ImageTextBlock: image with text layout
- CardGridBlock: grid of cards
- CTABlock: call-to-action sections
- QuoteBlock: testimonial quotes
- VideoBlock: embedded videos
- DividerBlock: visual separators
- ContactFormBlock: contact forms
- NewsletterBlock: newsletter signup
- ProcessStepsBlock: step-by-step processes
- TimelineBlock: timeline displays
- TestimonialsBlock: testimonial carousels
- PostsListBlock: blog post listings

Globals:
- Navigation: site navigation structure
- SiteSettings: general site configuration
- SEOSettings: default SEO settings per tenant

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 08:19:15 +00:00

159 lines
3.7 KiB
TypeScript

import type { Block } from 'payload'
/**
* Posts List Block
* Zeigt Blog-Artikel, News oder andere Post-Typen an
*/
export const PostsListBlock: Block = {
slug: 'posts-list-block',
labels: {
singular: 'Blog/News Liste',
plural: 'Blog/News Listen',
},
fields: [
{
name: 'title',
type: 'text',
label: 'Überschrift',
localized: true,
},
{
name: 'subtitle',
type: 'text',
label: 'Untertitel',
localized: true,
},
{
name: 'postType',
type: 'select',
required: true,
defaultValue: 'blog',
label: 'Beitragstyp',
options: [
{ label: 'Blog-Artikel', value: 'blog' },
{ label: 'News/Aktuelles', value: 'news' },
{ label: 'Pressemitteilungen', value: 'press' },
{ label: 'Ankündigungen', value: 'announcement' },
{ label: 'Alle Beiträge', value: 'all' },
],
},
{
name: 'layout',
type: 'select',
defaultValue: 'grid',
label: 'Layout',
options: [
{ label: 'Grid (Karten)', value: 'grid' },
{ label: 'Liste', value: 'list' },
{ label: 'Featured + Grid', value: 'featured' },
{ label: 'Kompakt (Sidebar)', value: 'compact' },
{ label: 'Masonry', value: 'masonry' },
],
},
{
name: 'columns',
type: 'select',
defaultValue: '3',
label: 'Spalten',
options: [
{ label: '2 Spalten', value: '2' },
{ label: '3 Spalten', value: '3' },
{ label: '4 Spalten', value: '4' },
],
admin: {
condition: (data, siblingData) =>
siblingData?.layout === 'grid' ||
siblingData?.layout === 'featured' ||
siblingData?.layout === 'masonry',
},
},
{
name: 'limit',
type: 'number',
defaultValue: 6,
min: 1,
max: 24,
label: 'Anzahl Beiträge',
},
{
name: 'showFeaturedOnly',
type: 'checkbox',
defaultValue: false,
label: 'Nur hervorgehobene anzeigen',
},
{
name: 'filterByCategory',
type: 'relationship',
relationTo: 'categories',
hasMany: true,
label: 'Nach Kategorien filtern',
admin: {
description: 'Leer = alle Kategorien',
},
},
{
name: 'showExcerpt',
type: 'checkbox',
defaultValue: true,
label: 'Kurzfassung anzeigen',
},
{
name: 'showDate',
type: 'checkbox',
defaultValue: true,
label: 'Datum anzeigen',
},
{
name: 'showAuthor',
type: 'checkbox',
defaultValue: false,
label: 'Autor anzeigen',
},
{
name: 'showCategory',
type: 'checkbox',
defaultValue: true,
label: 'Kategorie anzeigen',
},
{
name: 'showPagination',
type: 'checkbox',
defaultValue: false,
label: 'Pagination anzeigen',
},
{
name: 'showReadMore',
type: 'checkbox',
defaultValue: true,
label: '"Alle anzeigen" Link',
},
{
name: 'readMoreLabel',
type: 'text',
defaultValue: 'Alle Beiträge anzeigen',
localized: true,
admin: {
condition: (data, siblingData) => siblingData?.showReadMore,
},
},
{
name: 'readMoreLink',
type: 'text',
defaultValue: '/blog',
admin: {
condition: (data, siblingData) => siblingData?.showReadMore,
},
},
{
name: 'backgroundColor',
type: 'select',
defaultValue: 'white',
label: 'Hintergrund',
options: [
{ label: 'Weiß', value: 'white' },
{ label: 'Hell (Grau)', value: 'light' },
{ label: 'Dunkel', value: 'dark' },
],
},
],
}