+ const defaultDescription =
+ query
+ ? `نتایج جستجو برای «${query}»`
+ : "منتخب ماشینآلات سنگین و صنعتی از فروشگاه ماشینیفای؛ برای جزئیات و قیمت، استعلام بگیرید.";
+
+ const content = (
+
{showHeader ? (
-
Stock Machines
-
محصولات موجود
+
{kicker}
+ {titleHref ? (
+
+
+
+
+
+ {title}
+
+
+ ) : (
+
{title}
+ )}
- {query
- ? `نتایج جستجو برای «${query}»`
- : "منتخب ماشینآلات سنگین و صنعتی از فروشگاه ماشینیفای؛ برای جزئیات و قیمت، استعلام بگیرید."}
+ {description ?? defaultDescription}
) : query ? (
@@ -126,13 +171,23 @@ export function Products({
{showMoreLink ? (
-
- {total > items.length ? "محصولات بیشتر" : "همه محصولات"}
+
+ {moreLabel ??
+ (total > items.length ? "محصولات بیشتر" : "همه محصولات")}
) : null} >
)}
+ );
+
+ if (embedded) {
+ return
{content}
;
+ }
+
+ return (
+
);
}
diff --git a/src/components/SiteShell.tsx b/src/components/SiteShell.tsx
index 11bd9b1..fc24e42 100644
--- a/src/components/SiteShell.tsx
+++ b/src/components/SiteShell.tsx
@@ -1,5 +1,5 @@
import { Footer } from "@/components/Footer";
-import { Header } from "@/components/Header";
+import { HeaderContainer } from "@/components/HeaderContainer";
import { PageBanner } from "@/components/PageBanner";
type SiteShellProps = {
@@ -19,7 +19,7 @@ export function SiteShell({
}: SiteShellProps) {
return (
<>
-
+
{banner ? (
item.id === id) ?? null;
}
+
+export function listRootProductCategories(categories: Category[]) {
+ return buildCategoryTree(categories).filter((category) => category.isActive);
+}
+
+export function listLevel2ProductCategories(categories: Category[]) {
+ return listRootProductCategories(categories).flatMap((root) =>
+ root.children.filter((category) => category.isActive),
+ );
+}
+
+export async function getRootProductCategories() {
+ const categories = await listCategories("product");
+ return listRootProductCategories(categories).map((category) => ({
+ id: category.id,
+ label: categoryLabel(category),
+ href: `/user-products?categoryId=${encodeURIComponent(category.id)}`,
+ }));
+}
+
+export async function getLevel2ProductCategories() {
+ const categories = await listCategories("product");
+ return listLevel2ProductCategories(categories).map((category) => ({
+ id: category.id,
+ label: categoryLabel(category),
+ href: `/user-products?categoryId=${encodeURIComponent(category.id)}`,
+ }));
+}
diff --git a/src/lib/user-product-gallery.ts b/src/lib/user-product-gallery.ts
new file mode 100644
index 0000000..3194364
--- /dev/null
+++ b/src/lib/user-product-gallery.ts
@@ -0,0 +1,9 @@
+export function resolveProductGallery(product: {
+ images?: { url: string }[] | null;
+ imageUrl?: string | null;
+}) {
+ const fromImages =
+ product.images?.map((img) => img.url).filter(Boolean) ?? [];
+ if (fromImages.length > 0) return fromImages;
+ return product.imageUrl ? [product.imageUrl] : [];
+}