@mintlify/common 1.0.1294 → 1.0.1296

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.
@@ -9,3 +9,8 @@ export type DisplayDomainDeployment = {
9
9
  };
10
10
  };
11
11
  export declare function getDisplayDomain(deployment: DisplayDomainDeployment, isDev?: boolean, appendBasePath?: boolean): string;
12
+ export declare function getMarkdownLinkDomain(deployment: DisplayDomainDeployment & {
13
+ preview?: unknown;
14
+ }, requestedHost?: string, { selfHosted }?: {
15
+ selfHosted?: boolean;
16
+ }): string | undefined;
@@ -39,3 +39,18 @@ export function getDisplayDomain(deployment, isDev = false, appendBasePath = tru
39
39
  const displayDomainBase = (_d = (_c = deployment.customDomains) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : `${subdomain}.${getSubdomain(deployment)}`;
40
40
  return displayDomainBase + (appendBasePath ? deployment.basePath : '');
41
41
  }
42
+ export function getMarkdownLinkDomain(deployment, requestedHost, { selfHosted = false } = {}) {
43
+ var _a, _b;
44
+ if (deployment.preview || selfHosted)
45
+ return undefined;
46
+ const host = requestedHost === null || requestedHost === void 0 ? void 0 : requestedHost.toLowerCase();
47
+ const requestedCustomDomain = host === undefined
48
+ ? undefined
49
+ : (_a = deployment.customDomains) === null || _a === void 0 ? void 0 : _a.find((domain) => domain.toLowerCase() === host);
50
+ if (requestedCustomDomain !== undefined) {
51
+ return requestedCustomDomain + deployment.basePath;
52
+ }
53
+ if (!((_b = deployment.customDomains) === null || _b === void 0 ? void 0 : _b.length) && deployment.basePath)
54
+ return undefined;
55
+ return getDisplayDomain(deployment);
56
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ImportDeclaration, ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, Program } from 'estree-jsx';
2
2
  import { MdxFlowExpression, MdxjsEsm, MdxJsxAttribute, MdxJsxExpressionAttribute, MdxTextExpression } from 'mdast-util-mdx';
3
- import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
3
+ import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
4
4
  import type { Node } from 'unist';
5
5
  import type { MdxNodeBodyChildType } from '../types/mdx/index.js';
6
6
  export declare const isMdxJsEsm: (node: Node) => node is MdxjsEsm;
@@ -14,6 +14,7 @@ export declare const isImportDeclaration: (bodyChild: MdxNodeBodyChildType) => b
14
14
  export declare const isExport: (type: string) => boolean;
15
15
  export declare const isExportNode: (bodyChild: MdxNodeBodyChildType) => bodyChild is ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration;
16
16
  export declare const isMdxJsxFlowElement: (node: Node) => node is MdxJsxFlowElement;
17
+ export declare const isMdxJsxElement: (node: unknown) => node is MdxJsxFlowElement | MdxJsxTextElement;
17
18
  export declare const isMdxJsxFragment: (node: Node) => node is MdxJsxFlowElement;
18
19
  export declare const createUniqueVariableName: (variableName: string, id: number) => string;
19
20
  export declare const getObjectExpressionStringProperty: (key: string, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute | undefined) => string | undefined;
package/dist/mdx/utils.js CHANGED
@@ -12,6 +12,9 @@ export const isExport = (type) => [
12
12
  ].includes(type);
13
13
  export const isExportNode = (bodyChild) => isExport(bodyChild.type);
14
14
  export const isMdxJsxFlowElement = (node) => node.type === 'mdxJsxFlowElement';
15
+ export const isMdxJsxElement = (node) => node instanceof Object &&
16
+ 'type' in node &&
17
+ (node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement');
15
18
  export const isMdxJsxFragment = (node) => isMdxJsxFlowElement(node) && node.name == null;
16
19
  export const createUniqueVariableName = (variableName, id) => `${variableName}_${id}`;
17
20
  export const getObjectExpressionStringProperty = (key, attribute) => {