From fffcdc732449021bd879c5406f0b6fc0d410447d Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 28 Jul 2026 09:03:27 +0000 Subject: [PATCH] Deploy --- .../sections/AdvertBannerSection.tsx | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/components/sections/AdvertBannerSection.tsx diff --git a/src/components/sections/AdvertBannerSection.tsx b/src/components/sections/AdvertBannerSection.tsx new file mode 100644 index 0000000..96cae6f --- /dev/null +++ b/src/components/sections/AdvertBannerSection.tsx @@ -0,0 +1,49 @@ +import Image from 'next/image' +import Link from 'next/link' +import { getAdvertBanners } from '@/lib/cms' + +export default async function AdvertBannerSection() { + const items = await getAdvertBanners() + const now = Date.now() + const banner = items.find(item => { + const start = item.data.start_date ? new Date(item.data.start_date as string).getTime() : 0 + const end = item.data.end_date ? new Date(item.data.end_date as string).getTime() : Infinity + return now >= start && now <= end + }) ?? items[0] + + if (!banner) return null + + const { headline, subheadline, cta_text, cta_url, image } = banner.data as { + headline: string; subheadline?: string; cta_text?: string; cta_url?: string; image?: string + } + + return ( +
+ {image ? ( +
+ {headline} +
+
+

{headline}

+ {subheadline &&

{subheadline}

} + {cta_text && cta_url && ( + + {cta_text} + + )} +
+
+ ) : ( +
+

{headline}

+ {subheadline &&

{subheadline}

} + {cta_text && cta_url && ( + + {cta_text} + + )} +
+ )} +
+ ) +}