From 1f81236d0aabcba23f24590c725930296bcaaa6b Mon Sep 17 00:00:00 2001 From: "amirhosein.ashourloo" Date: Mon, 17 Aug 2026 11:57:46 +0330 Subject: [PATCH] set static images --- src/app/page.tsx | 46 +++++++++++++++----- src/components/home/HeroSlider.tsx | 53 +++++++++++++++++------ src/components/home/ThreeBanners.tsx | 60 ++++++++++++++++++------- src/components/home/TwoBanners.tsx | 65 ++++++++++++++++++++-------- src/lib/meshkee.ts | 61 ++++++++++++-------------- 5 files changed, 192 insertions(+), 93 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 8943a97..0fdf1bc 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -18,33 +18,55 @@ import { getProducts, getBrandGroups, getStoreSpecials, + getStaticImageSlots, + imagesForSlot, + STATIC_IMAGE_KEYS, } from "@/lib/meshkee"; export default async function Home() { - const [categoryGroups, categories, storeSpecials, productsResult, brandGroups, businessInfo] = - await Promise.all([ - getCategoryGroups(), - getCategories(), - getStoreSpecials(), - getProducts({ pageSize: 12 }), - getBrandGroups(), - getBusinessInfo(), - ]); + const [ + categoryGroups, + categories, + storeSpecials, + productsResult, + brandGroups, + businessInfo, + staticImageSlots, + ] = await Promise.all([ + getCategoryGroups(), + getCategories(), + getStoreSpecials(), + getProducts({ pageSize: 12 }), + getBrandGroups(), + getBusinessInfo(), + getStaticImageSlots(), + ]); const specialSaleProducts = storeSpecials[0]?.items ?? []; + const twoBannerSlot = staticImageSlots.find((slot) => slot.key === STATIC_IMAGE_KEYS.twoBanner); + const threeBannerSlot = staticImageSlots.find( + (slot) => slot.key === STATIC_IMAGE_KEYS.threeBannerRow, + ); + const heroImages = imagesForSlot(staticImageSlots, STATIC_IMAGE_KEYS.homeHero); return ( <>
- + - + - + diff --git a/src/components/home/HeroSlider.tsx b/src/components/home/HeroSlider.tsx index 7c2cd68..31ff912 100644 --- a/src/components/home/HeroSlider.tsx +++ b/src/components/home/HeroSlider.tsx @@ -3,12 +3,29 @@ import { useState } from "react"; import { Placeholder } from "@/components/ui/Placeholder"; import { sliderSlides } from "@/data/sample"; +import type { StaticImageWithUrl } from "@/lib/meshkee"; const PEEK_OFFSET = 70; -export function HeroSlider() { +type Slide = { id: string; title: string; image: string; href?: string }; + +export function HeroSlider({ images = [] }: { images?: StaticImageWithUrl[] }) { + const slides: Slide[] = + images.length > 0 + ? images.map((image) => ({ + id: image.id, + title: image.titleFa ?? image.titleEn ?? "", + image: image.url, + href: image.linkUrl ?? undefined, + })) + : sliderSlides.map((slide) => ({ + id: String(slide.id), + title: slide.title, + image: slide.image, + })); + const [active, setActive] = useState(0); - const len = sliderSlides.length; + const len = slides.length; const getDiff = (i: number) => { let diff = i - active; @@ -21,11 +38,20 @@ export function HeroSlider() {
- {sliderSlides.map((slide, i) => { + {slides.map((slide, i) => { const diff = getDiff(i); const isCenter = diff === 0; const isVisible = Math.abs(diff) <= 1; + const media = ( + + ); + return (
- + {slide.href ? ( + + {media} + + ) : ( + media + )}
); @@ -56,16 +83,14 @@ export function HeroSlider() {
- {sliderSlides.map((slide, i) => ( + {slides.map((slide, i) => (