@mintlify/common 1.0.902 → 1.0.904
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/getMDXOptions.d.ts +2 -1
- package/dist/mdx/getMDXOptions.js +2 -2
- package/dist/mdx/plugins/remark/remarkMdxRemoveUnknownJsx/index.d.ts +3 -1
- package/dist/mdx/plugins/remark/remarkMdxRemoveUnknownJsx/index.js +3 -2
- package/dist/mdx/server-only/getMdx.d.ts +2 -1
- package/dist/mdx/server-only/getMdx.js +3 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -12,10 +12,11 @@ type MDXOptionsData = {
|
|
|
12
12
|
tailwindSelectors?: string[];
|
|
13
13
|
path?: string;
|
|
14
14
|
};
|
|
15
|
-
export declare const getMDXOptions: ({ data, remarkPlugins, rehypePlugins, mdxExtracts, }: {
|
|
15
|
+
export declare const getMDXOptions: ({ data, remarkPlugins, rehypePlugins, mdxExtracts, allowedComponents, }: {
|
|
16
16
|
data: MDXOptionsData;
|
|
17
17
|
remarkPlugins?: PluggableList;
|
|
18
18
|
rehypePlugins?: PluggableList;
|
|
19
19
|
mdxExtracts?: MdxExtracts;
|
|
20
|
+
allowedComponents?: string[];
|
|
20
21
|
}) => SerializeOptions["mdxOptions"];
|
|
21
22
|
export {};
|
|
@@ -10,7 +10,7 @@ const rehypeExtractors = (mdxExtracts, data) => {
|
|
|
10
10
|
[rehypeMdxExtractEndpoint, data.pageMetadata, data.config, mdxExtracts],
|
|
11
11
|
];
|
|
12
12
|
};
|
|
13
|
-
export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], mdxExtracts, }) => {
|
|
13
|
+
export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], mdxExtracts, allowedComponents = [], }) => {
|
|
14
14
|
return {
|
|
15
15
|
remarkPlugins: [
|
|
16
16
|
[remarkMdxInjectSnippets, data.snippetTreeMap],
|
|
@@ -28,7 +28,7 @@ export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], md
|
|
|
28
28
|
remarkMermaid,
|
|
29
29
|
remarkVideo,
|
|
30
30
|
...remarkPlugins,
|
|
31
|
-
remarkMdxRemoveUnknownJsx,
|
|
31
|
+
[remarkMdxRemoveUnknownJsx, { allowlist: allowedComponents }],
|
|
32
32
|
],
|
|
33
33
|
rehypePlugins: [
|
|
34
34
|
rehypeCodeBlocks,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
|
-
export declare const remarkMdxRemoveUnknownJsx: (
|
|
2
|
+
export declare const remarkMdxRemoveUnknownJsx: ({ allowlist }?: {
|
|
3
|
+
allowlist?: string[];
|
|
4
|
+
}) => (tree: Root) => Root | import("mdast").Link | import("mdast").Delete | import("mdast").Code | import("mdast").Blockquote | import("mdast").Break | import("mdast").Definition | import("mdast").Emphasis | import("mdast").FootnoteDefinition | import("mdast").FootnoteReference | import("mdast").Heading | import("mdast").Html | import("mdast").Image | import("mdast").ImageReference | import("mdast").InlineCode | import("mdast").LinkReference | import("mdast").List | import("mdast").ListItem | import("mdast").Paragraph | import("mdast").Strong | import("mdast").Table | import("mdast").TableCell | import("mdast").TableRow | import("mdast").Text | import("mdast").ThematicBreak | import("mdast").Yaml | import("mdast-util-math").InlineMath | import("mdast-util-math").Math | import("mdast-util-mdx-expression").MdxTextExpression | import("mdast-util-mdx-expression").MdxFlowExpression | import("mdast-util-mdx").MdxJsxFlowElement | import("mdast-util-mdx").MdxJsxTextElement | import("mdast-util-mdxjs-esm").MdxjsEsm;
|
|
@@ -2,14 +2,15 @@ import { map } from 'unist-util-map';
|
|
|
2
2
|
import { allowedComponents } from '../../../index.js';
|
|
3
3
|
import { findExportedNodes, isMdxJsxFlowElementHast } from '../../../lib/index.js';
|
|
4
4
|
import { createCommentNode } from './createCommentNode.js';
|
|
5
|
-
export const remarkMdxRemoveUnknownJsx = () => (tree) => {
|
|
5
|
+
export const remarkMdxRemoveUnknownJsx = ({ allowlist } = {}) => (tree) => {
|
|
6
6
|
const exportedComponentNames = findExportedNodes(tree, 'ArrowFunctionExpression');
|
|
7
7
|
return map(tree, (node) => {
|
|
8
8
|
if (isMdxJsxFlowElementHast(node)) {
|
|
9
9
|
if (node.name &&
|
|
10
10
|
Array.isArray(allowedComponents) &&
|
|
11
11
|
!allowedComponents.includes(node.name) &&
|
|
12
|
-
!exportedComponentNames.includes(node.name)
|
|
12
|
+
!exportedComponentNames.includes(node.name) &&
|
|
13
|
+
!(allowlist === null || allowlist === void 0 ? void 0 : allowlist.includes(node.name))) {
|
|
13
14
|
return createCommentNode(node.name);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -12,7 +12,7 @@ export type GetMdxType = {
|
|
|
12
12
|
panelMdxSource?: SerializeSuccess;
|
|
13
13
|
panelMdxSourceWithNoJs?: SerializeSuccess;
|
|
14
14
|
};
|
|
15
|
-
export declare function getMdx({ path, content, metadata, snippets, subdomain, codeStyling, config, tailwindSelectors, pageType, trace, customLanguages, variables, rehypePlugins, remarkPlugins, }: {
|
|
15
|
+
export declare function getMdx({ path, content, metadata, snippets, subdomain, codeStyling, config, tailwindSelectors, pageType, trace, customLanguages, variables, rehypePlugins, remarkPlugins, allowedComponents, }: {
|
|
16
16
|
path: string;
|
|
17
17
|
content: string;
|
|
18
18
|
metadata: PageMetaTags;
|
|
@@ -27,5 +27,6 @@ export declare function getMdx({ path, content, metadata, snippets, subdomain, c
|
|
|
27
27
|
variables?: Record<string, string>;
|
|
28
28
|
rehypePlugins?: PluggableList;
|
|
29
29
|
remarkPlugins?: PluggableList;
|
|
30
|
+
allowedComponents?: string[];
|
|
30
31
|
}): Promise<GetMdxType>;
|
|
31
32
|
export { createSnippetTreeMap, type Snippet };
|
|
@@ -15,7 +15,7 @@ import { preprocessCustomHeadingIds } from '../preprocessCustomHeadingIds.js';
|
|
|
15
15
|
import { replaceVariables } from '../replaceVariables.js';
|
|
16
16
|
import { createSnippetTreeMap } from './getMdx/snippets.js';
|
|
17
17
|
export function getMdx(_a) {
|
|
18
|
-
return __awaiter(this, arguments, void 0, function* ({ path, content, metadata, snippets, subdomain, codeStyling, config, tailwindSelectors = undefined, pageType = 'default', trace = undefined, customLanguages = [], variables = undefined, rehypePlugins = [], remarkPlugins = [], }) {
|
|
18
|
+
return __awaiter(this, arguments, void 0, function* ({ path, content, metadata, snippets, subdomain, codeStyling, config, tailwindSelectors = undefined, pageType = 'default', trace = undefined, customLanguages = [], variables = undefined, rehypePlugins = [], remarkPlugins = [], allowedComponents = [], }) {
|
|
19
19
|
const traceFn = trace !== null && trace !== void 0 ? trace : ((_name, fn) => fn());
|
|
20
20
|
const processedContent = preprocessCustomHeadingIds(replaceVariables(content, variables));
|
|
21
21
|
const processedSnippets = snippets.map((snippet) => (Object.assign(Object.assign({}, snippet), { content: preprocessCustomHeadingIds(replaceVariables(snippet.content, variables)) })));
|
|
@@ -41,11 +41,13 @@ export function getMdx(_a) {
|
|
|
41
41
|
remarkPlugins: plugins,
|
|
42
42
|
rehypePlugins,
|
|
43
43
|
mdxExtracts,
|
|
44
|
+
allowedComponents,
|
|
44
45
|
});
|
|
45
46
|
const mdxOptionsNoJs = getMDXOptions({
|
|
46
47
|
data: mdxOptionsData,
|
|
47
48
|
remarkPlugins: [remarkMdxRemoveJs, ...plugins],
|
|
48
49
|
rehypePlugins,
|
|
50
|
+
allowedComponents,
|
|
49
51
|
});
|
|
50
52
|
const scope = {
|
|
51
53
|
codeStyling,
|