import Image from "next/image";
import Link from "next/link";
import { HeroSlider, type HeroSlide } from "@/app/components/hero-slider";
import { ProductCarousel } from "@/app/components/product-carousel";
import { ArticleCarousel } from "@/app/components/article-carousel";
import { SlotBanner, SlotLinkedImage } from "@/app/components/slot-media";
import { getStaticImages, listBlogs } from "@/lib/meshkee/api";
import { formatDate } from "@/lib/meshkee/format";
import {
firstSlotImage,
imageSubtext,
imageTitleEn,
imageTitleFa,
slotImages,
} from "@/lib/meshkee/static-slots";
import type { StaticImageItem, StaticImageSlot } from "@/lib/meshkee/types";
import { blogHref } from "@/lib/meshkee/urls";
import {
aboutCopy,
articles as fallbackArticles,
categories,
categoryQuickLinks,
diningProducts,
features,
heroSlides as fallbackHeroSlides,
products,
site,
} from "@/lib/site-data";
function SectionTitle({
eyebrow,
title,
href,
}: {
eyebrow: string;
title: string;
href?: string;
}) {
return (
{href ? (
‹
MORE
) : null}
);
}
function QuickCategoryIcon({ index }: { index: number }) {
const shapes = [
"M5 18h14M7 18v-5a4 4 0 0 1 4-4h2a4 4 0 0 1 4 4v5M8 18v2m8-2v2",
"M8 20v-7a4 4 0 0 1 8 0v7M7 13h10M9 20h6",
"M6 18h12M8 18v-8h8v8M10 10v8m4-8v8",
"M5 18h14M7 18V9h10v9M9 12h6",
"M5 12h14M8 12v8m8-8v8M7 8h10",
"M5 18V9h14v9M5 14h14M8 18v2m8-2v2",
];
return (
);
}
function buildHeroSlides(images: StaticImageItem[]): HeroSlide[] {
if (!images.length) return fallbackHeroSlides;
return images.map((image, index) => {
const fallback = fallbackHeroSlides[index % fallbackHeroSlides.length];
return {
eyebrow: imageTitleEn(image) || fallback.eyebrow,
title: imageTitleFa(image) || fallback.title,
description: imageSubtext(image) || fallback.description,
image: image.url || fallback.image,
linkUrl: image.linkUrl,
};
});
}
function mergeQuickCategories(icons: StaticImageItem[]) {
return categoryQuickLinks.map((item, index) => {
const image = icons[index];
return {
title: imageTitleFa(image) || item.title,
iconImage: image?.url || item.iconImage,
href: image?.linkUrl || "#products",
};
});
}
const twoBannerFallbacks = [
{
eyebrow: "MINIMAL SOFA",
title: "خرید مبل مینیمال مدرن",
text: "طراحی ساده، دستههای چوبی و نشیمن راحت برای خانههای مدرن.",
},
{
eyebrow: "INSTALLMENT",
title: "خرید مبل اقساطی",
text: "شرایط ویژه برای خرید انواع مبلمان با تحویل و مشاوره فروش.",
},
];
const threeBannerFallbacks = [
{
title: "مبل راحتی مدرن",
text: "انتخابی مناسب برای چیدمان صمیمی و کاربردی فضای نشیمن.",
},
{
title: "سرویس خواب",
text: "مدلهای مدرن و کلاسیک برای تکمیل دکوراسیون اتاق خواب.",
},
{
title: "میز جلو مبلی و عسلی",
text: "هماهنگ با سبک مبلمان و قابل سفارش برای خانههای ایرانی.",
},
];
export default async function Home() {
const [homeSlots, blogItems] = await Promise.all([
getStaticImages("home").catch(() => [] as StaticImageSlot[]),
listBlogs({ page: 1, pageSize: 8 })
.then((data) =>
data.items.map((post) => ({
title: post.title,
date: formatDate(post.publishedAt || post.createdAt),
image: post.titleImageUrl || "/assets/sample/spacejoy-c0JoR_-2x3E-unsplash.jpg",
href: blogHref(post.id, post.title),
})),
)
.catch(() =>
fallbackArticles.map((article) => ({
...article,
href: "/blog",
})),
),
]);
const heroSlides = buildHeroSlides(slotImages(homeSlots, "slider"));
const quickCategories = mergeQuickCategories(slotImages(homeSlots, "categories-icon"));
const saleBannerImage = firstSlotImage(homeSlots, "special-sale-banner");
const featuresImage = firstSlotImage(homeSlots, "product-features-image");
const contactImage = firstSlotImage(homeSlots, "contactus-image");
const aboutHomeImage = firstSlotImage(homeSlots, "aboutus-image");
const twoBanners = slotImages(homeSlots, "two-banner-row");
const threeBanners = slotImages(homeSlots, "three-banner-row");
return (
{categories.map((category) => (
{category.title}
{category.subtitle}
))}
{features.map((feature, index) => (
{feature.title}
{feature.subtitle}
{feature.subtext}
))}
Contact Us
برای انتخاب پارچه و سفارش با ما در ارتباط باشید
مشاوران هومت هر روز از ساعت 10 صبح الی 20 شب آماده پاسخگویی و
راهنمایی برای انتخاب مدل، رنگ، پارچه و شرایط خرید هستند.
-
واتساپ / تلگرام:{" "}
{site.whatsapp} _ {site.mobile}
-
شماره تماس:{" "}
{site.phone}
ارتباط با مبلمان هومت
{twoBannerFallbacks.map((fallback, index) => (
))}
{aboutCopy.eyebrow}
درباره هومت
{aboutCopy.story}
بیشتر بدانید
{threeBannerFallbacks.map((fallback, index) => (
))}
);
}