From a1644ab47f452b9d6e9006687844a5bc37e9e4ec Mon Sep 17 00:00:00 2001 From: DrMint Date: Sat, 23 Apr 2022 20:29:38 +0200 Subject: [PATCH] Img component now support raw url --- src/components/Img.tsx | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/components/Img.tsx b/src/components/Img.tsx index 84e0606..e60a372 100644 --- a/src/components/Img.tsx +++ b/src/components/Img.tsx @@ -3,38 +3,29 @@ import Image, { ImageProps } from "next/image"; interface Props { className?: string; - image?: UploadImageFragment; + image?: UploadImageFragment | string; quality?: ImageQuality; alt?: ImageProps["alt"]; layout?: ImageProps["layout"]; objectFit?: ImageProps["objectFit"]; priority?: ImageProps["priority"]; - rawImg?: boolean; } export default function Img(props: Props): JSX.Element { - if (props.image?.width && props.image?.height) { + if (typeof props.image === "string") { + return ( + {props.alt + ); + } else if (props.image?.width && props.image.height) { const imgSize = getImgSizesByQuality( props.image.width, props.image.height, props.quality ?? ImageQuality.Small ); - - if (props.rawImg) { - return ( - // eslint-disable-next-line @next/next/no-img-element - {props.alt - ); - } return (