@mintlify/common 1.0.973 → 1.0.974

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,12 @@
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
+ }
2
10
  const MAX_RECURSION_DEPTH = 100;
3
11
  export function generatePathToBreadcrumbsMapForDocsConfig(navigation) {
4
12
  const pathToBreadcrumbs = new Map();
@@ -15,22 +23,12 @@ function generatePathToBreadcrumbsMapForDocsConfigRecursive(nav, map, currentBre
15
23
  if (!Array.isArray(items)) {
16
24
  continue;
17
25
  }
26
+ const propertyName = key === 'groups' ? 'group' : divisionPropertyNameMap[key];
27
+ const includeDivisionInBreadcrumbs = key === 'groups' || !excludedBreadcrumbDivisions.has(key);
18
28
  for (const item of items) {
19
- let divisionTitle = '';
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
- }
29
+ const divisionTitle = includeDivisionInBreadcrumbs
30
+ ? getStringProperty(item, propertyName)
31
+ : '';
34
32
  const newBreadcrumbs = divisionTitle
35
33
  ? [...currentBreadcrumbs, divisionTitle]
36
34
  : currentBreadcrumbs;