diff options
Diffstat (limited to 'components/Sidebar')
-rw-r--r-- | components/Sidebar/Link.tsx | 1 | ||||
-rw-r--r-- | components/Sidebar/OrgImage.tsx | 24 |
2 files changed, 20 insertions, 5 deletions
diff --git a/components/Sidebar/Link.tsx b/components/Sidebar/Link.tsx index f3ada7d..9f6ed76 100644 --- a/components/Sidebar/Link.tsx +++ b/components/Sidebar/Link.tsx @@ -102,6 +102,7 @@ export const PreviewLink = (props: LinkProps) => { const [whatever, type, uri] = [...href.matchAll(/(.*?)\:(.*)/g)][0] const [hover, setHover] = useState(false) + console.log(href) const getId = (type: string, uri: string) => { if (type === 'id') { return uri 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 ( + <Image layout="responsive" loader={dumbLoader} src={src} alt="" width="100%" height="100%" /> + ) + } + + 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 ( <Image layout="responsive" - loader={dumbLoader} - src={fullPath} + loader={homeLoader} + src={encodedPath} alt="" width="100%" height="100%" |