@mintlify/common 1.0.1049 → 1.0.1050
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/live-preview.d.ts
CHANGED
|
@@ -7,3 +7,7 @@ export declare const LIVE_PREVIEW_COMPILED_CONTENT_UPDATE_MESSAGE_TYPE = "livePr
|
|
|
7
7
|
export declare const LIVE_PREVIEW_NAVIGATION_UPDATE_MESSAGE_TYPE = "livePreviewNavigationUpdate";
|
|
8
8
|
export declare const LIVE_PREVIEW_REQUEST_CONTENT_MESSAGE_TYPE = "livePreviewRequestContent";
|
|
9
9
|
export declare const LIVE_PREVIEW_CONTENT_UNAVAILABLE_MESSAGE_TYPE = "livePreviewContentUnavailable";
|
|
10
|
+
export declare const LIVE_PREVIEW_CSS_SNAPSHOT_MESSAGE_TYPE = "livePreviewCssSnapshot";
|
|
11
|
+
export declare function normalizeLivePreviewPath(path: string): string;
|
|
12
|
+
export declare function normalizeLivePreviewBasePath(basePath: string | undefined): string;
|
|
13
|
+
export declare function stripLivePreviewBasePath(path: string, basePath: string | undefined): string;
|
package/dist/live-preview.js
CHANGED
|
@@ -7,3 +7,27 @@ export const LIVE_PREVIEW_COMPILED_CONTENT_UPDATE_MESSAGE_TYPE = 'livePreviewCom
|
|
|
7
7
|
export const LIVE_PREVIEW_NAVIGATION_UPDATE_MESSAGE_TYPE = 'livePreviewNavigationUpdate';
|
|
8
8
|
export const LIVE_PREVIEW_REQUEST_CONTENT_MESSAGE_TYPE = 'livePreviewRequestContent';
|
|
9
9
|
export const LIVE_PREVIEW_CONTENT_UNAVAILABLE_MESSAGE_TYPE = 'livePreviewContentUnavailable';
|
|
10
|
+
export const LIVE_PREVIEW_CSS_SNAPSHOT_MESSAGE_TYPE = 'livePreviewCssSnapshot';
|
|
11
|
+
function normalizeLivePreviewHref(path) {
|
|
12
|
+
return path.replace(/^\/+|\/+$/g, '').replace(/\.mdx?$/, '');
|
|
13
|
+
}
|
|
14
|
+
export function normalizeLivePreviewPath(path) {
|
|
15
|
+
const href = normalizeLivePreviewHref(path);
|
|
16
|
+
return href ? `/${href}` : '/';
|
|
17
|
+
}
|
|
18
|
+
export function normalizeLivePreviewBasePath(basePath) {
|
|
19
|
+
var _a;
|
|
20
|
+
const normalized = (_a = basePath === null || basePath === void 0 ? void 0 : basePath.replace(/^\/+|\/+$/g, '')) !== null && _a !== void 0 ? _a : '';
|
|
21
|
+
return normalized ? `/${normalized}` : '';
|
|
22
|
+
}
|
|
23
|
+
export function stripLivePreviewBasePath(path, basePath) {
|
|
24
|
+
const normalizedPath = normalizeLivePreviewPath(path);
|
|
25
|
+
const normalizedBasePath = normalizeLivePreviewBasePath(basePath);
|
|
26
|
+
if (!normalizedBasePath)
|
|
27
|
+
return normalizedPath;
|
|
28
|
+
if (normalizedPath === normalizedBasePath)
|
|
29
|
+
return '/';
|
|
30
|
+
return normalizedPath.startsWith(`${normalizedBasePath}/`)
|
|
31
|
+
? normalizedPath.slice(normalizedBasePath.length)
|
|
32
|
+
: normalizedPath;
|
|
33
|
+
}
|