@mintlify/common 1.0.348 → 1.0.349
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.
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
|
-
export declare const getImageUri: (imagePath: string, subdomain: string, filePath: string, basePath
|
|
2
|
+
export declare const getImageUri: (imagePath: string, subdomain: string, filePath: string, basePath: string | undefined, opts?: {
|
|
3
|
+
bucketName?: string;
|
|
4
|
+
region?: string;
|
|
5
|
+
}) => string;
|
|
3
6
|
export declare const remarkReplaceAllImages: (subdomain: string, filePath: string, basePath?: string) => (tree: Root) => Root;
|
|
@@ -3,14 +3,14 @@ import path from 'path';
|
|
|
3
3
|
import { visit } from 'unist-util-visit';
|
|
4
4
|
import { removeBasePath } from '../../../fs/removeBasePath.js';
|
|
5
5
|
import { getS3URI } from '../../../services/aws.js';
|
|
6
|
-
export const getImageUri = (imagePath, subdomain, filePath, basePath) => {
|
|
6
|
+
export const getImageUri = (imagePath, subdomain, filePath, basePath, opts = {}) => {
|
|
7
7
|
if (imagePath.startsWith('/')) {
|
|
8
8
|
const path = removeBasePath(imagePath, basePath);
|
|
9
|
-
return getS3URI(subdomain, path);
|
|
9
|
+
return getS3URI(subdomain, path, opts);
|
|
10
10
|
}
|
|
11
11
|
const beforeFilePath = path.join(filePath, '../');
|
|
12
12
|
const relativePath = removeBasePath(path.join(beforeFilePath, imagePath), basePath);
|
|
13
|
-
return getS3URI(subdomain, relativePath);
|
|
13
|
+
return getS3URI(subdomain, relativePath, opts);
|
|
14
14
|
};
|
|
15
15
|
export const remarkReplaceAllImages = (subdomain, filePath, basePath) => {
|
|
16
16
|
return (tree) => {
|
package/dist/services/aws.d.ts
CHANGED
package/dist/services/aws.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
export const getS3URI = (subdomain, resourcePath) => {
|
|
2
|
+
export const getS3URI = (subdomain, resourcePath, opts = {}) => {
|
|
3
3
|
if (resourcePath.startsWith('http://') || resourcePath.startsWith('https://'))
|
|
4
4
|
return resourcePath;
|
|
5
5
|
const subpath = path.join(subdomain, resourcePath);
|
|
6
|
-
const baseUrl = new URL('
|
|
6
|
+
const baseUrl = new URL(`https://${opts.bucketName ? opts.bucketName : 'mintlify'}.s3.${opts.region ? opts.region : 'us-west-1'}.amazonaws.com`);
|
|
7
7
|
return new URL(subpath, baseUrl).toString();
|
|
8
8
|
};
|