diff --git a/components/PayloadRichText.tsx b/components/PayloadRichText.tsx index 9e4dabb8..70f50e4b 100644 --- a/components/PayloadRichText.tsx +++ b/components/PayloadRichText.tsx @@ -45,6 +45,52 @@ const jsxConverters: JSXConverters = { ); } + // Handle markdown-style links [text](url) from MDX migration + if (text && /\[([^\]]+)\]\(([^)]+)\)/.test(text)) { + const parts: React.ReactNode[] = []; + const remaining = text; + let key = 0; + const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g; + let match; + let lastIndex = 0; + while ((match = linkRegex.exec(remaining)) !== null) { + if (match.index > lastIndex) { + parts.push({remaining.slice(lastIndex, match.index)}); + } + parts.push( + + {match[1]} + , + ); + lastIndex = match.index + match[0].length; + } + if (lastIndex < remaining.length) { + parts.push({remaining.slice(lastIndex)}); + } + return <>{parts}; + } + + // Handle newlines in text nodes — convert to
for proper line breaks + if (text && text.includes('\n')) { + const lines = text.split('\n'); + return ( + <> + {lines.map((line: string, i: number) => ( + + {line} + {i < lines.length - 1 &&
} +
+ ))} + + ); + } + if (node.format === 1) return {text}; if (node.format === 2) return {text}; return {text};