@mintlify/common 1.0.475 → 1.0.477
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/mdx/getS3ImageUri.d.ts +4 -0
- package/dist/mdx/getS3ImageUri.js +12 -0
- package/dist/mdx/index.d.ts +1 -0
- package/dist/mdx/index.js +1 -0
- package/dist/mdx/plugins/remark/index.d.ts +0 -1
- package/dist/mdx/plugins/remark/index.js +0 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -6
- package/dist/mdx/plugins/remark/remarkReplaceAllImages.d.ts +0 -6
- package/dist/mdx/plugins/remark/remarkReplaceAllImages.js +0 -48
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.477",
|
|
4
4
|
"description": "Commonly shared code within Mintlify",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"./server-mdx": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"types": "./dist/mdx/server-only/index.d.ts",
|
|
14
|
+
"default": "./dist/mdx/server-only/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./services/aws": {
|
|
17
|
+
"types": "./dist/services/aws.d.ts",
|
|
18
|
+
"default": "./dist/services/aws.js"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"sideEffects": false,
|
|
@@ -96,5 +100,5 @@
|
|
|
96
100
|
"typescript": "^5.5.3",
|
|
97
101
|
"vitest": "^2.0.4"
|
|
98
102
|
},
|
|
99
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "f792049dbe8491bd6350545e6f5fcbe3fc1f96e9"
|
|
100
104
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'mdast';
|
|
2
|
-
export declare const getImageUri: (imagePath: string, subdomain: string, filePath: string, basePath: string | undefined, opts?: {
|
|
3
|
-
bucketName?: string;
|
|
4
|
-
region?: string;
|
|
5
|
-
}) => string;
|
|
6
|
-
export declare const remarkReplaceAllImages: (subdomain: string, filePath: string, basePath?: string) => (tree: Root) => Root;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { visit } from 'unist-util-visit';
|
|
3
|
-
import { removeBasePath } from '../../../fs/removeBasePath.js';
|
|
4
|
-
import { isAbsoluteUrl } from '../../../isAbsoluteUrl.js';
|
|
5
|
-
import { getS3URI } from '../../../services/aws.js';
|
|
6
|
-
export const getImageUri = (imagePath, subdomain, filePath, basePath, opts = {}) => {
|
|
7
|
-
if (imagePath.startsWith('/')) {
|
|
8
|
-
const path = removeBasePath(imagePath, basePath);
|
|
9
|
-
return getS3URI(subdomain, path, opts);
|
|
10
|
-
}
|
|
11
|
-
const beforeFilePath = path.join(filePath, '../');
|
|
12
|
-
const relativePath = removeBasePath(path.join(beforeFilePath, imagePath), basePath);
|
|
13
|
-
return getS3URI(subdomain, relativePath, opts);
|
|
14
|
-
};
|
|
15
|
-
export const remarkReplaceAllImages = (subdomain, filePath, basePath) => {
|
|
16
|
-
return (tree) => {
|
|
17
|
-
visit(tree, 'mdxJsxFlowElement', (node) => {
|
|
18
|
-
if (node.name === 'img' || node.name === 'source' || node.name === 'video') {
|
|
19
|
-
const srcAttr = node.attributes.find(isSrcAttr);
|
|
20
|
-
if (!srcAttr)
|
|
21
|
-
return;
|
|
22
|
-
const nodeUrl = srcAttr.value;
|
|
23
|
-
if (typeof nodeUrl !== 'string')
|
|
24
|
-
return;
|
|
25
|
-
if (
|
|
26
|
-
// <img/> component
|
|
27
|
-
!isAbsoluteUrl(nodeUrl) &&
|
|
28
|
-
!isDataString(nodeUrl)) {
|
|
29
|
-
srcAttr.value = getImageUri(nodeUrl, subdomain, filePath, basePath);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
visit(tree, 'image', (node) => {
|
|
34
|
-
if (
|
|
35
|
-
// ![]() format
|
|
36
|
-
node.url &&
|
|
37
|
-
!isAbsoluteUrl(node.url) &&
|
|
38
|
-
!isDataString(node.url)) {
|
|
39
|
-
node.url = getImageUri(node.url, subdomain, filePath, basePath);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return tree;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
function isSrcAttr(attr) {
|
|
46
|
-
return attr.type === 'mdxJsxAttribute' && attr.name === 'src';
|
|
47
|
-
}
|
|
48
|
-
const isDataString = (str) => str.startsWith('data:');
|