import { BlogIcon, ContactIcon, CVIcon, HamburgerIcon, HomeIcon, ProjectsIcon, } from '@components/Icons'; import { NavItem } from '@ts/types/nav'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { ForwardedRef, forwardRef, SetStateAction } from 'react'; import { useIntl } from 'react-intl'; import styles from './MainNav.module.scss'; const MainNav = ( { isOpened, setIsOpened, }: { isOpened: boolean; setIsOpened: (value: SetStateAction) => void; }, ref: ForwardedRef ) => { const intl = useIntl(); const router = useRouter(); const mainNavConfig: NavItem[] = [ { id: 'home', name: intl.formatMessage({ defaultMessage: 'Home', description: 'MainNav: home link', }), slug: '/', }, { id: 'blog', name: intl.formatMessage({ defaultMessage: 'Blog', description: 'MainNav: blog link', }), slug: '/blog', }, { id: 'projects', name: intl.formatMessage({ defaultMessage: 'Projects', description: 'MainNav: projects link', }), slug: '/projets', }, { id: 'cv', name: intl.formatMessage({ defaultMessage: 'Resume', description: 'MainNav: resume link', }), slug: '/cv', }, { id: 'contact', name: intl.formatMessage({ defaultMessage: 'Contact', description: 'MainNav: contact link', }), slug: '/contact', }, ]; const getIcon = (id: string) => { switch (id) { case 'home': return ; case 'blog': return ; case 'contact': return ; case 'cv': return ; case 'projects': return ; default: break; } }; const navItems = mainNavConfig.map((item) => { const currentClass = router.asPath === item.slug ? styles.current : ''; return (
  • {getIcon(item.id)} {item.name}
  • ); }); return ( ); }; export default forwardRef(MainNav);