@mintlify/common 1.0.414 → 1.0.415
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.
|
@@ -2,20 +2,40 @@ import { divisions } from '@mintlify/validation';
|
|
|
2
2
|
import { generatePathToBreadcrumbsMapRecursive } from './generatePathToBreadcrumbsMap.js';
|
|
3
3
|
export function generatePathToBreadcrumbsMapForDocsConfig(navigation) {
|
|
4
4
|
const pathToBreadcrumbs = new Map();
|
|
5
|
-
generatePathToBreadcrumbsMapForDocsConfigRecursive(navigation, pathToBreadcrumbs);
|
|
5
|
+
generatePathToBreadcrumbsMapForDocsConfigRecursive(navigation, pathToBreadcrumbs, []);
|
|
6
6
|
return pathToBreadcrumbs;
|
|
7
7
|
}
|
|
8
|
-
function generatePathToBreadcrumbsMapForDocsConfigRecursive(nav, map) {
|
|
8
|
+
function generatePathToBreadcrumbsMapForDocsConfigRecursive(nav, map, currentBreadcrumbs = []) {
|
|
9
9
|
if ('groups' in nav) {
|
|
10
10
|
for (const group of nav.groups) {
|
|
11
|
-
generatePathToBreadcrumbsMapRecursive(group,
|
|
11
|
+
generatePathToBreadcrumbsMapRecursive(group, currentBreadcrumbs, map);
|
|
12
12
|
}
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
for (const
|
|
16
|
-
if (
|
|
17
|
-
const items = nav[
|
|
18
|
-
|
|
15
|
+
for (const key of divisions) {
|
|
16
|
+
if (key in nav) {
|
|
17
|
+
const items = nav[key];
|
|
18
|
+
if (!Array.isArray(items)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
for (const item of items) {
|
|
22
|
+
let divisionTitle = '';
|
|
23
|
+
// We purposely exclude `versions` and `languages` here to avoid
|
|
24
|
+
// cluttering the breadcrumbs unneccessarily.
|
|
25
|
+
if (key === 'dropdowns' && 'dropdown' in item && typeof item.dropdown === 'string') {
|
|
26
|
+
divisionTitle = item.dropdown;
|
|
27
|
+
}
|
|
28
|
+
else if (key === 'tabs' && 'tab' in item && typeof item.tab === 'string') {
|
|
29
|
+
divisionTitle = item.tab;
|
|
30
|
+
}
|
|
31
|
+
else if (key === 'anchors' && 'anchor' in item && typeof item.anchor === 'string') {
|
|
32
|
+
divisionTitle = item.anchor;
|
|
33
|
+
}
|
|
34
|
+
const newBreadcrumbs = divisionTitle
|
|
35
|
+
? [...currentBreadcrumbs, divisionTitle]
|
|
36
|
+
: currentBreadcrumbs;
|
|
37
|
+
generatePathToBreadcrumbsMapForDocsConfigRecursive(item, map, newBreadcrumbs);
|
|
38
|
+
}
|
|
19
39
|
}
|
|
20
40
|
}
|
|
21
41
|
}
|