diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 5ff61c4..c6f01ac 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -108,11 +108,7 @@ export default async function Home() { -
-
- -
-
+ ); } diff --git a/frontend/src/components/HeroWrapper.tsx b/frontend/src/components/HeroWrapper.tsx index 30ea1a0..88e983d 100644 --- a/frontend/src/components/HeroWrapper.tsx +++ b/frontend/src/components/HeroWrapper.tsx @@ -21,29 +21,52 @@ query Query($publicationState: PublicationState) { } } }`); - export default async function HeroWrapper() { const graphqlData = await getClient().query({ query: GET_HERO_DATA, }); - if (graphqlData.data === null || graphqlData.data === undefined) { - return
There are no projects to show.
; + // Check if data is available + if ( + !graphqlData.data || + !graphqlData.data.hero || + !graphqlData.data.hero.data + ) { + return <>; + } + + const heroData = graphqlData.data.hero.data; + const heroAttributes = heroData.attributes; + + if (!heroAttributes || !heroAttributes.image?.data) { + return <>; + } + + const imageUrl = STRAPI_URL! + heroAttributes.image?.data?.attributes?.url; + if (!isValidUrl(imageUrl)) { + return
Invalid image URL.
; } return ( <> - +
+
+ +
+
); } + +function isValidUrl(urlString: string): boolean { + try { + new URL(urlString); + return true; + } catch (e) { + return false; + } +}