@mintlify/common 1.0.1089 → 1.0.1091
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/dist/navigation/filterDivisions.js +8 -0
- package/dist/navigation/firstHrefDivisionScoping.test.d.ts +1 -0
- package/dist/navigation/firstHrefDivisionScoping.test.js +147 -0
- package/dist/navigation/updateFirstHrefInDivision.d.ts +2 -1
- package/dist/navigation/updateFirstHrefInDivision.js +10 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -47,6 +47,8 @@ export const filterDivisions = ({ currentPath, currentVersion, currentLanguage,
|
|
|
47
47
|
};
|
|
48
48
|
const firstHrefInVersion = new Map();
|
|
49
49
|
const firstHrefInLanguage = new Map();
|
|
50
|
+
let activeVersionsOwner;
|
|
51
|
+
let activeLanguagesOwner;
|
|
50
52
|
function findPageInNavigation({ currentPath, entry, parentGroups, isPreview = false, ancestorDivisionNames = [], }) {
|
|
51
53
|
if (typeof entry !== 'object') {
|
|
52
54
|
return { page: undefined, groupsOrPages: undefined };
|
|
@@ -144,6 +146,10 @@ export const filterDivisions = ({ currentPath, currentVersion, currentLanguage,
|
|
|
144
146
|
ancestorDivisionNames: newAncestorNames,
|
|
145
147
|
});
|
|
146
148
|
if (page) {
|
|
149
|
+
if (key === 'versions' && !activeVersionsOwner)
|
|
150
|
+
activeVersionsOwner = entry;
|
|
151
|
+
if (key === 'languages' && !activeLanguagesOwner)
|
|
152
|
+
activeLanguagesOwner = entry;
|
|
147
153
|
const isSameDivision = createDivisionMatcher(subDivisions);
|
|
148
154
|
const filteredSubDivisions = subDivisions
|
|
149
155
|
.filter((division) => isDivisionAccessible(division, userGroups, isPreview))
|
|
@@ -212,6 +218,7 @@ export const filterDivisions = ({ currentPath, currentVersion, currentLanguage,
|
|
|
212
218
|
firstHrefInDivision: firstHrefInVersion,
|
|
213
219
|
navigationDivisions,
|
|
214
220
|
isHiddenPage: page === undefined,
|
|
221
|
+
activeDivisionOwner: activeVersionsOwner,
|
|
215
222
|
});
|
|
216
223
|
}
|
|
217
224
|
if (navigationDivisions.languages.length) {
|
|
@@ -228,6 +235,7 @@ export const filterDivisions = ({ currentPath, currentVersion, currentLanguage,
|
|
|
228
235
|
firstHrefInDivision: firstHrefInLanguage,
|
|
229
236
|
navigationDivisions,
|
|
230
237
|
isHiddenPage: page === undefined,
|
|
238
|
+
activeDivisionOwner: activeLanguagesOwner,
|
|
231
239
|
});
|
|
232
240
|
}
|
|
233
241
|
if (decoratedNav && 'global' in decoratedNav && decoratedNav.global) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { filterDivisions } from './filterDivisions.js';
|
|
2
|
+
const baseArgs = {
|
|
3
|
+
userGroups: new Set(),
|
|
4
|
+
currentVersion: undefined,
|
|
5
|
+
currentLanguage: undefined,
|
|
6
|
+
shouldUseDivisionMatch: true,
|
|
7
|
+
cache: { dropdownCache: new Map() },
|
|
8
|
+
};
|
|
9
|
+
const dropdownsWithIdenticalVersionSets = {
|
|
10
|
+
dropdowns: [
|
|
11
|
+
{
|
|
12
|
+
dropdown: 'Market Risk',
|
|
13
|
+
versions: [
|
|
14
|
+
{
|
|
15
|
+
version: '6.0 (latest)',
|
|
16
|
+
groups: [
|
|
17
|
+
{
|
|
18
|
+
group: 'Guides',
|
|
19
|
+
pages: [{ title: 'MR Intro', href: '/solutions/market-risk/6.0/intro' }],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
version: 'Previous versions',
|
|
25
|
+
pages: [{ title: 'MR Previous', href: '/solutions/market-risk/previous-versions' }],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
dropdown: 'FRTB',
|
|
31
|
+
versions: [
|
|
32
|
+
{
|
|
33
|
+
version: '6.0 (latest)',
|
|
34
|
+
groups: [
|
|
35
|
+
{
|
|
36
|
+
group: 'Cube',
|
|
37
|
+
pages: [
|
|
38
|
+
{ title: 'LH', href: '/solutions/frtb/6.0/cube/lh' },
|
|
39
|
+
{ title: 'Omega', href: '/solutions/frtb/6.0/cube/omega' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
version: 'Previous versions',
|
|
46
|
+
pages: [{ title: 'FRTB Previous', href: '/solutions/frtb/previous-versions' }],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
const productsWithSharedPage = {
|
|
53
|
+
products: [
|
|
54
|
+
{
|
|
55
|
+
product: 'Java SDK',
|
|
56
|
+
versions: [
|
|
57
|
+
{
|
|
58
|
+
version: '6.1',
|
|
59
|
+
pages: [
|
|
60
|
+
{ title: 'Java Intro', href: '/java-sdk/6.1/intro' },
|
|
61
|
+
{ title: 'Billing', href: '/shared/billing' },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
version: 'Previous versions',
|
|
66
|
+
pages: [{ title: 'Java Old', href: '/java-sdk/previous/intro' }],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
product: 'Solutions',
|
|
72
|
+
versions: [
|
|
73
|
+
{
|
|
74
|
+
version: '6.1',
|
|
75
|
+
pages: [
|
|
76
|
+
{ title: 'Sol Intro', href: '/solutions/6.1/intro' },
|
|
77
|
+
{ title: 'Billing', href: '/shared/billing' },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
version: 'Previous versions',
|
|
82
|
+
pages: [{ title: 'Sol Old', href: '/solutions/previous/intro' }],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
const dropdownsWithIdenticalLanguageSets = {
|
|
89
|
+
dropdowns: [
|
|
90
|
+
{
|
|
91
|
+
dropdown: 'Alpha',
|
|
92
|
+
languages: [
|
|
93
|
+
{
|
|
94
|
+
language: 'en',
|
|
95
|
+
pages: [{ title: 'Alpha Overview', href: '/alpha/en/overview' }],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
language: 'es',
|
|
99
|
+
pages: [{ title: 'Alpha Resumen', href: '/alpha/es/overview' }],
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
dropdown: 'Beta',
|
|
105
|
+
languages: [
|
|
106
|
+
{
|
|
107
|
+
language: 'en',
|
|
108
|
+
pages: [{ title: 'Beta Overview', href: '/beta/en/overview' }],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
language: 'es',
|
|
112
|
+
pages: [{ title: 'Beta Resumen', href: '/beta/es/overview' }],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
describe('firstHrefInDivision scoping with colliding division labels', () => {
|
|
119
|
+
it('resolves a sibling version inside the active dropdown, not the first label match', () => {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
const result = filterDivisions(Object.assign(Object.assign({}, baseArgs), { currentPath: '/solutions/frtb/6.0/cube/lh', currentVersion: '6.0 (latest)', decoratedNav: dropdownsWithIdenticalVersionSets }));
|
|
122
|
+
expect((_a = result.firstHrefInVersion.get('6.0 (latest)')) === null || _a === void 0 ? void 0 : _a.href).toBe('/solutions/frtb/6.0/cube/lh');
|
|
123
|
+
expect((_b = result.firstHrefInVersion.get('Previous versions')) === null || _b === void 0 ? void 0 : _b.href).toBe('/solutions/frtb/previous-versions');
|
|
124
|
+
});
|
|
125
|
+
it('resolves a sibling version inside the first dropdown when the reader is there', () => {
|
|
126
|
+
var _a;
|
|
127
|
+
const result = filterDivisions(Object.assign(Object.assign({}, baseArgs), { currentPath: '/solutions/market-risk/6.0/intro', currentVersion: '6.0 (latest)', decoratedNav: dropdownsWithIdenticalVersionSets }));
|
|
128
|
+
expect((_a = result.firstHrefInVersion.get('Previous versions')) === null || _a === void 0 ? void 0 : _a.href).toBe('/solutions/market-risk/previous-versions');
|
|
129
|
+
});
|
|
130
|
+
it('resolves a sibling version for a shared page using the current product', () => {
|
|
131
|
+
var _a;
|
|
132
|
+
const result = filterDivisions(Object.assign(Object.assign({}, baseArgs), { currentPath: '/shared/billing', currentVersion: '6.1', currentProduct: 'Solutions', decoratedNav: productsWithSharedPage }));
|
|
133
|
+
const activeProduct = result.products.find((p) => 'isActive' in p && p.isActive);
|
|
134
|
+
expect(activeProduct === null || activeProduct === void 0 ? void 0 : activeProduct.product).toBe('Solutions');
|
|
135
|
+
expect((_a = result.firstHrefInVersion.get('Previous versions')) === null || _a === void 0 ? void 0 : _a.href).toBe('/solutions/previous/intro');
|
|
136
|
+
});
|
|
137
|
+
it('resolves a sibling language inside the active dropdown', () => {
|
|
138
|
+
var _a;
|
|
139
|
+
const result = filterDivisions(Object.assign(Object.assign({}, baseArgs), { currentPath: '/beta/en/overview', currentLanguage: 'en', decoratedNav: dropdownsWithIdenticalLanguageSets }));
|
|
140
|
+
expect((_a = result.firstHrefInLanguage.get('es')) === null || _a === void 0 ? void 0 : _a.href).toBe('/beta/es/overview');
|
|
141
|
+
});
|
|
142
|
+
it('keeps hidden-page behavior unchanged', () => {
|
|
143
|
+
var _a;
|
|
144
|
+
const result = filterDivisions(Object.assign(Object.assign({}, baseArgs), { currentPath: '/not-in-nav', currentVersion: '6.0 (latest)', decoratedNav: dropdownsWithIdenticalVersionSets }));
|
|
145
|
+
expect((_a = result.firstHrefInVersion.get('6.0 (latest)')) === null || _a === void 0 ? void 0 : _a.href).toBe('/not-in-nav');
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -12,7 +12,7 @@ export type DivisionMatch = {
|
|
|
12
12
|
href: string;
|
|
13
13
|
matchLevel: DivisionMatchLevel;
|
|
14
14
|
};
|
|
15
|
-
export declare function updateFirstHrefInDivision({ type, currentPath, entry, parentGroups, nearestDivisionValue, isActiveGroup, inActiveDivision, currentDivisionValue, allDivisionValues, firstHrefInDivision, navigationDivisions, isHiddenPage, activeGroupNames, }: {
|
|
15
|
+
export declare function updateFirstHrefInDivision({ type, currentPath, entry, parentGroups, nearestDivisionValue, isActiveGroup, inActiveDivision, currentDivisionValue, allDivisionValues, firstHrefInDivision, navigationDivisions, isHiddenPage, activeGroupNames, activeDivisionOwner, }: {
|
|
16
16
|
type: 'version' | 'language';
|
|
17
17
|
currentPath: string;
|
|
18
18
|
entry: DecoratedNavigationConfig | DecoratedPageOrGroupConfig;
|
|
@@ -26,5 +26,6 @@ export declare function updateFirstHrefInDivision({ type, currentPath, entry, pa
|
|
|
26
26
|
navigationDivisions: NavigationDivisions;
|
|
27
27
|
isHiddenPage: boolean;
|
|
28
28
|
activeGroupNames?: Set<string>;
|
|
29
|
+
activeDivisionOwner?: object;
|
|
29
30
|
}): void;
|
|
30
31
|
export declare function pathsDifferByOneSegment(a: string, b: string, type: 'version' | 'language'): boolean;
|
|
@@ -13,7 +13,7 @@ export var DivisionMatchLevel;
|
|
|
13
13
|
DivisionMatchLevel[DivisionMatchLevel["UNVERSIONED"] = 5] = "UNVERSIONED";
|
|
14
14
|
})(DivisionMatchLevel || (DivisionMatchLevel = {}));
|
|
15
15
|
const ACCEPTED_BASE_PATHS = ['docs', 'doc', 'documentation', 'help'];
|
|
16
|
-
export function updateFirstHrefInDivision({ type, currentPath, entry, parentGroups, nearestDivisionValue, isActiveGroup, inActiveDivision, currentDivisionValue, allDivisionValues, firstHrefInDivision, navigationDivisions, isHiddenPage, activeGroupNames, }) {
|
|
16
|
+
export function updateFirstHrefInDivision({ type, currentPath, entry, parentGroups, nearestDivisionValue, isActiveGroup, inActiveDivision, currentDivisionValue, allDivisionValues, firstHrefInDivision, navigationDivisions, isHiddenPage, activeGroupNames, activeDivisionOwner, }) {
|
|
17
17
|
if (typeof entry !== 'object')
|
|
18
18
|
return;
|
|
19
19
|
if (isPage(entry)) {
|
|
@@ -44,6 +44,7 @@ export function updateFirstHrefInDivision({ type, currentPath, entry, parentGrou
|
|
|
44
44
|
navigationDivisions,
|
|
45
45
|
isHiddenPage,
|
|
46
46
|
activeGroupNames,
|
|
47
|
+
activeDivisionOwner,
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
for (const page of entry.pages) {
|
|
@@ -62,6 +63,7 @@ export function updateFirstHrefInDivision({ type, currentPath, entry, parentGrou
|
|
|
62
63
|
navigationDivisions,
|
|
63
64
|
isHiddenPage,
|
|
64
65
|
activeGroupNames,
|
|
66
|
+
activeDivisionOwner,
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -91,6 +93,7 @@ export function updateFirstHrefInDivision({ type, currentPath, entry, parentGrou
|
|
|
91
93
|
navigationDivisions,
|
|
92
94
|
isHiddenPage,
|
|
93
95
|
activeGroupNames,
|
|
96
|
+
activeDivisionOwner,
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
}
|
|
@@ -99,7 +102,11 @@ export function updateFirstHrefInDivision({ type, currentPath, entry, parentGrou
|
|
|
99
102
|
if (!subDivisions)
|
|
100
103
|
continue;
|
|
101
104
|
let inActiveDivision = false;
|
|
102
|
-
|
|
105
|
+
const isMatchingDivisionKey = (type === 'version' && key === 'versions') || (type === 'language' && key === 'languages');
|
|
106
|
+
if (isMatchingDivisionKey && activeDivisionOwner !== undefined) {
|
|
107
|
+
inActiveDivision = entry === activeDivisionOwner;
|
|
108
|
+
}
|
|
109
|
+
else if (allDivisionValues && allDivisionValues.length) {
|
|
103
110
|
if (type === 'version' && key === 'versions') {
|
|
104
111
|
const localDivisionValueCount = navigationDivisions.versions.filter((version) => !version.isGlobal).length;
|
|
105
112
|
inActiveDivision =
|
|
@@ -161,6 +168,7 @@ export function updateFirstHrefInDivision({ type, currentPath, entry, parentGrou
|
|
|
161
168
|
navigationDivisions,
|
|
162
169
|
isHiddenPage,
|
|
163
170
|
activeGroupNames: activeGroupsInVersionContext,
|
|
171
|
+
activeDivisionOwner,
|
|
164
172
|
});
|
|
165
173
|
}
|
|
166
174
|
}
|