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