@mintlify/previewing 4.0.786 → 4.0.787
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.
|
@@ -15,7 +15,7 @@ import { generateDependentSnippets } from './generateDependentSnippets.js';
|
|
|
15
15
|
import { generatePagesWithImports } from './generatePagesWithImports.js';
|
|
16
16
|
import { getDocsState } from './getDocsState.js';
|
|
17
17
|
import { resolveAllImports } from './resolveAllImports.js';
|
|
18
|
-
import { updateGeneratedNav, updateOpenApiFiles, upsertOpenApiFile } from './update.js';
|
|
18
|
+
import { updateCustomLanguages, updateGeneratedNav, updateOpenApiFiles, upsertOpenApiFile, } from './update.js';
|
|
19
19
|
import { isFileSizeValid, shouldRegenerateNavForPage } from './utils.js';
|
|
20
20
|
const { readFile } = _promises;
|
|
21
21
|
const frontmatterHashes = new Map();
|
|
@@ -175,6 +175,7 @@ const onUpdateEvent = async (filename, callback) => {
|
|
|
175
175
|
}
|
|
176
176
|
await DocsConfigUpdater.writeConfigFile(docsConfig, CLIENT_PATH);
|
|
177
177
|
await updateOpenApiFiles(openApiFiles);
|
|
178
|
+
await updateCustomLanguages(docsConfig);
|
|
178
179
|
}
|
|
179
180
|
catch (err) {
|
|
180
181
|
console.error(err);
|
|
@@ -201,6 +202,21 @@ const onUpdateEvent = async (filename, callback) => {
|
|
|
201
202
|
regenerateNav = true;
|
|
202
203
|
category = 'openApi';
|
|
203
204
|
}
|
|
205
|
+
else {
|
|
206
|
+
const customLanguages = JSON.parse(await fs.readFile(pathUtil.join(NEXT_PROPS_PATH, 'customLanguages.json'), 'utf-8'));
|
|
207
|
+
let updated = false;
|
|
208
|
+
for (const [index, customLanguage] of customLanguages.entries()) {
|
|
209
|
+
if (filePath.endsWith(customLanguage.filePath)) {
|
|
210
|
+
updated = true;
|
|
211
|
+
const file = await fs.readFile(filePath, 'utf-8');
|
|
212
|
+
customLanguages[index] = { content: file, filePath: customLanguage.filePath };
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (updated) {
|
|
217
|
+
await fs.writeFile(pathUtil.join(NEXT_PROPS_PATH, 'customLanguages.json'), JSON.stringify(customLanguages, null, 2));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
204
220
|
break;
|
|
205
221
|
}
|
|
206
222
|
case 'css':
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { OpenApiFile } from '@mintlify/models';
|
|
2
|
+
import { DocsConfig } from '@mintlify/validation';
|
|
2
3
|
export declare const updateGeneratedNav: () => Promise<void>;
|
|
3
4
|
export declare const updateOpenApiFiles: (providedOpenApiFiles?: OpenApiFile[]) => Promise<void>;
|
|
4
5
|
export declare const upsertOpenApiFile: (openApiFile: OpenApiFile) => Promise<void>;
|
|
6
|
+
export declare const updateCustomLanguages: (docsConfig?: DocsConfig) => Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { getCustomLanguages } from '@mintlify/prebuild';
|
|
1
2
|
import fse from 'fs-extra';
|
|
2
3
|
import { join } from 'path';
|
|
3
|
-
import { NEXT_PROPS_PATH } from '../../constants.js';
|
|
4
|
+
import { CMD_EXEC_PATH, NEXT_PROPS_PATH } from '../../constants.js';
|
|
4
5
|
import { generateNav } from './generate.js';
|
|
5
6
|
import { getDocsState } from './getDocsState.js';
|
|
6
7
|
import { readJsonFile } from './utils.js';
|
|
@@ -40,3 +41,16 @@ export const upsertOpenApiFile = async (openApiFile) => {
|
|
|
40
41
|
flag: 'w',
|
|
41
42
|
});
|
|
42
43
|
};
|
|
44
|
+
export const updateCustomLanguages = async (docsConfig) => {
|
|
45
|
+
if (docsConfig == undefined) {
|
|
46
|
+
docsConfig = (await getDocsState()).docsConfig;
|
|
47
|
+
}
|
|
48
|
+
const customLanguages = await getCustomLanguages({
|
|
49
|
+
config: docsConfig,
|
|
50
|
+
contentDirectoryPath: CMD_EXEC_PATH,
|
|
51
|
+
});
|
|
52
|
+
const targetPath = join(NEXT_PROPS_PATH, 'customLanguages.json');
|
|
53
|
+
await fse.outputFile(targetPath, JSON.stringify(customLanguages, null, 2), {
|
|
54
|
+
flag: 'w',
|
|
55
|
+
});
|
|
56
|
+
};
|