@mintlify/common 1.0.867 → 1.0.869
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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DecoratedNavigationConfig } from '@mintlify/validation';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a map from page paths to their search boost multiplier based on navigation hierarchy.
|
|
4
|
+
* A page inherits its boost factor from itself or any parent group/division that sets `boost`.
|
|
5
|
+
* The map only contains entries for pages with a boost factor > 1; unboosted pages are omitted.
|
|
6
|
+
* Assumes page hrefs in navWithPageContext have a leading / but config page paths do not.
|
|
7
|
+
* Outputted dictionary will NOT have a leading / in the dictionary keys.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generatePathToBoostDict(decoratedNav: DecoratedNavigationConfig): Map<string, number>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { divisions } from '@mintlify/validation';
|
|
2
|
+
import { isPage } from '../navigation/isPage.js';
|
|
3
|
+
import { optionallyRemoveLeadingSlash } from '../optionallyRemoveLeadingSlash.js';
|
|
4
|
+
import { iterateObjectArrayProperty } from './iterateObjectArrayProperty.js';
|
|
5
|
+
/**
|
|
6
|
+
* Generates a map from page paths to their search boost multiplier based on navigation hierarchy.
|
|
7
|
+
* A page inherits its boost factor from itself or any parent group/division that sets `boost`.
|
|
8
|
+
* The map only contains entries for pages with a boost factor > 1; unboosted pages are omitted.
|
|
9
|
+
* Assumes page hrefs in navWithPageContext have a leading / but config page paths do not.
|
|
10
|
+
* Outputted dictionary will NOT have a leading / in the dictionary keys.
|
|
11
|
+
*/
|
|
12
|
+
export function generatePathToBoostDict(decoratedNav) {
|
|
13
|
+
const pathToBoostDict = new Map();
|
|
14
|
+
generatePathToBoostDictRecursive(pathToBoostDict, decoratedNav, 1);
|
|
15
|
+
return pathToBoostDict;
|
|
16
|
+
}
|
|
17
|
+
function generatePathToBoostDictRecursive(pathToBoostDict, nav, parentBoost) {
|
|
18
|
+
if (typeof nav !== 'object')
|
|
19
|
+
return;
|
|
20
|
+
const effectiveBoost = 'boost' in nav && typeof nav.boost === 'number' ? nav.boost : parentBoost;
|
|
21
|
+
if (isPage(nav)) {
|
|
22
|
+
const key = optionallyRemoveLeadingSlash(nav.href);
|
|
23
|
+
if (!pathToBoostDict.has(key) && effectiveBoost !== 1) {
|
|
24
|
+
pathToBoostDict.set(key, effectiveBoost);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if ('pages' in nav && Array.isArray(nav.pages)) {
|
|
28
|
+
if ('root' in nav && typeof nav.root === 'object') {
|
|
29
|
+
generatePathToBoostDictRecursive(pathToBoostDict, nav.root, effectiveBoost);
|
|
30
|
+
}
|
|
31
|
+
for (const page of nav.pages) {
|
|
32
|
+
if (typeof page === 'object') {
|
|
33
|
+
generatePathToBoostDictRecursive(pathToBoostDict, page, effectiveBoost);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (const key of ['groups', ...divisions]) {
|
|
38
|
+
iterateObjectArrayProperty(nav, key, (item) => generatePathToBoostDictRecursive(pathToBoostDict, item, effectiveBoost));
|
|
39
|
+
}
|
|
40
|
+
}
|
package/dist/divisions/index.js
CHANGED