From 6deb6247f63f5aaa25550dc0398d50221c5383c1 Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <hello@tefkah.com>
Date: Sat, 9 Oct 2021 18:35:39 +0200
Subject: fix: images in preview

---
 util/processOrg.tsx | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

(limited to 'util/processOrg.tsx')

diff --git a/util/processOrg.tsx b/util/processOrg.tsx
index a025645..3f32d30 100644
--- a/util/processOrg.tsx
+++ b/util/processOrg.tsx
@@ -15,6 +15,7 @@ import rehype2react from 'rehype-react'
 import { PreviewLink } from '../components/Sidebar/Link'
 import { NodeByCite, NodeById } from '../pages'
 import React, { useMemo } from 'react'
+import { OrgImage } from '../components/Sidebar/OrgImage'
 
 export interface ProcessedOrgProps {
   nodeById: NodeById
@@ -26,7 +27,14 @@ export interface ProcessedOrgProps {
 }
 
 export const ProcessedOrg = (props: ProcessedOrgProps) => {
-  const { nodeById, setSidebarHighlightedNode, setPreviewNode, previewText, nodeByCite } = props
+  const {
+    nodeById,
+    setSidebarHighlightedNode,
+    setPreviewNode,
+    previewText,
+    nodeByCite,
+    previewNode,
+  } = props
 
   const processor = unified()
     .use(uniorgParse)
@@ -48,10 +56,13 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
               nodeById={nodeById}
               setPreviewNode={setPreviewNode}
             >
-              {typeof children === 'string' ? children : null}
+              {children}
             </PreviewLink>
           )
         },
+        img: ({ src }) => {
+          return <OrgImage src={src as string} file={previewNode.file} />
+        },
       },
     })
 
-- 
cgit v1.2.3

