diff options
Diffstat (limited to 'components/Sidebar')
-rw-r--r-- | components/Sidebar/Link.tsx | 3 | ||||
-rw-r--r-- | components/Sidebar/OrgImage.tsx | 28 |
2 files changed, 30 insertions, 1 deletions
diff --git a/components/Sidebar/Link.tsx b/components/Sidebar/Link.tsx index 57fb723..4463fb8 100644 --- a/components/Sidebar/Link.tsx +++ b/components/Sidebar/Link.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/display-name */ import { Box, Button, @@ -140,7 +141,7 @@ export const PreviewLink = (props: LinkProps) => { const getText = () => { console.log('gettin text') - fetch(`http://localhost:35901/file/${file}`) + fetch(`127.0.0.1:35901/file/${file}`) .then((res) => { return res.text() }) diff --git a/components/Sidebar/OrgImage.tsx b/components/Sidebar/OrgImage.tsx new file mode 100644 index 0000000..e8773e2 --- /dev/null +++ b/components/Sidebar/OrgImage.tsx @@ -0,0 +1,28 @@ +import React, { useEffect, useState } from 'react' +import Image from 'next/image' +import path from 'path' +//import '../../../public/placeholder.png' + +export interface OrgImageProps { + src: string + file: string +} + +export const OrgImage = (props: OrgImageProps) => { + const { src, file } = props + + const [image, setImage] = useState<any>(null) + const dir = path.dirname(file) + const fullPath = encodeURIComponent(encodeURIComponent(path.join(dir, src))) + + /* ) +* .then((res) => res.blob()) +* .then((res) => setImage(res)) +* .catch((e) => { +* setImage(null) +* console.error(e) +* }) +}, [fullPath]) */ + + return <Image src={`http://localhost:35901/img/${fullPath}`} alt="" width={100} height={100} /> +} |