@mintlify/prebuild 1.0.971 → 1.0.973
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.
- package/dist/prebuild/update/preserveAutoGeneratedMetadata.d.ts +7 -0
- package/dist/prebuild/update/preserveAutoGeneratedMetadata.js +22 -0
- package/dist/prebuild/update/read/readContent.js +2 -1
- package/dist/prebuild/update/resolveImportsAndWriteFiles.js +2 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DecoratedNavigationPage } from '@mintlify/models';
|
|
2
|
+
/**
|
|
3
|
+
* When user MDX doesn't explicitly set title/description, preserve the
|
|
4
|
+
* auto-generated values (e.g. from OpenAPI schemas) that already exist
|
|
5
|
+
* in pagesAcc. Mutates pageMetadata and pagesAcc in place.
|
|
6
|
+
*/
|
|
7
|
+
export declare const preserveAutoGeneratedMetadata: (contentStr: string, slug: string, pageMetadata: DecoratedNavigationPage, pagesAcc: Record<string, DecoratedNavigationPage>) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parseFrontmatter } from '@mintlify/common';
|
|
2
|
+
/**
|
|
3
|
+
* When user MDX doesn't explicitly set title/description, preserve the
|
|
4
|
+
* auto-generated values (e.g. from OpenAPI schemas) that already exist
|
|
5
|
+
* in pagesAcc. Mutates pageMetadata and pagesAcc in place.
|
|
6
|
+
*/
|
|
7
|
+
export const preserveAutoGeneratedMetadata = (contentStr, slug, pageMetadata, pagesAcc) => {
|
|
8
|
+
const existing = pagesAcc[slug];
|
|
9
|
+
if (existing) {
|
|
10
|
+
try {
|
|
11
|
+
const frontmatter = parseFrontmatter(contentStr).attributes;
|
|
12
|
+
if (!frontmatter.title && existing.title)
|
|
13
|
+
pageMetadata.title = existing.title;
|
|
14
|
+
if (!frontmatter.description && existing.description)
|
|
15
|
+
pageMetadata.description = existing.description;
|
|
16
|
+
if (!frontmatter.sidebarTitle && existing.sidebarTitle)
|
|
17
|
+
pageMetadata.sidebarTitle = existing.sidebarTitle;
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
}
|
|
21
|
+
pagesAcc[slug] = pageMetadata;
|
|
22
|
+
};
|
|
@@ -2,6 +2,7 @@ import { hasImports, findAndRemoveImports, getDecoratedNavPageAndSlug, parseFron
|
|
|
2
2
|
import { promises as _promises } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { preparseMdxTree } from '../../../createPage/preparseMdx/index.js';
|
|
5
|
+
import { preserveAutoGeneratedMetadata } from '../preserveAutoGeneratedMetadata.js';
|
|
5
6
|
const { readFile } = _promises;
|
|
6
7
|
export const readPageContents = async ({ contentDirectoryPath, openApiFiles, asyncApiFiles, contentFilenames, pagesAcc, }) => {
|
|
7
8
|
const filesWithImports = [];
|
|
@@ -27,7 +28,7 @@ export const readPageContents = async ({ contentDirectoryPath, openApiFiles, asy
|
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
30
|
const { slug, pageMetadata } = getDecoratedNavPageAndSlug(filename, contentStr, openApiFiles, asyncApiFiles);
|
|
30
|
-
|
|
31
|
+
preserveAutoGeneratedMetadata(contentStr, slug, pageMetadata, pagesAcc);
|
|
31
32
|
return { targetPath, sourcePath, tree, metadata: pageMetadata };
|
|
32
33
|
}
|
|
33
34
|
catch (error) {
|
|
@@ -2,6 +2,7 @@ import { resolveAllImports, hasImports, findAndRemoveImports, getDecoratedNavPag
|
|
|
2
2
|
import { outputFile } from 'fs-extra';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { addWarning } from '../warnings.js';
|
|
5
|
+
import { preserveAutoGeneratedMetadata } from './preserveAutoGeneratedMetadata.js';
|
|
5
6
|
export const resolveImportsAndWriteFiles = async ({ openApiFiles, asyncApiFiles, pagesAcc, snippetsV2, filesWithImports, }) => {
|
|
6
7
|
const snippetsWithResolvedImports = await resolveImportsInSnippets(snippetsV2);
|
|
7
8
|
const writeSnippetsWithImportsPromises = await writeSnippets(snippetsWithResolvedImports);
|
|
@@ -57,7 +58,7 @@ const resolveImportsInPages = async ({ openApiFiles, asyncApiFiles, snippetsWith
|
|
|
57
58
|
});
|
|
58
59
|
const contentStr = stringifyTree(tree);
|
|
59
60
|
const { slug, pageMetadata } = getDecoratedNavPageAndSlug(fileWithImports.filename, contentStr, openApiFiles, asyncApiFiles);
|
|
60
|
-
|
|
61
|
+
preserveAutoGeneratedMetadata(contentStr, slug, pageMetadata, pagesAcc);
|
|
61
62
|
const targetPath = join('src', '_props', fileWithImports.filename);
|
|
62
63
|
return {
|
|
63
64
|
targetPath,
|