@mintlify/common 1.0.563 → 1.0.564

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,8 @@
1
+ import { DecoratedNavigationConfig } from '@mintlify/validation';
2
+ /**
3
+ * Generates a map from page paths to their public status based on navigation hierarchy.
4
+ * A page is public if it or any parent group/division has public: true.
5
+ * Assumes page hrefs in navWithPageContext have a leading / but config page paths do not.
6
+ * Outputted dictionary will NOT have a leading / in the dictionary keys.
7
+ */
8
+ export declare function generatePathToPublicDict(decoratedNav: DecoratedNavigationConfig): Map<string, boolean>;
@@ -0,0 +1,48 @@
1
+ import { divisions } from '@mintlify/validation';
2
+ import { isPage } from '../navigation/isPage.js';
3
+ import { optionallyRemoveLeadingSlash } from '../optionallyRemoveLeadingSlash.js';
4
+ /**
5
+ * Generates a map from page paths to their public status based on navigation hierarchy.
6
+ * A page is public if it or any parent group/division has public: true.
7
+ * Assumes page hrefs in navWithPageContext have a leading / but config page paths do not.
8
+ * Outputted dictionary will NOT have a leading / in the dictionary keys.
9
+ */
10
+ export function generatePathToPublicDict(decoratedNav) {
11
+ const pathToPublicDict = new Map();
12
+ generatePathToPublicDictRecursive(pathToPublicDict, decoratedNav, false);
13
+ return pathToPublicDict;
14
+ }
15
+ function generatePathToPublicDictRecursive(pathToPublicDict, nav, parentPublic) {
16
+ if (typeof nav !== 'object')
17
+ return;
18
+ // Determine the effective public status for this level
19
+ const effectivePublic = 'public' in nav && typeof nav.public === 'boolean' ? nav.public : parentPublic;
20
+ if (isPage(nav)) {
21
+ const key = optionallyRemoveLeadingSlash(nav.href);
22
+ // Set the public status for this page if not already set
23
+ // We keep the first value encountered to handle duplicate paths
24
+ if (!pathToPublicDict.has(key)) {
25
+ pathToPublicDict.set(key, effectivePublic);
26
+ }
27
+ }
28
+ if ('pages' in nav) {
29
+ if ('root' in nav && typeof nav.root === 'object') {
30
+ generatePathToPublicDictRecursive(pathToPublicDict, nav.root, effectivePublic);
31
+ }
32
+ for (const page of nav.pages) {
33
+ if (typeof page === 'object') {
34
+ generatePathToPublicDictRecursive(pathToPublicDict, page, effectivePublic);
35
+ }
36
+ }
37
+ }
38
+ for (const key of ['groups', ...divisions]) {
39
+ if (key in nav) {
40
+ const items = nav[key];
41
+ if (Array.isArray(items)) {
42
+ for (const item of items) {
43
+ generatePathToPublicDictRecursive(pathToPublicDict, item, effectivePublic);
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './generatePathToVersionDict.js';
2
2
  export * from './generatePathToVersionDictForDocsConfig.js';
3
3
  export * from './generatePathToLanguageDict.js';
4
+ export * from './generatePathToPublicDict.js';
@@ -1,3 +1,4 @@
1
1
  export * from './generatePathToVersionDict.js';
2
2
  export * from './generatePathToVersionDictForDocsConfig.js';
3
3
  export * from './generatePathToLanguageDict.js';
4
+ export * from './generatePathToPublicDict.js';