From 8ef1c76ae113cfab4e9ca7d23dd8c867b71d9e4d Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 20 Feb 2023 00:48:38 +0100 Subject: [PATCH] this is ugly but it works --- src/components/Image.tsx | 41 +++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/components/Image.tsx b/src/components/Image.tsx index 9fe67a9..95c6499 100644 --- a/src/components/Image.tsx +++ b/src/components/Image.tsx @@ -1,13 +1,40 @@ +import ImageStyle from "@/styles/Image.module.sass" +import Link from "./Link"; +// const regex = /@(?\w*)@(?\w*\S*)/gm; + const Image = ({ src, alt }: { src: string, alt: string }) => { - return ( -
- {alt} -
- ); + const regex = /@(?\w+)@(?\w{2,}\.[a-z]{2,10})/gm; + if (alt.match(regex)) { + const newAlt = alt.replace("art by", "") + const sub = "https://$/@$"; + const link = newAlt.replace(regex, sub); + return ( +
+ {alt} + art by +
+ ) + } + + else { + + return ( +
+ {alt} + {alt} + +
+ ); + } }; export default Image; \ No newline at end of file