The Node.js® Website
at main 750 B view raw
1import type { RichTranslationValues } from 'next-intl'; 2import type { FC } from 'react'; 3 4import Sidebar from '@/components/Containers/Sidebar'; 5import { useSiteNavigation } from '@/hooks/server'; 6import type { NavigationKeys } from '@/types'; 7 8type WithSidebarProps = { 9 navKeys: Array<NavigationKeys>; 10 context?: Record<string, RichTranslationValues>; 11}; 12 13const WithSidebar: FC<WithSidebarProps> = ({ navKeys, context }) => { 14 const { getSideNavigation } = useSiteNavigation(); 15 16 const mappedSidebarItems = getSideNavigation(navKeys, context).map( 17 ([, { label, items }]) => ({ 18 groupName: label, 19 items: items.map(([, item]) => item), 20 }) 21 ); 22 23 return <Sidebar groups={mappedSidebarItems} />; 24}; 25 26export default WithSidebar;