import { RichText, defaultJSXConverters, } from "@payloadcms/richtext-lexical/react"; import type { JSXConverters } from "@payloadcms/richtext-lexical/react"; import { MemeCard } from "@/src/components/MemeCard"; import { Mermaid } from "@/src/components/Mermaid"; import { LeadMagnet } from "@/src/components/LeadMagnet"; import { ComparisonRow } from "@/src/components/Landing/ComparisonRow"; import { mdxComponents } from "../content-engine/components"; import React from "react"; /** * Renders markdown-style inline links [text](/url) as tags. * Used by mintelP blocks which store body text with links. */ function renderInlineMarkdown(text: string): React.ReactNode { if (!text) return null; const parts = text.split(/(\[[^\]]+\]\([^)]+\)|[^<]*<\/Marker>)/); return parts.map((part, i) => { const linkMatch = part.match(/\[([^\]]+)\]\(([^)]+)\)/); if (linkMatch) { return ( {linkMatch[1]} ); } const markerMatch = part.match(/([^<]*)<\/Marker>/); if (markerMatch) { return ( {markerMatch[1]} ); } return {part}; }); } const jsxConverters: JSXConverters = { ...defaultJSXConverters, // Override paragraph to filter out leftover raw text paragraph: ({ node, nodesToJSX }: any) => { const children = node?.children; if ( children?.length === 1 && children[0]?.type === "text" && children[0]?.text?.trim()?.startsWith("<") && children[0]?.text?.trim()?.endsWith("/>") ) { return null; // suppress raw JSX component text like } return

{nodesToJSX({ nodes: children })}

; }, blocks: { memeCard: ({ node }: any) => (
), mermaid: ({ node }: any) => (
{node.fields.chartDefinition}
), leadMagnet: ({ node }: any) => (
), comparisonRow: ({ node }: any) => ( ), // --- Core text blocks --- mintelP: ({ node }: any) => (

{renderInlineMarkdown(node.fields.text)}

), mintelTldr: ({ node }: any) => ( {node.fields.content} ), // --- MDX Registry Injections --- leadParagraph: ({ node }: any) => ( {node.fields.text} ), articleBlockquote: ({ node }: any) => ( {node.fields.quote} {node.fields.author && ` - ${node.fields.author}`} ), mintelH2: ({ node }: any) => ( {node.fields.text} ), mintelH3: ({ node }: any) => ( {node.fields.text} ), mintelHeading: ({ node }: any) => { const displayLevel = node.fields.displayLevel || "h2"; if (displayLevel === "h3") return {node.fields.text}; return {node.fields.text}; }, statsDisplay: ({ node }: any) => ( ), diagramState: ({ node }: any) => (
{node.fields.definition}
), diagramTimeline: ({ node }: any) => (
{node.fields.definition}
), diagramGantt: ({ node }: any) => (
{node.fields.definition}
), diagramPie: ({ node }: any) => (
{node.fields.definition}
), diagramSequence: ({ node }: any) => (
{node.fields.definition}
), diagramFlow: ({ node }: any) => (
{node.fields.definition}
), waterfallChart: ({ node }: any) => ( ), premiumComparisonChart: ({ node }: any) => ( ), iconList: ({ node }: any) => ( {node.fields.items?.map((item: any, i: number) => { const isCheck = item.icon === "check" || !item.icon; const isCross = item.icon === "x" || item.icon === "cross"; const isBullet = item.icon === "circle" || item.icon === "bullet"; return ( // @ts-ignore {item.title || item.description} ); })} ), statsGrid: ({ node }: any) => { const rawStats = node.fields.stats || []; let statsStr = ""; if (Array.isArray(rawStats)) { statsStr = rawStats .map((s: any) => `${s.value || ""}|${s.label || ""}`) .join("~"); } else if (typeof rawStats === "string") { statsStr = rawStats; } return ; }, metricBar: ({ node }: any) => ( ), carousel: ({ node }: any) => ( ({ title: s.title || s.caption || "Slide", content: s.content || s.caption || "", icon: undefined, })) || [] } /> ), imageText: ({ node }: any) => ( {node.fields.text} ), revenueLossCalculator: ({ node }: any) => ( ), performanceChart: ({ node }: any) => , performanceROICalculator: ({ node }: any) => (
), loadTimeSimulator: ({ node }: any) => (
), architectureBuilder: ({ node }: any) => (
), digitalAssetVisualizer: ({ node }: any) => (
), twitterEmbed: ({ node }: any) => ( ), youTubeEmbed: ({ node }: any) => ( ), linkedInEmbed: ({ node }: any) => ( ), externalLink: ({ node }: any) => ( {node.fields.label} ), trackedLink: ({ node }: any) => ( {node.fields.label} ), articleMeme: ({ node }: any) => ( ), marker: ({ node }: any) => ( {node.fields.text} ), boldNumber: ({ node }: any) => ( ), webVitalsScore: ({ node }: any) => ( ), buttonBlock: ({ node }: any) => ( {node.fields.label} ), articleQuote: ({ node }: any) => ( ), reveal: ({ node }: any) => ( {/* Reveal component takes children, which in MDX is nested content */} ), section: ({ node }: any) => ( ), tableOfContents: () => , faqSection: ({ node }: any) => ( ), }, }; export function PayloadRichText({ data }: { data: any }) { if (!data) return null; return (
); }