diff --git a/src/app/products/category/[id]/[slug]/page.tsx b/src/app/products/category/[id]/[slug]/page.tsx
index 7517e03..04b250e 100644
--- a/src/app/products/category/[id]/[slug]/page.tsx
+++ b/src/app/products/category/[id]/[slug]/page.tsx
@@ -7,6 +7,7 @@ import ProductCard from "@/components/ProductCard";
import Pagination from "@/components/Pagination";
import {
getCategories,
+ getCategoryAncestors,
getCategoryById,
getCategoryDescendantIds,
getProducts,
@@ -82,13 +83,20 @@ export default async function CategoryProductsPage({
(a, b) =>
a.sortOrder - b.sortOrder || a.nameFa.localeCompare(b.nameFa, "fa")
);
+ const categoryTrail = getCategoryAncestors(category.id, allCategories);
return (
<>
({
+ label: cat.nameFa,
+ href: i < categoryTrail.length - 1 ? categoryPath(cat) : undefined,
+ })),
+ ]}
/>
diff --git a/src/app/products/page.tsx b/src/app/products/page.tsx
index 89d3399..fb2388f 100644
--- a/src/app/products/page.tsx
+++ b/src/app/products/page.tsx
@@ -5,9 +5,10 @@ import ProductCard from "@/components/ProductCard";
import Pagination from "@/components/Pagination";
import CategoryShowcase from "@/components/CategoryShowcase";
import HomeContactStrip from "@/components/HomeContactStrip";
-import { getCategoryById, getProducts } from "@/lib/meshkee";
+import { getCategories, getCategoryById, getProducts } from "@/lib/meshkee";
import { pageMetadata } from "@/lib/seo";
import { categoryPath } from "@/lib/urls";
+import { slugifyFa } from "@/lib/slugify";
export const metadata = pageMetadata({
title: "محصولات | آراد آریسمان",
@@ -21,9 +22,9 @@ const PAGE_SIZE = 6;
export default async function ProductsPage({
searchParams,
}: {
- searchParams: Promise<{ page?: string; categoryId?: string }>;
+ searchParams: Promise<{ page?: string; categoryId?: string; category?: string }>;
}) {
- const { page, categoryId } = await searchParams;
+ const { page, categoryId, category: categorySlug } = await searchParams;
if (categoryId) {
const category = await getCategoryById(categoryId);
@@ -32,6 +33,23 @@ export default async function ProductsPage({
}
}
+ if (categorySlug) {
+ const all = await getCategories();
+ const needle = categorySlug.trim().toLowerCase();
+ const matched = all.find((c) => {
+ const enSlug = c.name.toLowerCase().replace(/\s+/g, "-");
+ return (
+ c.slug?.toLowerCase() === needle ||
+ enSlug === needle ||
+ c.name.toLowerCase() === needle ||
+ slugifyFa(c.nameFa) === needle
+ );
+ });
+ if (matched) {
+ permanentRedirect(categoryPath(matched));
+ }
+ }
+
const requestedPage = Math.max(1, Number(page) || 1);
const { items, total } = await getProducts({
page: requestedPage,
diff --git a/src/components/AccountMenu.tsx b/src/components/AccountMenu.tsx
index 47eafc4..ba9492f 100644
--- a/src/components/AccountMenu.tsx
+++ b/src/components/AccountMenu.tsx
@@ -6,10 +6,22 @@ import { useSession, userDisplayName } from "@/lib/session";
function UserIcon() {
return (
-