import type { Metadata } from "next";
import { AboutPreview } from "@/components/home/AboutPreview";
import { BannerRow } from "@/components/home/BannerRow";
import { BlogCarousel } from "@/components/home/BlogCarousel";
import { Branches } from "@/components/home/Branches";
import { CategoryShowcase } from "@/components/home/CategoryShowcase";
import { Hero } from "@/components/home/Hero";
import { ProductCarousel } from "@/components/home/ProductCarousel";
import { Services } from "@/components/home/Services";
import { Stats } from "@/components/home/Stats";
import { WideBanner } from "@/components/home/WideBanner";
import {
about,
bannersBelowSlider,
blogPosts,
branches,
consumablesFallback,
refrigeratorPartsFallback,
services,
showcaseCategories,
site,
slides,
threeBannerRow,
twoBannerRow,
washingMachinePartsFallback,
} from "@/lib/data";
import { fetchBlogs } from "@/lib/blog";
import { fetchSpecialProducts } from "@/lib/store";
import { fetchStaticImageSlots, overlaySlotImages, pickSlot } from "@/lib/static-images";
export const revalidate = 60;
export const metadata: Metadata = {
title: {
absolute: `${site.name} | ${site.tagline}`,
},
description: site.description,
};
export default async function HomePage() {
const [slots, consumables, refrigerator, washing, blogs] = await Promise.all([
fetchStaticImageSlots("home"),
fetchSpecialProducts("consumeables"),
fetchSpecialProducts("refrigrator-parts"),
fetchSpecialProducts("washing-machine-parts"),
fetchBlogs({ pageSize: 8 }),
]);
const slider = overlaySlotImages(
pickSlot(slots, "slider"),
slides.map((slide) => ({
id: slide.id,
image: slide.image,
href: slide.href,
title: slide.title,
kicker: slide.kicker,
})),
"slider",
);
const icons = overlaySlotImages(
pickSlot(slots, "three-icon-image"),
services.map((service) => ({
id: service.id,
image: "",
href: service.href,
title: service.title,
text: service.text,
})),
"three-icon-image",
);
const categories = overlaySlotImages(
pickSlot(slots, "categories"),
showcaseCategories.map((item) => ({
id: item.id,
image: item.image,
href: item.href,
title: item.title,
text: item.text,
})),
"categories",
);
const aboutImage = overlaySlotImages(
pickSlot(slots, "about-us-image"),
[{ id: "about", image: about.image }],
"about-us-image",
);
const fiveBanners = overlaySlotImages(
pickSlot(slots, "five-banner-section"),
[...twoBannerRow, ...threeBannerRow].map((banner) => ({
id: banner.id,
image: banner.image,
href: banner.href,
title: banner.title,
kicker: banner.kicker,
text: banner.text,
})),
"five-banner-section",
);
const twoBanners = overlaySlotImages(
pickSlot(slots, "two-banner-row"),
bannersBelowSlider.map((banner) => ({
id: banner.id,
image: banner.image,
href: banner.href,
title: banner.title,
kicker: banner.kicker,
text: banner.text,
})),
"two-banner-row",
);
const fullRow = overlaySlotImages(
pickSlot(slots, "full-row-image"),
[
{
id: "wide",
image: "/images/banners/wide.jpg",
href: "/contact",
title: "اگر به دنبال قطعه ی خاصی هستید، با ما تماس بگیرید.",
kicker: "Contact us",
},
],
"full-row-image",
);
const branchImages = overlaySlotImages(
pickSlot(slots, "two-branch-image"),
branches.map((branch) => ({
id: branch.id,
image: branch.image,
href: "/contact",
title: branch.title,
text: branch.address,
})),
"two-branch-image",
);
return (
<>
>
);
}