From 047508e5dabb5dc865a97f70fd8c9af70f27d267 Mon Sep 17 00:00:00 2001 From: spencerwooo Date: Sat, 4 Sep 2021 14:39:00 +0100 Subject: [PATCH] markdown render image with size params (#89) --- components/previews/MarkdownPreview.tsx | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/components/previews/MarkdownPreview.tsx b/components/previews/MarkdownPreview.tsx index 4957c58..7fbc44d 100644 --- a/components/previews/MarkdownPreview.tsx +++ b/components/previews/MarkdownPreview.tsx @@ -26,16 +26,37 @@ const MarkdownPreview: FunctionComponent<{ file: any; path: string; standalone?: const isUrlAbsolute = url => url.indexOf('://') > 0 || url.indexOf('//') === 0 // Custom renderer to render images with relative path const relativeImagePathRenderer = { - img: ({ alt, src, title, style }: { alt?: string; src?: string; title?: string; style?: CSSProperties }) => { + img: ({ + alt, + src, + title, + width, + height, + style, + }: { + alt?: string + src?: string + title?: string + width?: string | number + height?: string | number + style?: CSSProperties + }) => { if (isUrlAbsolute(src as string)) { return ( // eslint-disable-next-line @next/next/no-img-element - {alt} + {alt} ) } return ( // eslint-disable-next-line @next/next/no-img-element - {alt} + {alt} ) }, }