import { Menu } from '@nx/nx-dev/models-menu'; import { Sidebar, SidebarMobile } from '@nx/nx-dev/ui-common'; import { useMemo } from 'react'; // TODO(jack): Remove this rspack modification once we move rspack into main repo (when stable). const rspackSection = { id: 'rspack', name: 'rspack', itemList: [ { id: 'documents', path: '/packages/rspack/documents', name: 'documents', children: [ { name: 'Overview of the Nx Rspack plugin', path: '/packages/rspack/documents/overview', id: 'overview', isExternal: false, children: [], disableCollapsible: false, }, { name: 'Rspack plugins', path: '/packages/rspack/documents/rspack-plugins', id: 'rspack-plugins', isExternal: false, children: [], disableCollapsible: false, }, { name: 'How to configure Rspack in your Nx workspace', path: '/packages/rspack/documents/rspack-config-setup', id: 'rspack-config-setup', isExternal: false, children: [], disableCollapsible: false, }, ], isExternal: false, disableCollapsible: false, }, { id: 'executors', path: '/packages/rspack/executors', name: 'executors', children: [ { id: 'rspack', path: '/packages/rspack/executors/rspack', name: 'rspack', children: [], isExternal: false, disableCollapsible: false, }, { id: 'dev-server', path: '/packages/rspack/executors/dev-server', name: 'dev-server', children: [], isExternal: false, disableCollapsible: false, }, ], isExternal: false, disableCollapsible: false, }, { id: 'generators', path: '/packages/rspack/generators', name: 'generators', children: [ { id: 'init', path: '/packages/rspack/generators/init', name: 'init', children: [], isExternal: false, disableCollapsible: false, }, { id: 'configuration', path: '/packages/rspack/generators/configuration', name: 'configuration', children: [], isExternal: false, disableCollapsible: false, }, { id: 'application', path: '/packages/rspack/generators/application', name: 'application', children: [], isExternal: false, disableCollapsible: false, }, ], isExternal: false, disableCollapsible: false, }, ], hideSectionHeader: false, }; export function SidebarContainer({ menu, navIsOpen, }: { menu: Menu; navIsOpen: boolean; }): JSX.Element { // TODO(jack): Remove this rspack modification once we move rspack into main repo (when stable). const menuWithRspack = useMemo(() => { const storybookIdx = menu.sections.findIndex((s) => s.id === 'storybook'); const sections = storybookIdx > -1 ? [ ...menu.sections.slice(0, storybookIdx), rspackSection, ...menu.sections.slice(storybookIdx), ] : menu.sections; return { ...menu, sections, }; }, [menu]); return (
); }