From 28b76ba05d8c593ee5252299b0b177f2494004d4 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Thu, 14 Oct 2021 16:30:30 +0200 Subject: fix: display non-rel image --- components/Sidebar/OrgImage.tsx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'components/Sidebar/OrgImage.tsx') diff --git a/components/Sidebar/OrgImage.tsx b/components/Sidebar/OrgImage.tsx index f9f508a..60bcdfb 100644 --- a/components/Sidebar/OrgImage.tsx +++ b/components/Sidebar/OrgImage.tsx @@ -22,18 +22,32 @@ export const OrgImage = (props: OrgImageProps) => { * }) }, [fullPath]) */ - const dir = path.dirname(file) - const fullPath = encodeURIComponent(encodeURIComponent(path.join(dir, src))) - const dumbLoader = ({ src, width, quality }: { [key: string]: string | number }) => { + return `${src}` + } + const homeLoader = ({ src, width, quality }: { [key: string]: string | number }) => { return `http://localhost:35901/img/${src}` } + if (src.replaceAll(/(http)?.*/g, '$1')) { + console.log(src.replaceAll(/(http)?.*/g, '$1')) + return ( + + ) + } + + const srcName = src.replaceAll(/file:/g, '') + + const dir = path.dirname(file) + const fullPath = + path.isAbsolute(srcName) || srcName.slice(0, 1) === '~' ? srcName : path.join(dir, srcName) + const encodedPath = encodeURIComponent(encodeURIComponent(fullPath)) + return (