From d84f9331540cc2296147dd25e4c06fd890bc4560 Mon Sep 17 00:00:00 2001 From: "bastien.ollier@etu.uca.fr" Date: Tue, 3 Jan 2023 09:49:51 +0100 Subject: [PATCH] =?UTF-8?q?fin=20pr=C3=A9visualisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Site Web/client/src/components/Post/Post.js | 31 +++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Site Web/client/src/components/Post/Post.js b/Site Web/client/src/components/Post/Post.js index 296a3002..3f1463e7 100644 --- a/Site Web/client/src/components/Post/Post.js +++ b/Site Web/client/src/components/Post/Post.js @@ -10,7 +10,9 @@ const LinkPreview = ({ link }) => { const [preview, setPreview] = useState({ image: '', title: '', description: '' }); useEffect(() => { - const key = '9f24d981b6f0ddfce993ce4a20d58867'; + //const key = '9f24d981b6f0ddfce993ce4a20d58867'; + const key = '2865b6b9d9571dc00bf940fad5728248'; + const fullLink = `http://api.linkpreview.net/?key=${key}&q=${link}`; axios @@ -19,17 +21,19 @@ const LinkPreview = ({ link }) => { .catch((err) => console.error(err)); }, [link]); - return ( -
- - {preview.title} - - - {link} - -

{preview.description}

-
- ); + if(preview.image === "") { + return (
{link}
); + } + else { + return ( +
+ + {preview.title}/ + +

{preview.description}

+
+ ); + } }; //e.preventDefaul(); pour ne pas recharcher la page @@ -75,10 +79,9 @@ const Post = ( { post } ) => {
- +

{post.message}

-