import React, { useEffect } from 'react' import Link from 'next/link' import { AnimateSharedLayout, motion } from 'framer-motion' import { useRouter } from 'next/router' import { Link as ChakraLink, Flex, Box, Stack, HStack } from '@chakra-ui/react' import Headroom from 'react-headroom' import paths from '../paths' const Container = motion.custom(Flex) const containerVariants = { open: { opacity: 1, display: 'flex', }, closed: { opacity: 0, transition: { when: 'afterChildren', }, transitionEnd: { display: 'none', }, }, } type NavProps = { handleClick: () => void variant?: string } const Nav: React.FC = ({ handleClick, variant = undefined }) => { const { pathname } = useRouter() return ( {paths.map((path) => { const currentLocation = pathname === '/' ? '/' : pathname.substring(1) const currentPath = path.path === '/' ? '/' : path.path.substring(1) if (currentPath === '/') { return null } const current = currentLocation === currentPath || (currentPath !== '/' && currentLocation.includes(currentPath)) return ( {path.name} ) })} ) } export default Nav