import React from 'react'; import { Menu, Layout } from 'antd'; import { useRouter } from 'next/router'; import './menu'; const SharedNav = () => { const { asPath, push } = useRouter(); let activeMenu; if (asPath === '/' || asPath.startsWith('/home')) { activeMenu = '/'; } else if (asPath.startsWith('/shop')) { activeMenu = '/shop'; } else if (asPath.startsWith('/checkout')) { activeMenu = '/checkout'; } const menuItems = [ { className: 'home-menu-link', label: ( <> Home 3000 ), key: '/', }, { className: 'shop-menu-link', label: ( <> Shop 3001 ), key: '/shop', }, { className: 'checkout-menu-link', label: ( <> Checkout 3002 ), key: '/checkout', }, ]; return (
nextjs-mf
{ push(key); }} items={menuItems} /> ); }; export default SharedNav;