@mintlify/common 1.0.816 → 1.0.817
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/getFirstPageFromNavigation.js +3 -1
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/prioritize-default-division-item.d.ts +1 -0
- package/dist/navigation/prioritize-default-division-item.js +12 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { divisions, } from '@mintlify/validation';
|
|
2
2
|
import { replaceSlashIndex } from '../slug/replaceSlashIndex.js';
|
|
3
3
|
import { checkNavAccess, isPage } from './index.js';
|
|
4
|
+
import { prioritizeDefaultDivisionItem } from './prioritize-default-division-item.js';
|
|
4
5
|
export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAccess = false, isPreview = false) {
|
|
5
6
|
if (!node || typeof node !== 'object')
|
|
6
7
|
return undefined;
|
|
@@ -44,7 +45,8 @@ export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAcces
|
|
|
44
45
|
if (key in node) {
|
|
45
46
|
const items = node[key];
|
|
46
47
|
if (Array.isArray(items)) {
|
|
47
|
-
|
|
48
|
+
const orderedItems = prioritizeDefaultDivisionItem(items, key);
|
|
49
|
+
for (const item of orderedItems) {
|
|
48
50
|
if (typeof item === 'object' && 'hidden' in item && item.hidden)
|
|
49
51
|
continue;
|
|
50
52
|
const page = getFirstPageFromNavigation(item, userGroups, shouldCheckNavAccess, isPreview);
|
package/dist/navigation/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function prioritizeDefaultDivisionItem<T>(items: T[], key: string): T[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const divisionsThatPrioritizeDefault = new Set(['languages', 'versions']);
|
|
2
|
+
function isDefaultDivisionItem(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && 'default' in value;
|
|
4
|
+
}
|
|
5
|
+
export function prioritizeDefaultDivisionItem(items, key) {
|
|
6
|
+
if (!divisionsThatPrioritizeDefault.has(key))
|
|
7
|
+
return items;
|
|
8
|
+
const defaultItem = items.find((item) => isDefaultDivisionItem(item) && item.default);
|
|
9
|
+
if (!defaultItem)
|
|
10
|
+
return items;
|
|
11
|
+
return [defaultItem, ...items.filter((item) => item !== defaultItem)];
|
|
12
|
+
}
|