diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index 71963c33b..c91fb1774 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -6,11 +6,9 @@ import { GlobalContext } from 'context/GlobalContext' import { ThemeToggler } from '../ThemeToggler/themeToggler' import { TopBar } from '../TopBar/TopBar' import { SocialMediaIconsList } from 'components/SocialMedia/SocialMediaIconsList' -import { useResults } from 'hooks/ResultsContext' export const Header: FC = () => { const { toggleNav } = useContext(GlobalContext) - const { results } = useResults() return (
@@ -20,11 +18,11 @@ export const Header: FC = () => {
- -
+ +
- - -
- ) : ( -
- - - {subcategoryName} - - - - -
- )} - - )} - - ) + if (router.pathname.length === 1) return null + return isResourceSelected ? ( +
+ + + {cleanedCategory} + + + +
+ ) : null } diff --git a/components/TopBar/utils.ts b/components/TopBar/utils.ts new file mode 100644 index 000000000..40bbb5acc --- /dev/null +++ b/components/TopBar/utils.ts @@ -0,0 +1,27 @@ +import { sidebarData } from 'database/data' + +export const regEx = /[ `!@#$%^&*()_+\=\[\]{};':"\\|,.<>\/?~]/g + +const cleanText = (text: string) => + text + .toLocaleLowerCase() + .replaceAll(regEx, ' ') + .replaceAll(' ', ' ') + .replaceAll('-', ' ') + +export const isValidResource = (name: string) => { + if (!name) return + + const subCategoryNames: string[] = [] + sidebarData.forEach((category) => + category.subcategory.forEach((subcategory) => + subCategoryNames.push(subcategory.url?.replaceAll('/', '')) + ) + ) + + const isValid = !!subCategoryNames?.find( + (n) => cleanText(n) === cleanText(name) + ) + + return isValid +} diff --git a/components/popup/popupCategoryDesc.tsx b/components/popup/popupCategoryDesc.tsx deleted file mode 100644 index 1e0233a69..000000000 --- a/components/popup/popupCategoryDesc.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import React from 'react' -import { Backdrop } from 'components/Backdrop/Backdrop' -import { createPortal } from 'react-dom' -import useDelayUnmount from 'hooks/useDelayUnmount' -import { ICategoryData } from 'types' -import { BsBoxArrowUpRight } from 'react-icons/bs' - -const PopupDesc: React.FC<{ - currentCategory: ICategoryData | null - onClose: () => void -}> = ({ currentCategory, onClose }) => { - const showElement = useDelayUnmount(!!currentCategory, 300) - - if (!showElement || !currentCategory) { - return null - } - - const { name, description } = currentCategory - - const overlayRoot = document.getElementById('overlay-root') - - if (!overlayRoot) { - return null - } - - return ( - <> - - {createPortal( -
e.stopPropagation()} - className={`fixed left-1/2 top-1/2 z-[150] max-w-[500px] -translate-x-1/2 -translate-y-1/2 transition-all ${ - currentCategory ? 'animate-scale-appearance' : 'animate-scale-hide' - } flex h-fit w-[90%] flex-col justify-between gap-5 overflow-hidden rounded-2xl border border-dashed border-theme-secondary dark:border-theme-primary bg-light-primary px-5 py-10 dark:bg-dark`} - role="dialog" - title={`${name ?? 'Card'} Popup`} - > - {description.length ? ( -
-
-
-

- {name} -

-
-
-

{description}

-
- ) : ( -
-

Oops!

-

- No description was provided for{' '} - {name}. -

-

Be the first to add by creating aGitHub Issue .

-
- )} -
, - overlayRoot - )} - - ) -} - -export default PopupDesc diff --git a/database/data.ts b/database/data.ts index 6a701975b..f2f708992 100644 --- a/database/data.ts +++ b/database/data.ts @@ -135,7 +135,7 @@ export const sidebarData: ISidebar[] = [ }, { name: 'Tutorials', - url: '/os-tutorials', + url: '/tutorials', resources: DB.openSourceTutorials, }, ], diff --git a/database/index.ts b/database/index.ts index 60e453d10..2c92451ad 100644 --- a/database/index.ts +++ b/database/index.ts @@ -74,7 +74,7 @@ export { default as openSourceArticles } from './open_source/articles.json' export { default as openSourcePrograms } from './open_source/os-programs.json' export { default as openSourceProjects } from './open_source/projects.json' export { default as openSourceTools } from './open_source/tools.json' -export { default as openSourceTutorials } from './open_source/os-tutorials.json' +export { default as openSourceTutorials } from './open_source/tutorials.json' // resources export { default as blogs } from './resources/blogs.json' export { default as officialdocs } from './resources/official-docs.json' diff --git a/database/open_source/os-tutorials.json b/database/open_source/tutorials.json similarity index 97% rename from database/open_source/os-tutorials.json rename to database/open_source/tutorials.json index b725d4e01..fe778fc40 100644 --- a/database/open_source/os-tutorials.json +++ b/database/open_source/tutorials.json @@ -4,7 +4,7 @@ "description": "Even though the focus is on a specific project, this video provides great advice on how to maintain someone else's open source project.", "url": "https://youtu.be/WPaN9vIyqt4", "category": "open-source", - "subcategory": "os-tutorials" + "subcategory": "tutorials" }, { "name": "Open Source BootCamp in Hindi", diff --git a/pages/[category]/[...subcategory].tsx b/pages/[category]/[...subcategory].tsx index dedfbfb72..1d41608de 100644 --- a/pages/[category]/[...subcategory].tsx +++ b/pages/[category]/[...subcategory].tsx @@ -18,7 +18,7 @@ interface PageProps { interface Params extends ParsedUrlQuery, PageProps {} const SubCategory: NextPage = ({ subcategory }) => { - const { filterDB, results, pageCategory } = useFilterDB(subcategory[0]) + const { filterDB, pageCategory } = useFilterDB(subcategory[0]) const title = `LinksHub - ${ pageCategory[0].toUpperCase() + pageCategory.slice(1) }` @@ -36,7 +36,7 @@ const SubCategory: NextPage = ({ subcategory }) => { return ( <> - + {title} = ({ subcategory }) => { content="https://discord.com/invite/NvK67YnJX5" /> - -
+ +
{content} - { - const { results, setResults } = useResults() + const { setResults } = useResults() const router = useRouter() const title = `LinksHub - ${router.asPath @@ -93,11 +93,8 @@ const Search = () => { content="https://discord.com/invite/NvK67YnJX5" /> - -
+ +
{filteredCardsList.length > 0 ? ( ) : (