diff --git a/app/search/layout.tsx b/app/search/layout.tsx
index 5ef628120..39bb38220 100644
--- a/app/search/layout.tsx
+++ b/app/search/layout.tsx
@@ -1,7 +1,5 @@
import Footer from 'components/layout/footer';
import Collections from 'components/layout/search/collections';
-import FilterList from 'components/layout/search/filter';
-import { sorting } from 'lib/constants';
export default function SearchLayout({ children }: { children: React.ReactNode }) {
return (
@@ -12,7 +10,7 @@ export default function SearchLayout({ children }: { children: React.ReactNode }
{children}
-
+ {/* */}
diff --git a/components/carousel.tsx b/components/carousel.tsx
index 286d4dfea..526b5d9c7 100644
--- a/components/carousel.tsx
+++ b/components/carousel.tsx
@@ -3,8 +3,7 @@ import Link from 'next/link';
import { GridTileImage } from './grid/tile';
export async function Carousel() {
- // Collections that start with `hidden-*` are hidden from the search page.
- const products = await getCollectionProducts({ collection: 'hidden-homepage-carousel' });
+ const products = await getCollectionProducts({});
if (!products?.length) return null;
diff --git a/components/grid/three-items.tsx b/components/grid/three-items.tsx
index 23b3f8991..ebd317e19 100644
--- a/components/grid/three-items.tsx
+++ b/components/grid/three-items.tsx
@@ -38,9 +38,8 @@ function ThreeItemGridItem({
}
export async function ThreeItemGrid() {
- // Collections that start with `hidden-*` are hidden from the search page.
const homepageItems = await getCollectionProducts({
- collection: 'hidden-homepage-featured-items'
+ tag: 'featured'
});
if (!homepageItems[0] || !homepageItems[1] || !homepageItems[2]) return null;
diff --git a/lib/shopify/index.ts b/lib/shopify/index.ts
index c4ee6be61..a269fec19 100644
--- a/lib/shopify/index.ts
+++ b/lib/shopify/index.ts
@@ -1,5 +1,5 @@
import { SHOPIFY_GRAPHQL_API_ENDPOINT, TAGS } from 'lib/constants';
-import { find, findByID } from 'lib/shopify/payload';
+import { Where, find, findByID } from 'lib/shopify/payload';
import { Category, Media, Option, Product } from 'lib/shopify/payload-types';
import { isShopifyError } from 'lib/type-guards';
import { ensureStartsWith } from 'lib/utils';
@@ -271,16 +271,36 @@ const reshapeProduct = (product: Product): ExProduct => {
export async function getCollectionProducts({
collection,
+ tag,
reverse,
sortKey
}: {
- collection: string;
+ collection?: string;
+ tag?: string;
reverse?: boolean;
sortKey?: string;
}): Promise {
- console.log(collection);
+ const filters: Where[] = [];
+ if (collection) {
+ filters.push({
+ categories: {
+ equals: collection
+ }
+ });
+ }
+ if (tag) {
+ filters.push({
+ tags: {
+ equals: collection
+ }
+ });
+ }
- const products = await find('products', {});
+ const products = await find('products', {
+ where: {
+ and: filters
+ }
+ });
return products.docs.map(reshapeProduct);
}
@@ -363,7 +383,25 @@ export async function getProducts({
reverse?: boolean;
sortKey?: string;
}): Promise {
- const products = await find('products', {});
+ let where: Where | undefined;
+ if (query) {
+ where = {
+ or: [
+ {
+ title: {
+ contains: query
+ }
+ },
+ {
+ description: {
+ contains: query
+ }
+ }
+ ]
+ };
+ }
+
+ const products = await find('products', { where });
return products.docs.map(reshapeProduct);
}
diff --git a/lib/shopify/payload.ts b/lib/shopify/payload.ts
index f7176d687..04003fd52 100644
--- a/lib/shopify/payload.ts
+++ b/lib/shopify/payload.ts
@@ -26,7 +26,7 @@ type Operator = (typeof OPERATORS)[number];
type WhereField = {
[key in Operator]?: unknown;
};
-type Where = {
+export type Where = {
[key: string]: Where[] | WhereField;
and?: Where[];
or?: Where[];