@mintlify/common 1.0.641 → 1.0.642
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/getFileCategory.d.ts +1 -1
- package/dist/getFileCategory.js +5 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/mdx/snippets/resolveAllImports.d.ts +0 -1
- package/dist/mdx/snippets/resolveAllImports.js +3 -3
- package/dist/mdx/snippets/resolveSnippetImportPath.d.ts +2 -3
- package/dist/mdx/snippets/resolveSnippetImportPath.js +6 -5
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/dist/snippetPatterns.d.ts +0 -13
- package/dist/snippetPatterns.js +0 -18
|
@@ -17,4 +17,4 @@ export declare function isGatedFormat(params: {
|
|
|
17
17
|
filePath?: undefined;
|
|
18
18
|
ext: string;
|
|
19
19
|
}): boolean;
|
|
20
|
-
export declare const getFileCategory: (filePath: string
|
|
20
|
+
export declare const getFileCategory: (filePath: string) => PotentialFileCategory;
|
package/dist/getFileCategory.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { parse } from 'path';
|
|
2
2
|
import { SNIPPET_EXTENSIONS } from './mdx/snippets/constants.js';
|
|
3
|
-
import { isSnippetPath } from './snippetPatterns.js';
|
|
4
3
|
const excludedMdFiles = ['readme', 'license', 'contributing', 'contribute'];
|
|
5
4
|
export const generatedStaticFiles = [
|
|
6
5
|
'llms.txt',
|
|
@@ -74,7 +73,7 @@ export function isGatedFormat({ filePath, ext }) {
|
|
|
74
73
|
ext = ext.startsWith('.') ? ext : `.${ext}`;
|
|
75
74
|
return gatedStaticAssetExtensions.includes(ext.toLowerCase());
|
|
76
75
|
}
|
|
77
|
-
export const getFileCategory = (filePath
|
|
76
|
+
export const getFileCategory = (filePath) => {
|
|
78
77
|
filePath = filePath.toLowerCase();
|
|
79
78
|
const parsed = parse(filePath);
|
|
80
79
|
if (parsed.base === 'mint.json') {
|
|
@@ -91,16 +90,16 @@ export const getFileCategory = (filePath, snippetPatterns) => {
|
|
|
91
90
|
if (generatedStaticFiles.includes(parsed.base)) {
|
|
92
91
|
return 'generatedStaticFile';
|
|
93
92
|
}
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
if ((filePath.startsWith('_snippets/') || filePath.startsWith('snippets/')) &&
|
|
94
|
+
(SNIPPET_EXTENSIONS.some((ext) => extension === ext) || extension === '.md')) {
|
|
96
95
|
if (filePath.startsWith('_snippets/')) {
|
|
97
96
|
return 'snippet';
|
|
98
97
|
}
|
|
99
|
-
if (
|
|
98
|
+
else if (filePath.startsWith('snippets/')) {
|
|
100
99
|
return 'snippet-v2';
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
|
-
if (extension === '.mdx') {
|
|
102
|
+
else if (extension === '.mdx') {
|
|
104
103
|
return 'page';
|
|
105
104
|
}
|
|
106
105
|
else if (extension === '.md') {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -11,13 +11,13 @@ import { getExportMapFromTree } from './getExportMap.js';
|
|
|
11
11
|
import { resolveImport } from './resolveImport/index.js';
|
|
12
12
|
import { resolveSnippetImportPath } from './resolveSnippetImportPath.js';
|
|
13
13
|
export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const { snippets, fileWithImports
|
|
14
|
+
const { snippets, fileWithImports } = params;
|
|
15
15
|
let ast = fileWithImports.tree;
|
|
16
16
|
const exportMap = getExportMapFromTree(ast);
|
|
17
17
|
for (const source of Object.keys(fileWithImports.importMap)) {
|
|
18
|
-
const resolvedPath = resolveSnippetImportPath(source, fileWithImports.filename
|
|
18
|
+
const resolvedPath = resolveSnippetImportPath(source, fileWithImports.filename);
|
|
19
19
|
if (resolvedPath == null) {
|
|
20
|
-
console.log(`Invalid import path ${source} in ${fileWithImports.filename}. Import must resolve to a
|
|
20
|
+
console.log(`Invalid import path ${source} in ${fileWithImports.filename}. Import must resolve to a file in /snippets/.`);
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
23
|
const importedSnippet = snippets.find((snippet) => snippet.filename === resolvedPath);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resolves an import path to an absolute path with leading slash.
|
|
3
|
-
* Only allows imports that resolve to files in
|
|
3
|
+
* Only allows imports that resolve to files in /snippets/.
|
|
4
4
|
*
|
|
5
5
|
* @param source The import source path (e.g., '/snippets/foo.mdx' or '../snippets/bar.mdx')
|
|
6
6
|
* @param importingFilePath The path of the file containing the import
|
|
7
|
-
* @param snippetPatterns Optional custom snippet patterns from docs.json config
|
|
8
7
|
* @returns The resolved absolute path with leading slash, or null if invalid or not in snippets folder
|
|
9
8
|
*/
|
|
10
|
-
export declare const resolveSnippetImportPath: (source: string, importingFilePath: string
|
|
9
|
+
export declare const resolveSnippetImportPath: (source: string, importingFilePath: string) => string | null;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { posix } from 'path';
|
|
2
|
-
import { isSnippetPath } from '../../snippetPatterns.js';
|
|
3
2
|
const isRelativeImport = (source) => {
|
|
4
3
|
return source.startsWith('./') || source.startsWith('../');
|
|
5
4
|
};
|
|
5
|
+
const isInSnippetsFolder = (resolvedPath) => {
|
|
6
|
+
return resolvedPath.startsWith('/snippets/');
|
|
7
|
+
};
|
|
6
8
|
/**
|
|
7
9
|
* Resolves an import path to an absolute path with leading slash.
|
|
8
|
-
* Only allows imports that resolve to files in
|
|
10
|
+
* Only allows imports that resolve to files in /snippets/.
|
|
9
11
|
*
|
|
10
12
|
* @param source The import source path (e.g., '/snippets/foo.mdx' or '../snippets/bar.mdx')
|
|
11
13
|
* @param importingFilePath The path of the file containing the import
|
|
12
|
-
* @param snippetPatterns Optional custom snippet patterns from docs.json config
|
|
13
14
|
* @returns The resolved absolute path with leading slash, or null if invalid or not in snippets folder
|
|
14
15
|
*/
|
|
15
|
-
export const resolveSnippetImportPath = (source, importingFilePath
|
|
16
|
+
export const resolveSnippetImportPath = (source, importingFilePath) => {
|
|
16
17
|
let resolvedPath;
|
|
17
18
|
if (source.startsWith('/')) {
|
|
18
19
|
resolvedPath = posix.normalize(source);
|
|
@@ -24,7 +25,7 @@ export const resolveSnippetImportPath = (source, importingFilePath, snippetPatte
|
|
|
24
25
|
else {
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
27
|
-
if (!
|
|
28
|
+
if (!isInSnippetsFolder(resolvedPath)) {
|
|
28
29
|
return null;
|
|
29
30
|
}
|
|
30
31
|
return resolvedPath;
|