Add links to the categories & brands in the landing

This commit is contained in:
Luis Alvarez
2020-10-25 21:43:13 -05:00
parent 50c50b6d53
commit d70132734b
3 changed files with 26 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
import { useEffect, useState } from 'react'
import getSlug from './get-slug'
export function useSearchMeta(asPath: string) {
const [pathname, setPathname] = useState<string>('/search')
@@ -34,11 +35,16 @@ export const filterQuery = (query: any) =>
return obj
}, {})
export const getCategoryPath = (slug: string, brand?: string) =>
`/search${brand ? `/designers/${brand}` : ''}${slug ? `/${slug}` : ''}`
export const getCategoryPath = (path: string, brand?: string) => {
const category = getSlug(path)
export const getDesignerPath = (slug: string, category?: string) => {
const designer = slug.replace(/^brands/, 'designers')
return `/search${brand ? `/designers/${brand}` : ''}${
category ? `/${category}` : ''
}`
}
export const getDesignerPath = (path: string, category?: string) => {
const designer = getSlug(path).replace(/^brands/, 'designers')
return `/search${designer ? `/${designer}` : ''}${
category ? `/${category}` : ''