@mintlify/common
Advanced tools
Comparing version 1.0.242 to 1.0.243
export * from './isGroup.js'; | ||
export * from './isPage.js'; | ||
export * from './generatePathToBreadcrumbsMap.js'; | ||
export * from './getFirstPageFromNavigation.js'; | ||
export * from './generatePathToBreadcrumbsMapForDocsConfig.js'; |
export * from './isGroup.js'; | ||
export * from './isPage.js'; | ||
export * from './generatePathToBreadcrumbsMap.js'; | ||
export * from './getFirstPageFromNavigation.js'; | ||
export * from './generatePathToBreadcrumbsMapForDocsConfig.js'; |
import { DecoratedNavigationEntry, DecoratedNavigationGroup } from '@mintlify/models'; | ||
import { DecoratedGroupConfig, DecoratedPageOrGroupConfig } from '@mintlify/validation'; | ||
export declare const isGroup: (entry: DecoratedNavigationEntry | DecoratedPageOrGroupConfig) => entry is DecoratedNavigationGroup | DecoratedGroupConfig; | ||
export declare const isGroup: (entry: DecoratedNavigationEntry) => entry is DecoratedNavigationGroup; |
import { DecoratedNavigationEntry, DecoratedNavigationPage } from '@mintlify/models'; | ||
import { DecoratedPageOrGroupConfig } from '@mintlify/validation'; | ||
export declare const isPage: (entry: DecoratedNavigationEntry | DecoratedPageOrGroupConfig) => entry is DecoratedNavigationPage; | ||
export declare const isPage: (entry: DecoratedNavigationEntry) => entry is DecoratedNavigationPage; |
export const isPage = (entry) => { | ||
return entry.hasOwnProperty('href') && entry.hasOwnProperty('title'); | ||
return entry.hasOwnProperty('href'); | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { DecoratedNavigationConfig } from '@mintlify/validation'; | ||
import type { DecoratedNavigation } from '@mintlify/models'; | ||
/** | ||
@@ -6,2 +6,2 @@ * Assumes page hrefs in navWithPageContext have a leading / but config page paths do not. | ||
*/ | ||
export declare function generatePathToVersionDict(decoratedNav: DecoratedNavigationConfig): Map<string, string | undefined>; | ||
export declare function generatePathToVersionDict(decoratedNav: DecoratedNavigation): Map<string, string | undefined>; |
@@ -1,3 +0,2 @@ | ||
import { divisions } from '@mintlify/validation'; | ||
import { isPage } from '../navigation/isPage.js'; | ||
import { isGroup } from '../navigation/index.js'; | ||
import { optionallyRemoveLeadingSlash } from '../optionallyRemoveLeadingSlash.js'; | ||
@@ -10,31 +9,17 @@ /** | ||
const pathToVersionDict = new Map(); | ||
generatePathToVersionDictRecursive(pathToVersionDict, decoratedNav); | ||
decoratedNav.forEach((group) => generatePathToVersionDictRecursive(pathToVersionDict, group)); | ||
return pathToVersionDict; | ||
} | ||
function generatePathToVersionDictRecursive(pathToVersionDict, nav, nearestVersion) { | ||
if (typeof nav !== 'object') | ||
return; | ||
if (isPage(nav)) { | ||
pathToVersionDict.set(optionallyRemoveLeadingSlash(nav.href), nearestVersion); | ||
function generatePathToVersionDictRecursive(pathToVersionDict, entry, nearestVersion) { | ||
var _a; | ||
if (isGroup(entry)) { | ||
entry.pages.forEach((subEntry) => { | ||
var _a; | ||
return generatePathToVersionDictRecursive(pathToVersionDict, subEntry, (_a = entry.version) !== null && _a !== void 0 ? _a : nearestVersion); | ||
}); | ||
} | ||
if ('pages' in nav) { | ||
for (const page of nav.pages) { | ||
if (typeof page === 'object') { | ||
generatePathToVersionDictRecursive(pathToVersionDict, page, nearestVersion); | ||
} | ||
} | ||
else { | ||
const finalVersion = (_a = entry.version) !== null && _a !== void 0 ? _a : nearestVersion; | ||
pathToVersionDict.set(optionallyRemoveLeadingSlash(entry.href), finalVersion); | ||
} | ||
for (const key of ['groups', ...divisions]) { | ||
if (key in nav) { | ||
const items = nav[key]; | ||
if (Array.isArray(items)) { | ||
for (const item of items) { | ||
let version = nearestVersion; | ||
if (key === 'versions') | ||
version = item.version; | ||
generatePathToVersionDictRecursive(pathToVersionDict, item, version); | ||
} | ||
} | ||
} | ||
} | ||
} |
{ | ||
"name": "@mintlify/common", | ||
"version": "1.0.242", | ||
"version": "1.0.243", | ||
"description": "Commonly shared code within Mintlify", | ||
@@ -32,5 +32,5 @@ "main": "./dist/index.js", | ||
"@mintlify/mdx": "^1.0.1", | ||
"@mintlify/models": "0.0.166", | ||
"@mintlify/models": "0.0.167", | ||
"@mintlify/openapi-parser": "^0.0.7", | ||
"@mintlify/validation": "0.1.266", | ||
"@mintlify/validation": "0.1.267", | ||
"@sindresorhus/slugify": "^2.1.1", | ||
@@ -83,3 +83,3 @@ "acorn": "^8.11.2", | ||
}, | ||
"gitHead": "99a79cdcdc326ffa797e48a64056719f4cd8f528" | ||
"gitHead": "b64861e26b20aac2c3b3ed94a08b5b10451cfe7f" | ||
} |
Sorry, the diff of this file is not supported yet
276415
174
2845
+ Added@mintlify/models@0.0.167(transitive)
+ Added@mintlify/validation@0.1.267(transitive)
- Removed@mintlify/models@0.0.166(transitive)
- Removed@mintlify/validation@0.1.266(transitive)
Updated@mintlify/models@0.0.167
Updated@mintlify/validation@0.1.267