diff --git a/pages/search.tsx b/pages/search.tsx
index d71049a4b..6b3ae91e5 100644
--- a/pages/search.tsx
+++ b/pages/search.tsx
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import { useRouter } from 'next/router'
import Link from 'next/link'
+import cn from 'classnames'
import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info'
import useSearch from '@lib/bigcommerce/products/use-search'
import { Layout } from '@components/core'
@@ -38,8 +39,13 @@ export default function Home({
All Categories
{categories.map((cat) => (
-
-
+
+
{cat.name}
@@ -50,8 +56,13 @@ export default function Home({
All Designers
{brands.flatMap(({ node }) => (
-
-
+
+
{node.name}
@@ -122,14 +133,13 @@ function useSearchMeta(asPath: string) {
return { category, brand }
}
-function getCategoryPath(path: string, designer?: string) {
- return designer ? `/search/designers/${designer}${path}` : `/search${path}`
-}
+// Remove trailing and leading slash
+const getSlug = (path: string) => path.replace(/^\/|\/$/g, '')
-function getDesignerPath(path: string, category?: string) {
- // Remove the trailing slash and replace /brands with /designers
- const designer = path.replace(/^\/brands/, '/designers').replace(/\/$/, '')
- const href = `/search${designer}`
+const getCategoryPath = (slug: string, designer?: string) =>
+ designer ? `/search/designers/${designer}/${slug}` : `/search/${slug}`
- return category ? `${href}/${category}` : href
+const getDesignerPath = (slug: string, category?: string) => {
+ const designer = slug.replace(/^brands/, 'designers')
+ return `/search/${designer}${category ? `/${category}` : ''}`
}
diff --git a/pages/search/designers2/[designer]/[category].tsx b/pages/search/designers2/[designer]/[category].tsx
new file mode 100644
index 000000000..f8fee1c9d
--- /dev/null
+++ b/pages/search/designers2/[designer]/[category].tsx
@@ -0,0 +1,96 @@
+import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
+import Link from 'next/link'
+import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info'
+import useSearch from '@lib/bigcommerce/products/use-search'
+import { Layout } from '@components/core'
+import { Container, Grid } from '@components/ui'
+import { ProductCard } from '@components/product'
+import { useRouter } from 'next/router'
+
+export async function getStaticProps({ preview }: GetStaticPropsContext) {
+ const { categories, brands } = await getSiteInfo()
+
+ return {
+ props: { categories, brands },
+ }
+}
+
+export default function Home({
+ categories,
+ brands,
+}: InferGetStaticPropsType) {
+ const router = useRouter()
+ const { q } = router.query
+ const { data } = useSearch({
+ search: typeof q === 'string' ? q : '',
+ })
+
+ console.log('Q', router.query)
+
+ return (
+
+
+
+
+ -
+ All Categories
+
+ {categories.map((cat) => (
+ -
+
+ {cat.name}
+
+
+ ))}
+
+
+ -
+ All Designers
+
+ {brands.flatMap(({ node }) => (
+ -
+ {node.name}
+
+ ))}
+
+
+
+ {data ? (
+ <>
+ {q && (
+
+ {data.found ? (
+ <>Showing {data.products.length} results for>
+ ) : (
+ <>There are no products that match>
+ )}{' '}
+ "{q}"
+
+ )}
+
+ >
+ ) : (
+
Searching...
+ )}
+
+
+
+ -
+ Relevance
+
+ - Latest arrivals
+ - Trending
+ - Price: Low to high
+ - Price: High to low
+
+
+
+
+ )
+}
+
+Home.Layout = Layout