From 455daf6090a1cb6cbb6147e2ad28814f4554de5b Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Fri, 16 May 2025 15:36:31 -0600 Subject: [PATCH] update ad banner --- src/pages/parts/home/HeroPart.tsx | 124 +++++++++++++++++++++++------- 1 file changed, 96 insertions(+), 28 deletions(-) diff --git a/src/pages/parts/home/HeroPart.tsx b/src/pages/parts/home/HeroPart.tsx index 56717a67..3d7469a2 100644 --- a/src/pages/parts/home/HeroPart.tsx +++ b/src/pages/parts/home/HeroPart.tsx @@ -130,34 +130,102 @@ export function HeroPart({ setIsSticky, searchParams }: HeroPartProps) { {/* Optional ad */} {conf().SHOW_AD && !isAdDismissed ? ( -
- - {conf().AD_CONTENT_URL.length !== 0 ? ( -
- - ad banner - -
- ) : null} -

- - Your ad here (づ ᴗ _ᴗ)づ♡ - -

+
+ {(() => { + const adContentUrl = conf().AD_CONTENT_URL; + + // VITE_AD_CONTENT_URL=default message (null will be nothing),referal link,image link, card message + // Ensure adContentUrl is an array. If not, render nothing for ads. + if (!Array.isArray(adContentUrl)) { + return null; + } + + const ad1LinkIsValid = + typeof adContentUrl[1] === "string" && adContentUrl[1].length > 0; + const ad1ImageIsProvided = typeof adContentUrl[2] === "string"; + const showAd1 = + adContentUrl.length >= 2 && ad1LinkIsValid && ad1ImageIsProvided; + + const ad2LinkIsValid = + typeof adContentUrl[3] === "string" && adContentUrl[3].length > 0; + const ad2ImageIsProvided = typeof adContentUrl[4] === "string"; + const showAd2 = + adContentUrl.length >= 5 && ad2LinkIsValid && ad2ImageIsProvided; + + return ( + <> +
+ {showAd1 ? ( +
+ + +
+ ad banner +
+

+ {adContentUrl[3]} +

+
+
+ ) : null} + {showAd2 ? ( +
+ + +
+ ad banner +
+

+ {adContentUrl[6]} +

+
+
+ ) : null} +
+ {adContentUrl[0] !== "null" && ( +
+

+ + {adContentUrl[0]} + +

+
+ )} + + ); + })()}
) : null} {/* End of ad */}