@usequeek/theme-kit 0.5.9 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hooks/use-categories.ts +8 -1
- package/package.json +1 -1
package/hooks/use-categories.ts
CHANGED
|
@@ -47,6 +47,11 @@ function flattenCategories(items: Category[]): Category[] {
|
|
|
47
47
|
* count. On failure the list is empty and `error` is set; the hook never
|
|
48
48
|
* throws.
|
|
49
49
|
*
|
|
50
|
+
* Without `ids` it asks for the store's storefront list (`storefront=1`), so it
|
|
51
|
+
* follows the merchant's collections-page settings: an empty collection is left
|
|
52
|
+
* out, like on `/shop`. With `ids` it asks for `include_empty=0` only, so a
|
|
53
|
+
* hand-picked smart collection is never dropped by those settings.
|
|
54
|
+
*
|
|
50
55
|
* @example
|
|
51
56
|
* const { categories } = useCategories({ limit: 6 });
|
|
52
57
|
*/
|
|
@@ -95,7 +100,9 @@ export function useCategories(options?: {
|
|
|
95
100
|
return;
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
|
|
103
|
+
// Pinned ids are filtered client-side and storefront=1 can switch the API to manual-only
|
|
104
|
+
// collections, which would drop a hand-picked smart collection: hide empty ones only.
|
|
105
|
+
const query: Record<string, string> = idsKey ? { include_empty: '0' } : { storefront: '1' };
|
|
99
106
|
const response = await client.get<CategoriesResponse>('/collections', withLocaleQuery(query, locale));
|
|
100
107
|
let items = flattenCategories(Array.isArray(response.data) ? response.data : []);
|
|
101
108
|
|
package/package.json
CHANGED