@f5-sales-demo/docs-theme 4.4.0 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -28,3 +28,21 @@ describe('canonical provider navigation', () => {
|
|
|
28
28
|
expect(nav[0].entries[1].isCurrent).toBe(true);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
describe('bounded collection expansion', () => {
|
|
33
|
+
it('keeps sibling references and expands only the exact active ancestry', () => {
|
|
34
|
+
const pages = [
|
|
35
|
+
{ id: 'root', collection_id: 'c', parent_id: null, title: 'Root', slug: 'resources/demo' },
|
|
36
|
+
{ id: 'a', collection_id: 'c', parent_id: 'root', title: 'A', slug: 'resources/demo/properties/a' },
|
|
37
|
+
{ id: 'aa', collection_id: 'c', parent_id: 'a', title: 'AA', slug: 'resources/demo/properties/a/child' },
|
|
38
|
+
{ id: 'b', collection_id: 'c', parent_id: 'root', title: 'B', slug: 'resources/demo/properties/ab' },
|
|
39
|
+
{ id: 'bb', collection_id: 'c', parent_id: 'b', title: 'BB', slug: 'resources/demo/properties/ab/child' },
|
|
40
|
+
];
|
|
41
|
+
const nav = collectionNavigation(pages, 'c', '/', 'resources/demo/properties/a/child');
|
|
42
|
+
const text = JSON.stringify(nav);
|
|
43
|
+
expect(text).toContain('AA');
|
|
44
|
+
expect(text).toContain('"label":"B"');
|
|
45
|
+
expect(text).not.toContain('BB');
|
|
46
|
+
expect(nav[0].type).toBe('group');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -39,7 +39,9 @@ export function collectionNavigation(pages: ProviderPage[], collection: string,
|
|
|
39
39
|
const tree = (page: ProviderPage, seen = new Set<string>()): StarlightRouteData['sidebar'][number] => {
|
|
40
40
|
if (seen.has(page.id)) throw new Error(`Cyclic canonical navigation: ${page.id}`);
|
|
41
41
|
const descendants = children.get(page.id) || [];
|
|
42
|
-
|
|
42
|
+
// Other branches remain navigable through their reference page, whose
|
|
43
|
+
// content lists every direct child. Expand only the active ancestry.
|
|
44
|
+
if (!descendants.length || !(current === page.slug || current.startsWith(`${page.slug}/`))) return link(page);
|
|
43
45
|
const next = new Set([...seen, page.id]);
|
|
44
46
|
return {
|
|
45
47
|
type: 'group',
|