Docs

This page isn't translated yet

next

Post types and templates

Post types and custom post templates.

A post carries two independent selectors:

  • postType — a taxonomy value (article, video, …) used for filtering, archives, and queries. Options come from posts.types (default false → single implicit article). A single type hides the select.
  • postTemplate — which registered template renders the post. Options come from the post-template registry. A single default template hides the select.

The post-template registry mirrors the page-template registry exactly. The module ships a built-in Default Single-Post template; consumers add more via the top-level customPostTemplates option (or posts.templates). Each registered template contributes a per-template conditional field group to the Posts collection, shown when postTemplate equals that template's name or when postType equals it — the same prepareTemplateFields / syncPageTemplates mechanism Pages use.

// src/post-templates/VideoPost.tsx  — a custom post template
import type { SysthemaPostTemplate } from '@systhemaui/payload'
import { postHeroFields, postBodyField } from '@systhemaui/payload'

export const VideoPostTemplate: SysthemaPostTemplate = {
  name: 'video',
  label: 'Video',
  component: VideoPostComponent, // your React component rendering the post
  // These fields appear only when postTemplate === 'video':
  fields: [
    ...postHeroFields, // reuse the shipped (optional) hero field shape
    { name: 'videoUrl', type: 'text', required: true },
    { name: 'videoDuration', type: 'text' },
    postBodyField, // the region-level Lexical body field
  ],
}
// src/payload.config.ts — register it (mirrors customPageTemplates)
withSysthema(
  {
    posts: {
      enabled: true,
      types: ['Article', 'Video'],
    },
    customPostTemplates: [VideoPostTemplate],
  },
  baseConfig,
)

SysthemaPostTemplate is { name, label?, component, fields?, hero? } — the post-template equivalent of SysthemaPayloadPageTemplate. The shipped field shapes are re-exported so custom templates can reuse them: defaultPostTemplateFields, postHeroFields (hero defaults to heroType: 'none', so a content-only post is valid), and postBodyField (the region-level Lexical editor body — narrower than the page root editor; no Page/Component blocks).

The default post templateLink to this section

The built-in DefaultPost (@systhemaui/payload/next) renders the post's category as a muted kicker (.post-type) above the hero title and its tags as a <Chip> row in the hero append slot. Both default ON and are gated by the hero config show.kicker / show.tags (no dedicated General-Settings toggle) with classNames.kicker / classNames.tags overrides. A content-only (no-hero) post surfaces the kicker + byline + tags standalone above the body. Related posts render through the next-optimized <PostsList> (auto next/image via sizesForLayout) inside a <Section padding={0}>.