Polish storefront SEO, specials, and homepage UX.
Publish Meshkee sitemap-config, map product-source specials without variants, restore hero autoplay, and tighten page heroes, product images, and section order. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
11d0ba64ed
commit
24b5649abd
+36
-5
@@ -7,12 +7,43 @@ export async function GET(request: Request) {
|
||||
return Response.json({ items: [] });
|
||||
}
|
||||
|
||||
const encoded = encodeURIComponent(query);
|
||||
const base = `${meshkeeApiBase}/tenants/${encodeURIComponent(websiteDomain)}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${meshkeeApiBase}/tenants/${encodeURIComponent(websiteDomain)}/store-items?name=${encodeURIComponent(query)}&pageSize=8`,
|
||||
{ cache: "no-store" },
|
||||
);
|
||||
return Response.json(await response.json());
|
||||
const storeResponse = await fetch(`${base}/store-items?name=${encoded}&pageSize=8`, {
|
||||
cache: "no-store",
|
||||
});
|
||||
const storeData = (await storeResponse.json()) as { items?: unknown[] };
|
||||
if (storeData.items?.length) {
|
||||
return Response.json(storeData);
|
||||
}
|
||||
|
||||
const catalogResponse = await fetch(`${base}/products?name=${encoded}&pageSize=8`, {
|
||||
cache: "no-store",
|
||||
});
|
||||
const catalogData = (await catalogResponse.json()) as {
|
||||
items?: Array<{
|
||||
id: string;
|
||||
nameFa?: string | null;
|
||||
title?: string | null;
|
||||
slug?: string | null;
|
||||
thumbnailUrl?: string | null;
|
||||
image?: string | null;
|
||||
store?: { minPrice?: number | null; maxPrice?: number | null };
|
||||
}>;
|
||||
};
|
||||
|
||||
return Response.json({
|
||||
items: (catalogData.items ?? []).map((item) => ({
|
||||
id: item.slug || item.id,
|
||||
productId: item.id,
|
||||
productNameFa: item.nameFa,
|
||||
productTitle: item.title,
|
||||
productImage: item.thumbnailUrl || item.image,
|
||||
price: item.store?.minPrice ?? item.store?.maxPrice ?? null,
|
||||
})),
|
||||
});
|
||||
} catch {
|
||||
return Response.json({ items: [] });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user