@mintlify/previewing 4.0.517 → 4.0.519

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,6 +1,3 @@
1
- import type { DecoratedNavigation, DecoratedNavigationPage } from '@mintlify/models';
2
- import { DecoratedNavigationConfig } from '@mintlify/validation';
3
- export declare const generateNav: (pagesAcc: Record<string, DecoratedNavigationPage>) => Promise<{
4
- generatedNav?: DecoratedNavigation;
5
- generatedDocsNav: DecoratedNavigationConfig;
6
- }>;
1
+ import type { DecoratedNavigationPage } from '@mintlify/models';
2
+ import { DecoratedNavigationConfig, DocsConfig } from '@mintlify/validation';
3
+ export declare const generateNav: (pagesAcc: Record<string, DecoratedNavigationPage>, docsConfig: DocsConfig) => Promise<DecoratedNavigationConfig>;
@@ -7,11 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { generateDecoratedMintNavigationFromPages, getConfigObj, categorizeFilePaths, createPage, generateDecoratedDocsNavigationFromPages, } from '@mintlify/prebuild';
11
- import { upgradeToDocsConfig } from '@mintlify/validation';
10
+ import { categorizeFilePaths, createPage, generateDecoratedDocsNavigationFromPages, } from '@mintlify/prebuild';
12
11
  import { promises as _promises } from 'fs';
13
12
  import { join } from 'path';
14
- import { CMD_EXEC_PATH, NEXT_PROPS_PATH } from '../../constants.js';
13
+ import { CMD_EXEC_PATH } from '../../constants.js';
15
14
  const { readFile } = _promises;
16
15
  const createFilenamePageMetadataMap = (_a) => __awaiter(void 0, [_a], void 0, function* ({ contentDirectoryPath, contentFilenames, openApiFiles, asyncApiFiles, pagesAcc = {}, }) {
17
16
  const contentPromises = [];
@@ -26,24 +25,15 @@ const createFilenamePageMetadataMap = (_a) => __awaiter(void 0, [_a], void 0, fu
26
25
  yield Promise.all(contentPromises);
27
26
  return pagesAcc;
28
27
  });
29
- export const generateNav = (pagesAcc) => __awaiter(void 0, void 0, void 0, function* () {
30
- var _a;
28
+ export const generateNav = (pagesAcc, docsConfig) => __awaiter(void 0, void 0, void 0, function* () {
31
29
  const { contentFilenames, openApiFiles, asyncApiFiles } = yield categorizeFilePaths(CMD_EXEC_PATH);
32
- const [filenamePageMetadataMap, configObj, docsConfigObj] = yield Promise.all([
33
- createFilenamePageMetadataMap({
34
- contentDirectoryPath: CMD_EXEC_PATH,
35
- contentFilenames,
36
- openApiFiles,
37
- asyncApiFiles,
38
- pagesAcc,
39
- }),
40
- getConfigObj(NEXT_PROPS_PATH, 'mint'),
41
- getConfigObj(NEXT_PROPS_PATH, 'docs'),
42
- ]);
43
- let generatedNav;
44
- if (configObj) {
45
- generatedNav = generateDecoratedMintNavigationFromPages(filenamePageMetadataMap, configObj.navigation);
46
- }
47
- const generatedDocsNav = generateDecoratedDocsNavigationFromPages(filenamePageMetadataMap, (_a = docsConfigObj === null || docsConfigObj === void 0 ? void 0 : docsConfigObj.navigation) !== null && _a !== void 0 ? _a : upgradeToDocsConfig(configObj).navigation);
48
- return { generatedNav, generatedDocsNav };
30
+ const filenamePageMetadataMap = yield createFilenamePageMetadataMap({
31
+ contentDirectoryPath: CMD_EXEC_PATH,
32
+ contentFilenames,
33
+ openApiFiles,
34
+ asyncApiFiles,
35
+ pagesAcc,
36
+ });
37
+ const generatedDocsNav = generateDecoratedDocsNavigationFromPages(filenamePageMetadataMap, docsConfig.navigation);
38
+ return generatedDocsNav;
49
39
  });
@@ -216,9 +216,10 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
216
216
  });
217
217
  break;
218
218
  }
219
- case 'snippet':
219
+ case 'snippet': {
220
220
  yield fse.copy(filePath, targetPath);
221
221
  break;
222
+ }
222
223
  case 'snippet-v2': {
223
224
  let contentStr = (yield readFile(filePath)).toString();
224
225
  const tree = yield preparseMdxTree(contentStr, CMD_EXEC_PATH, filePath);
@@ -234,7 +235,7 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
234
235
  break;
235
236
  }
236
237
  case 'mintConfig':
237
- case 'docsConfig':
238
+ case 'docsConfig': {
238
239
  regenerateNav = true;
239
240
  try {
240
241
  const { mintConfig, openApiFiles, docsConfig } = yield getDocsState();
@@ -248,8 +249,9 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
248
249
  console.error(err);
249
250
  }
250
251
  break;
252
+ }
251
253
  case 'potentialYamlOpenApiSpec':
252
- case 'potentialJsonOpenApiSpec':
254
+ case 'potentialJsonOpenApiSpec': {
253
255
  let doc;
254
256
  try {
255
257
  const file = yield fs.readFile(filePath, 'utf-8');
@@ -269,9 +271,10 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
269
271
  category = 'openApi';
270
272
  }
271
273
  break;
274
+ }
272
275
  case 'css':
273
276
  case 'js':
274
- case 'staticFile':
277
+ case 'staticFile': {
275
278
  if (yield isFileSizeValid(filePath, 5)) {
276
279
  yield fse.copy(filePath, targetPath);
277
280
  }
@@ -279,6 +282,7 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
279
282
  console.error(Chalk.red(`🚨 The file at ${filename} is too big. The maximum file size is 5 mb.`));
280
283
  }
281
284
  break;
285
+ }
282
286
  }
283
287
  if (regenerateNav) {
284
288
  // TODO: Instead of re-generating the entire nav, optimize by just updating the specific page that changed.
@@ -14,14 +14,8 @@ import { generateNav } from './generate.js';
14
14
  import { getDocsState } from './getDocsState.js';
15
15
  import { readJsonFile } from './utils.js';
16
16
  export const updateGeneratedNav = () => __awaiter(void 0, void 0, void 0, function* () {
17
- const { pagesAcc } = yield getDocsState();
18
- const { generatedNav, generatedDocsNav } = yield generateNav(pagesAcc);
19
- if (generatedNav) {
20
- const targetPath = join(NEXT_PROPS_PATH, 'generatedNav.json');
21
- yield fse.outputFile(targetPath, JSON.stringify(generatedNav, null, 2), {
22
- flag: 'w',
23
- });
24
- }
17
+ const { pagesAcc, docsConfig } = yield getDocsState();
18
+ const generatedDocsNav = yield generateNav(pagesAcc, docsConfig);
25
19
  const targetDocsPath = join(NEXT_PROPS_PATH, 'generatedDocsNav.json');
26
20
  yield fse.outputFile(targetDocsPath, JSON.stringify(generatedDocsNav, null, 2), {
27
21
  flag: 'w',