Payload Markdown
@valkyrianlabs/payload-markdown adds portable Markdown authoring to Payload CMS. It provides a CodeMirror-backed admin field, an optional reusable Payload block, server-rendered Markdown output, Shiki code highlighting, heading anchors, GFM support, and registry-backed content directives.
The stored value remains Markdown. Configuration, presentation, directive themes, and code rendering stay in source-controlled Payload config instead of being baked into CMS-authored content.
Install the plugin, enable it for a collection, then render the stored field or block content with the server export.
Start
Install and Configure
Register payloadMarkdown() in Payload and choose whether collections receive a field, a block, or both.
Render
Fields and Blocks
Use the server renderer for Markdown fields and the block component for vlMdBlock layout entries.
Shape
Directives
Use readable directives for callouts, details, TOCs, steps, cards, buttons, tabs, sections, columns, and cells.
Quick Install
1pnpm add @valkyrianlabs/payload-markdown
1import { payloadMarkdown } from '@valkyrianlabs/payload-markdown'2import type { Config } from 'payload'3 4const config: Config = {5 plugins: [6 payloadMarkdown({7 collections: {8 posts: true,9 },10 }),11 ],12}13 14export default config
1import { MarkdownRenderer } from '@valkyrianlabs/payload-markdown/server'2 3export function PostBody({ content }: { content?: string | null }) {4 return <MarkdownRenderer collectionSlug="posts" markdown={content} />5}
What It Covers
- Plain Markdown storage for portable content.
- Automatic Markdown field installation for field-first collections.
- Automatic
vlMdBlockinstallation for collections withblocksfields. - Manual
markdownField()andMarkdownBlockexports for explicit schemas. - Server-rendered Markdown with Shiki, GFM, heading anchors, and sanitized HTML.
- Directive rendering for content patterns that should stay readable in Git.
- CodeMirror autocomplete, snippet variants, syntax highlighting, closing labels, and non-fatal diagnostics.
- Local SVG icon packs for buttons, cards, and callouts.
- Top-level and collection-scoped
code,themes, andconfignamespaces. - Stable hook classes and
data-*attributes for styling and tests.
Documentation Map
Getting Started
Installation, collection setup, field and block behavior, and basic rendering.
Configuration
Plugin options, scoping rules, Shiki code behavior, styling, and directive theme registries.
Directives
Supported directive syntax, attributes, defaults, diagnostics, and rendering behavior.
Authoring
Editor behavior, Markdown-in-Markdown examples, and copyable content patterns.
Advanced
Troubleshooting, migration notes, and edge cases.
API Reference
Exports, option shapes, renderer props, directive names, and default theme exports.