diff --git a/components/RichBody.tsx b/components/RichBody.tsx index 6913910..8bb65c0 100644 --- a/components/RichBody.tsx +++ b/components/RichBody.tsx @@ -76,16 +76,33 @@ export function RichBody(props: Props): ReactElement { // const children; const plaintext = documentToPlainTextString(node); const isShortcode = CMS.SHORTCODE_REGEX.test(plaintext); - - return isShortcode ? ( - renderShortcode(plaintext) - ) : ( -

- {children} -

- ); + if (isShortcode) { + return renderShortcode(plaintext); + } else { + let hasImage = false; + Children.map(children, (child: any) => { + if (child.type === 'figure') { + hasImage = true; + return; + } + }); + if (hasImage) { + return ( + + {children} + + ); + } + return ( +

+ {children} +

+ ); + } }, [BLOCKS.HEADING_1]: (node, children) => (

+