@mintlify/common 1.0.641 → 1.0.643

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.
@@ -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, snippetPatterns?: string[]) => PotentialFileCategory;
20
+ export declare const getFileCategory: (filePath: string) => PotentialFileCategory;
@@ -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, snippetPatterns) => {
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
- const hasSnippetExtension = SNIPPET_EXTENSIONS.some((ext) => extension === ext) || extension === '.md';
95
- if (hasSnippetExtension) {
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 (isSnippetPath(filePath, snippetPatterns)) {
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
@@ -27,4 +27,3 @@ export * from './truncateAtWordBoundary.js';
27
27
  export * from './api-reference/parseApiTargetFromMetadata.js';
28
28
  export * from './mintIgnore.js';
29
29
  export * from './getDisplayDomain.js';
30
- export * from './snippetPatterns.js';
package/dist/index.js CHANGED
@@ -27,4 +27,3 @@ export * from './truncateAtWordBoundary.js';
27
27
  export * from './api-reference/parseApiTargetFromMetadata.js';
28
28
  export * from './mintIgnore.js';
29
29
  export * from './getDisplayDomain.js';
30
- export * from './snippetPatterns.js';
@@ -3,5 +3,4 @@ import type { FileType, FileWithImports } from '../../types/mdx/index.js';
3
3
  export declare const resolveAllImports: (params: {
4
4
  snippets: FileType[];
5
5
  fileWithImports: FileWithImports;
6
- snippetPatterns?: string[];
7
6
  }) => Promise<Root>;
@@ -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, snippetPatterns } = params;
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, snippetPatterns);
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 valid snippet location.`);
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 valid snippet locations.
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, snippetPatterns?: string[]) => string | null;
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 valid snippet locations.
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, snippetPatterns) => {
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 (!isSnippetPath(resolvedPath, snippetPatterns)) {
28
+ if (!isInSnippetsFolder(resolvedPath)) {
28
29
  return null;
29
30
  }
30
31
  return resolvedPath;