@mintlify/common 1.0.505 → 1.0.506
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,2 +1,2 @@
|
|
|
1
1
|
import type { DecoratedNavigationPage } from '@mintlify/models';
|
|
2
|
-
export declare function checkNavAccess(page: DecoratedNavigationPage, userGroups: Set<string
|
|
2
|
+
export declare function checkNavAccess(page: DecoratedNavigationPage, userGroups: Set<string>, isPreview?: boolean): boolean;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export function checkNavAccess(page, userGroups) {
|
|
1
|
+
export function checkNavAccess(page, userGroups, isPreview = false) {
|
|
2
|
+
if (isPreview)
|
|
3
|
+
return true;
|
|
2
4
|
const pageGroups = Array.isArray(page.groups) && page.groups.every((pageGroup) => typeof pageGroup === 'string')
|
|
3
5
|
? page.groups
|
|
4
6
|
: undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DecoratedNavigationPage } from '@mintlify/models';
|
|
2
2
|
import { DecoratedGroupConfig, DecoratedNavigationConfig, DecoratedPageConfig } from '@mintlify/validation';
|
|
3
|
-
export declare function getFirstPageFromNavigation(node: DecoratedNavigationConfig | DecoratedGroupConfig | DecoratedPageConfig | undefined, userGroups?: Set<string>, shouldCheckNavAccess?: boolean): DecoratedNavigationPage | undefined;
|
|
3
|
+
export declare function getFirstPageFromNavigation(node: DecoratedNavigationConfig | DecoratedGroupConfig | DecoratedPageConfig | undefined, userGroups?: Set<string>, shouldCheckNavAccess?: boolean, isPreview?: boolean): DecoratedNavigationPage | undefined;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { divisions, } from '@mintlify/validation';
|
|
2
2
|
import { replaceSlashIndex } from '../slug/replaceSlashIndex.js';
|
|
3
3
|
import { checkNavAccess, isPage } from './index.js';
|
|
4
|
-
export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAccess = false) {
|
|
4
|
+
export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAccess = false, isPreview = false) {
|
|
5
5
|
if (!node || typeof node !== 'object')
|
|
6
6
|
return undefined;
|
|
7
7
|
if (isPage(node)) {
|
|
8
|
-
if (shouldCheckNavAccess && userGroups && !checkNavAccess(node, userGroups)) {
|
|
8
|
+
if (shouldCheckNavAccess && userGroups && !checkNavAccess(node, userGroups, isPreview)) {
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
11
11
|
node.href = replaceSlashIndex(node.href);
|
|
@@ -13,7 +13,7 @@ export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAcces
|
|
|
13
13
|
}
|
|
14
14
|
if ('pages' in node) {
|
|
15
15
|
if ('root' in node && typeof node.root === 'object') {
|
|
16
|
-
const page = getFirstPageFromNavigation(node.root, userGroups, shouldCheckNavAccess);
|
|
16
|
+
const page = getFirstPageFromNavigation(node.root, userGroups, shouldCheckNavAccess, isPreview);
|
|
17
17
|
if (page) {
|
|
18
18
|
page.href = replaceSlashIndex(page.href);
|
|
19
19
|
return page;
|
|
@@ -21,7 +21,7 @@ export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAcces
|
|
|
21
21
|
}
|
|
22
22
|
for (const page of node.pages) {
|
|
23
23
|
if (typeof page === 'object') {
|
|
24
|
-
const pagePath = getFirstPageFromNavigation(page, userGroups, shouldCheckNavAccess);
|
|
24
|
+
const pagePath = getFirstPageFromNavigation(page, userGroups, shouldCheckNavAccess, isPreview);
|
|
25
25
|
if (pagePath) {
|
|
26
26
|
pagePath.href = replaceSlashIndex(pagePath.href);
|
|
27
27
|
return pagePath;
|
|
@@ -33,7 +33,7 @@ export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAcces
|
|
|
33
33
|
for (const group of node.groups) {
|
|
34
34
|
if (group.hidden)
|
|
35
35
|
continue;
|
|
36
|
-
const page = getFirstPageFromNavigation(group, userGroups, shouldCheckNavAccess);
|
|
36
|
+
const page = getFirstPageFromNavigation(group, userGroups, shouldCheckNavAccess, isPreview);
|
|
37
37
|
if (page) {
|
|
38
38
|
page.href = replaceSlashIndex(page.href);
|
|
39
39
|
return page;
|
|
@@ -47,7 +47,7 @@ export function getFirstPageFromNavigation(node, userGroups, shouldCheckNavAcces
|
|
|
47
47
|
for (const item of items) {
|
|
48
48
|
if (typeof item === 'object' && 'hidden' in item && item.hidden)
|
|
49
49
|
continue;
|
|
50
|
-
const page = getFirstPageFromNavigation(item, userGroups, shouldCheckNavAccess);
|
|
50
|
+
const page = getFirstPageFromNavigation(item, userGroups, shouldCheckNavAccess, isPreview);
|
|
51
51
|
if (page) {
|
|
52
52
|
page.href = replaceSlashIndex(page.href);
|
|
53
53
|
return page;
|