'Pass all urls to router.pathname

I have object to navigation and i want to pass urls to router.pathname. No i pass item.url is only one url and one element of sub menu disapper becouse i set only for one url.

This is my Object:

{
    label: 'More',
    url: '/panel/settings',
    icon: UserIcon,
    subItems: [
      { label: 'user', url: '/panel/user' },
      { label: 'superuser'), url: '/panel/superuser' },
    ],
  },

and in navigation below i want to pass to router.pathname both urls

 <div className="pl-9">
                {subItems.map((item, index) => (
                  <Link href={item.url} key={index} passHref>
                    <span
                      className={mergeClasses(
                        'flex items-center text-xs font-bold text-grey-700 px-4 py-6 transition-colors duration-200 hover:text-grey-600 cursor-pointer',
                        router.pathname == item.url
                          ? 'text-primary-500 hover:text-primary-500'
                          : '',
                        router.pathname == url || router.pathname == item.url
                          ? ''
                          : 'hidden',
                      )}
                    >
                      {item.label}
                    </span>
                  </Link>
                ))}
              </div>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source