# CMS Block Integration This directory contains utilities for integrating PayloadCMS custom blocks with the www marketing site blog. ## Overview PayloadCMS blog posts can contain custom blocks (Banner, MediaBlock, Code, Quote, YouTube) in addition to regular text content. This integration converts those blocks into the existing markdown/MDX syntax that the www blog already understands, ensuring seamless compatibility. ## Components ### convertRichTextToMarkdown.ts Enhanced conversion utilities: - `convertRichTextToMarkdownWithBlocks()` - Converts PayloadCMS rich text to markdown using existing www syntax - `convertRichTextToMarkdown()` - Legacy function for backward compatibility ### processCMSContent.ts Main processor that: 1. Converts PayloadCMS rich text to markdown using existing www component syntax 2. Generates table of contents from the converted content 3. Serializes content for MDX rendering ## Usage ### In Blog Pages ```typescript import { processCMSContent } from '~/lib/cms/processCMSContent' // Process CMS content - blocks are converted to existing www syntax const processedContent = await processCMSContent(cmsPost.content, tocDepth) // Use in blog data const blogData = { ...cmsPost, content: processedContent.content, // MDX with existing www components toc: processedContent.toc, } ``` ### Block Conversion Examples PayloadCMS blocks are automatically converted to existing www markdown syntax: ````typescript // PayloadCMS MediaBlock becomes: 'Description' // PayloadCMS Code block becomes: '```typescript\nconst example = "Hello world"\n```' // PayloadCMS Quote block becomes: '\n\nQuote text here\n\n' // PayloadCMS YouTube block becomes: '
\n