Skip to content

Commit 122791a

Browse files
isaacplmannFrozenPandaz
authored andcommitted
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 (cherry picked from commit a05d389)
1 parent 6bf79f4 commit 122791a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

nx-dev/data-access-menu/src/lib/menu.utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
22

3+
const COLLAPSIBLE_SECTIONS = ['concepts', 'recipes'];
4+
35
export function getBasicNxSection(items: MenuItem[]): MenuSection {
46
return {
57
id: 'basic',
@@ -19,7 +21,9 @@ export function getBasicNxSection(items: MenuItem[]): MenuSection {
1921
.map((m) => {
2022
return {
2123
...m,
22-
disableCollapsible: !m.id.endsWith('tutorial'),
24+
disableCollapsible: !COLLAPSIBLE_SECTIONS.some((collapsibleSection) =>
25+
m.id.endsWith(collapsibleSection)
26+
),
2327
};
2428
}),
2529
};

nx-dev/ui-common/src/lib/sidebar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ function SidebarSectionItems({ item }: { item: MenuItem }): JSX.Element {
109109
</h5>
110110
<ul className={cx('mb-6 ml-3', collapsed ? 'hidden' : '')}>
111111
{(item.children as MenuItem[]).map((subItem, index) => {
112-
const isActiveLink = subItem.path === withoutAnchors(router.asPath);
112+
const isActiveLink = withoutAnchors(router.asPath).startsWith(
113+
subItem.path
114+
);
113115
if (isActiveLink && collapsed) {
114116
handleCollapseToggle();
115117
}

0 commit comments

Comments
 (0)