diff --git a/components/Breadcrumps/index.tsx b/components/Breadcrumps/index.tsx index 44c600659..84e5d0d58 100644 --- a/components/Breadcrumps/index.tsx +++ b/components/Breadcrumps/index.tsx @@ -25,7 +25,7 @@ const BreadCrumbs: React.FC = ({ sections }) => { href={section.url} className="flex gap-x-2 bg-theme-quinary bg-opacity-20 text-text-primary-light dark:text-text-quaternary text-lg py-0.5 px-2.5 rounded-lg capitalize cursor-pointer" > - {section.name} + {section.name?.split('-').join(' ')} ))} diff --git a/components/Searchbar/Searchbar.tsx b/components/Searchbar/Searchbar.tsx index 1c9d89892..8a2874349 100644 --- a/components/Searchbar/Searchbar.tsx +++ b/components/Searchbar/Searchbar.tsx @@ -63,15 +63,23 @@ export const Searchbar: React.FC = ({ const handleSubmit = (e: React.FormEvent) => { e.preventDefault() - dispatchSearch({ type: 'submit' }) - if (searchQuery.trim() !== '') { - router.push({ - pathname: '/search', - query: { - query: searchQuery, - }, - }) + const cleanedSearchQuery = searchQuery.toLocaleLowerCase().trim() + if (cleanedSearchQuery !== '') { + const { category } = sidebarData.find((item) => + item.subcategory.find((subCat) => subCat.name === cleanedSearchQuery) + ) || { category: '' } + + if (category != '') { + router.push(`/${category}/${cleanedSearchQuery}`) + } else { + router.push({ + pathname: '/search', + query: { + query: searchQuery, + }, + }) + } } } diff --git a/components/TopBar/TopBar.tsx b/components/TopBar/TopBar.tsx index 6264df928..416185f3d 100644 --- a/components/TopBar/TopBar.tsx +++ b/components/TopBar/TopBar.tsx @@ -18,8 +18,9 @@ export const TopBar: FC = ({}) => { const { theme } = useTheme() const category = router.asPath - const categoryName = category.split('/')[1] - const subcategoryName = category?.split('/')[2] + const categoryName = category?.split('/')[1]?.split('-').join(' ') + const subcategoryName = category?.split('/')[2]?.split('-').join(' ') + const searchQuery = router.query.query?.toString() || '' let cleanedCategory = '' @@ -63,7 +64,7 @@ export const TopBar: FC = ({}) => {
-

{capitalizeEachWord(cleanedCategory.split('-').join(' '))}

+

{capitalizeEachWord(cleanedCategory)}