docs(core): collapse concepts and recipes (#23246)

Collapse concepts and recipes top level sections

Also make sure that sidebar expands to the active link even if it is
multiple sections down
This commit is contained in:
Isaac Mann 2024-05-08 12:34:46 -04:00 committed by GitHub
parent a2d9f9cc16
commit a05d38931b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,7 @@
import { MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
const COLLAPSIBLE_SECTIONS = ['concepts', 'recipes'];
export function getBasicNxSection(items: MenuItem[]): MenuSection {
return {
id: 'basic',
@ -19,7 +21,9 @@ export function getBasicNxSection(items: MenuItem[]): MenuSection {
.map((m) => {
return {
...m,
disableCollapsible: !m.id.endsWith('tutorial'),
disableCollapsible: !COLLAPSIBLE_SECTIONS.some((collapsibleSection) =>
m.id.endsWith(collapsibleSection)
),
};
}),
};

View File

@ -109,7 +109,9 @@ function SidebarSectionItems({ item }: { item: MenuItem }): JSX.Element {
</h5>
<ul className={cx('mb-6 ml-3', collapsed ? 'hidden' : '')}>
{(item.children as MenuItem[]).map((subItem, index) => {
const isActiveLink = subItem.path === withoutAnchors(router.asPath);
const isActiveLink = withoutAnchors(router.asPath).startsWith(
subItem.path
);
if (isActiveLink && collapsed) {
handleCollapseToggle();
}