@mintlify/common 1.0.1020 → 1.0.1022
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.js +2 -1
- package/dist/mdx/plugins/remark/index.d.ts +2 -0
- package/dist/mdx/plugins/remark/index.js +2 -0
- package/dist/mdx/plugins/remark/remarkExtractMultiView.js +21 -6
- package/dist/mdx/plugins/remark/remarkMdxRemoveUnknownJsx/index.d.ts +1 -1
- package/dist/mdx/plugins/remark/remarkPrompt.js +6 -4
- package/dist/mdx/plugins/remark/remarkUnwrapInlineJsx.d.ts +11 -0
- package/dist/mdx/plugins/remark/remarkUnwrapInlineJsx.js +26 -0
- package/dist/mdx/plugins/remark/remarkValidateVisibility.d.ts +2 -0
- package/dist/mdx/plugins/remark/remarkValidateVisibility.js +15 -0
- package/dist/mdx/plugins/remark/remarkVisibilityForMarkdown.d.ts +19 -0
- package/dist/mdx/plugins/remark/remarkVisibilityForMarkdown.js +59 -17
- package/dist/mdx/server-only/getMdx.js +7 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rehypeCodeBlocks, rehypeDynamicTailwindCss, rehypeKeyboardSymbols, rehypeListItemText, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeTable, rehypeUnicodeIds, rehypeZoomImages, remarkExtractChangelogFilters, remarkExtractTableOfContents, remarkFileTree, remarkFrames, remarkComponentIds, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, remarkMdxExtractPanel, remarkResolveRelativeLinks, remarkVideo, remarkMdxClientComponentBoundaries, remarkExtractMultiView, remarkPrompt, remarkUnwrapJsxHeadings, } from './plugins/index.js';
|
|
1
|
+
import { rehypeCodeBlocks, rehypeDynamicTailwindCss, rehypeKeyboardSymbols, rehypeListItemText, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeTable, rehypeUnicodeIds, rehypeZoomImages, remarkExtractChangelogFilters, remarkExtractTableOfContents, remarkFileTree, remarkFrames, remarkComponentIds, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, remarkMdxExtractPanel, remarkResolveRelativeLinks, remarkVideo, remarkMdxClientComponentBoundaries, remarkExtractMultiView, remarkPrompt, remarkUnwrapInlineJsx, remarkUnwrapJsxHeadings, } from './plugins/index.js';
|
|
2
2
|
import { remarkMdxRemoveUnknownJsx } from './plugins/remark/remarkMdxRemoveUnknownJsx/index.js';
|
|
3
3
|
import { remarkMermaid } from './plugins/remark/remarkMermaid.js';
|
|
4
4
|
// avoid running extractors unnecessarily
|
|
@@ -18,6 +18,7 @@ export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], md
|
|
|
18
18
|
remarkPrompt,
|
|
19
19
|
[remarkComponentIds, data.pageMetadata],
|
|
20
20
|
remarkUnwrapJsxHeadings,
|
|
21
|
+
remarkUnwrapInlineJsx,
|
|
21
22
|
[remarkExtractTableOfContents, mdxExtracts, data.pageMetadata], // modifies tree so cannot be excluded
|
|
22
23
|
[remarkExtractChangelogFilters, mdxExtracts],
|
|
23
24
|
[remarkMdxExtractPanel, mdxExtracts],
|
|
@@ -15,10 +15,12 @@ export * from './remarkSplitTabs.js';
|
|
|
15
15
|
export * from './remarkComponentIds.js';
|
|
16
16
|
export * from './remarkMdxExtractPanel.js';
|
|
17
17
|
export * from './remarkValidateSteps.js';
|
|
18
|
+
export * from './remarkValidateVisibility.js';
|
|
18
19
|
export * from './remarkValidateTabs.js';
|
|
19
20
|
export * from './remarkVideo.js';
|
|
20
21
|
export * from './remarkExtractMultiView.js';
|
|
21
22
|
export * from './remarkPrompt.js';
|
|
22
23
|
export * from './remarkResolveRelativeLinks.js';
|
|
24
|
+
export * from './remarkUnwrapInlineJsx.js';
|
|
23
25
|
export * from './remarkUnwrapJsxHeadings.js';
|
|
24
26
|
export * from './remarkVisibilityForMarkdown.js';
|
|
@@ -15,10 +15,12 @@ export * from './remarkSplitTabs.js';
|
|
|
15
15
|
export * from './remarkComponentIds.js';
|
|
16
16
|
export * from './remarkMdxExtractPanel.js';
|
|
17
17
|
export * from './remarkValidateSteps.js';
|
|
18
|
+
export * from './remarkValidateVisibility.js';
|
|
18
19
|
export * from './remarkValidateTabs.js';
|
|
19
20
|
export * from './remarkVideo.js';
|
|
20
21
|
export * from './remarkExtractMultiView.js';
|
|
21
22
|
export * from './remarkPrompt.js';
|
|
22
23
|
export * from './remarkResolveRelativeLinks.js';
|
|
24
|
+
export * from './remarkUnwrapInlineJsx.js';
|
|
23
25
|
export * from './remarkUnwrapJsxHeadings.js';
|
|
24
26
|
export * from './remarkVisibilityForMarkdown.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import remarkStringify from 'remark-stringify';
|
|
2
2
|
import { unified } from 'unified';
|
|
3
|
-
import { visit } from 'unist-util-visit';
|
|
3
|
+
import { SKIP, visit } from 'unist-util-visit';
|
|
4
4
|
import { coreRemarkMdxPlugins } from '../../remark.js';
|
|
5
5
|
export const remarkExtractMultiView = (mdxExtracts) => {
|
|
6
6
|
return (tree) => {
|
|
@@ -10,7 +10,10 @@ export const remarkExtractMultiView = (mdxExtracts) => {
|
|
|
10
10
|
if ('attributes' in sanitized && Array.isArray(sanitized.attributes)) {
|
|
11
11
|
sanitized.attributes = sanitized.attributes.map((attr) => {
|
|
12
12
|
if (attr.value != null && typeof attr.value !== 'string') {
|
|
13
|
-
|
|
13
|
+
const raw = 'value' in attr.value && typeof attr.value.value === 'string'
|
|
14
|
+
? attr.value.value
|
|
15
|
+
: String(attr.value);
|
|
16
|
+
return Object.assign(Object.assign({}, attr), { value: raw });
|
|
14
17
|
}
|
|
15
18
|
return attr;
|
|
16
19
|
});
|
|
@@ -40,7 +43,9 @@ export const remarkExtractMultiView = (mdxExtracts) => {
|
|
|
40
43
|
return attribute.value;
|
|
41
44
|
}
|
|
42
45
|
if (typeof attribute.value === 'object' && 'value' in attribute.value) {
|
|
43
|
-
|
|
46
|
+
const raw = String(attribute.value.value).trim();
|
|
47
|
+
const quoted = raw.match(/^(["'`])([\s\S]*)\1$/);
|
|
48
|
+
return quoted ? quoted[2] : raw;
|
|
44
49
|
}
|
|
45
50
|
return undefined;
|
|
46
51
|
};
|
|
@@ -59,7 +64,7 @@ export const remarkExtractMultiView = (mdxExtracts) => {
|
|
|
59
64
|
console.warn(`\n⚠️ Duplicate View title: "${title}"\n` +
|
|
60
65
|
` Use one View component per title per page. Duplicate Views are ignored.\n` +
|
|
61
66
|
` Learn more: https://www.mintlify.com/docs/components/view\n`);
|
|
62
|
-
return;
|
|
67
|
+
return SKIP;
|
|
63
68
|
}
|
|
64
69
|
// Extract the id attribute (set by remarkComponentIds or explicit) so the
|
|
65
70
|
// client can match URL hashes back to the correct view for shareable links.
|
|
@@ -79,10 +84,20 @@ export const remarkExtractMultiView = (mdxExtracts) => {
|
|
|
79
84
|
}
|
|
80
85
|
multiViews.push(viewItem);
|
|
81
86
|
}
|
|
87
|
+
else {
|
|
88
|
+
console.warn(`\n⚠️ View component is missing a title.\n` +
|
|
89
|
+
` Every View needs a non-empty string title; a View without one is never rendered.\n` +
|
|
90
|
+
` Learn more: https://www.mintlify.com/docs/components/view\n`);
|
|
91
|
+
}
|
|
82
92
|
}
|
|
83
93
|
});
|
|
84
|
-
if (mdxExtracts
|
|
85
|
-
|
|
94
|
+
if (mdxExtracts) {
|
|
95
|
+
if (multiViews.length) {
|
|
96
|
+
mdxExtracts.multiViewItems = multiViews;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
delete mdxExtracts.multiViewItems;
|
|
100
|
+
}
|
|
86
101
|
}
|
|
87
102
|
return tree;
|
|
88
103
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
2
|
export declare const remarkMdxRemoveUnknownJsx: ({ allowlist }?: {
|
|
3
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-
|
|
4
|
+
}) => (tree: Root) => Root | import("mdast").Link | import("mdast").Delete | import("mdast").Code | import("mdast-util-mdx").MdxJsxFlowElement | import("mdast-util-mdx").MdxJsxTextElement | 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-mdxjs-esm").MdxjsEsm;
|
|
@@ -12,7 +12,7 @@ const dedent = (text) => {
|
|
|
12
12
|
export const remarkPrompt = () => {
|
|
13
13
|
return (tree, file) => {
|
|
14
14
|
const source = String(file.value);
|
|
15
|
-
|
|
15
|
+
const transformPromptNode = (node) => {
|
|
16
16
|
if (node.name !== 'Prompt')
|
|
17
17
|
return;
|
|
18
18
|
if (!node.position)
|
|
@@ -23,7 +23,7 @@ export const remarkPrompt = () => {
|
|
|
23
23
|
const endOffset = node.position.end.offset;
|
|
24
24
|
if (startOffset === undefined || endOffset === undefined)
|
|
25
25
|
return;
|
|
26
|
-
const nodeSource = source.slice(startOffset, endOffset);
|
|
26
|
+
const nodeSource = source.slice(startOffset, endOffset).replace(/\r\n?/g, '\n');
|
|
27
27
|
let inString = false;
|
|
28
28
|
let braceDepth = 0;
|
|
29
29
|
let openTagEnd = -1;
|
|
@@ -34,7 +34,7 @@ export const remarkPrompt = () => {
|
|
|
34
34
|
inString = false;
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
|
-
if (ch === '"' || ch === "'") {
|
|
37
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
38
38
|
inString = ch;
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
@@ -84,6 +84,8 @@ export const remarkPrompt = () => {
|
|
|
84
84
|
},
|
|
85
85
|
});
|
|
86
86
|
node.children = [];
|
|
87
|
-
}
|
|
87
|
+
};
|
|
88
|
+
visit(tree, 'mdxJsxFlowElement', transformPromptNode);
|
|
89
|
+
visit(tree, 'mdxJsxTextElement', transformPromptNode);
|
|
88
90
|
};
|
|
89
91
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Root } from 'mdast';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps the paragraph MDX generates around the content of inline components
|
|
4
|
+
* authored in block form (`<Badge>\nBeta\n</Badge>`). Without this, the
|
|
5
|
+
* paragraph renders inside the component's inline element (`<span><p>`,
|
|
6
|
+
* `<button><p>`) — invalid HTML that browsers reparse, causing hydration
|
|
7
|
+
* mismatches. Any other block content (multiple paragraphs, headings,
|
|
8
|
+
* blockquotes, ...) is left untouched (flattening would silently merge
|
|
9
|
+
* blocks) and surfaced with a warning instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare const remarkUnwrapInlineJsx: () => (tree: Root) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
const INLINE_JSX_COMPONENTS = new Set(['Badge', 'Tooltip']);
|
|
3
|
+
/**
|
|
4
|
+
* Unwraps the paragraph MDX generates around the content of inline components
|
|
5
|
+
* authored in block form (`<Badge>\nBeta\n</Badge>`). Without this, the
|
|
6
|
+
* paragraph renders inside the component's inline element (`<span><p>`,
|
|
7
|
+
* `<button><p>`) — invalid HTML that browsers reparse, causing hydration
|
|
8
|
+
* mismatches. Any other block content (multiple paragraphs, headings,
|
|
9
|
+
* blockquotes, ...) is left untouched (flattening would silently merge
|
|
10
|
+
* blocks) and surfaced with a warning instead.
|
|
11
|
+
*/
|
|
12
|
+
export const remarkUnwrapInlineJsx = () => (tree) => {
|
|
13
|
+
visit(tree, 'mdxJsxFlowElement', (node) => {
|
|
14
|
+
if (!node.name || !INLINE_JSX_COMPONENTS.has(node.name))
|
|
15
|
+
return;
|
|
16
|
+
const [onlyChild] = node.children;
|
|
17
|
+
if (node.children.length === 1 && (onlyChild === null || onlyChild === void 0 ? void 0 : onlyChild.type) === 'paragraph') {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- phrasing content is valid at runtime; mdast types only allow block content here
|
|
19
|
+
node.children = onlyChild.children;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (node.children.length > 0) {
|
|
23
|
+
console.warn(`<${node.name}> is an inline component; block-level content inside it renders invalid HTML. Use a single line of content.`);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
import { isVisibilityElement, resolveVisibilityFor } from './remarkVisibilityForMarkdown.js';
|
|
3
|
+
export const remarkValidateVisibility = () => (tree) => {
|
|
4
|
+
visit(tree, (node) => {
|
|
5
|
+
if (!isVisibilityElement(node))
|
|
6
|
+
return;
|
|
7
|
+
const resolution = resolveVisibilityFor(node);
|
|
8
|
+
if (resolution.kind === 'invalid') {
|
|
9
|
+
console.warn(`<Visibility for="${resolution.raw}"> has an unknown audience — expected "humans" or "agents". The content will be hidden from humans.`);
|
|
10
|
+
}
|
|
11
|
+
if (resolution.kind === 'missing') {
|
|
12
|
+
console.warn('<Visibility> is missing its "for" audience — expected "humans" or "agents". The content will be hidden from humans.');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
|
+
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
3
|
+
type MdxJsxElement = MdxJsxFlowElement | MdxJsxTextElement;
|
|
4
|
+
export declare function isVisibilityElement(node: {
|
|
5
|
+
type: string;
|
|
6
|
+
name?: string | null;
|
|
7
|
+
}): boolean;
|
|
8
|
+
export type VisibilityResolution = {
|
|
9
|
+
kind: 'audience';
|
|
10
|
+
audience: 'humans' | 'agents';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'invalid';
|
|
13
|
+
raw: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'dynamic';
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'missing';
|
|
18
|
+
};
|
|
19
|
+
export declare function resolveVisibilityFor(node: MdxJsxElement): VisibilityResolution;
|
|
2
20
|
export declare const remarkVisibilityForMarkdown: () => (tree: Root) => void;
|
|
21
|
+
export {};
|
|
@@ -1,26 +1,52 @@
|
|
|
1
|
+
export function isVisibilityElement(node) {
|
|
2
|
+
return ((node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') &&
|
|
3
|
+
node.name === 'Visibility');
|
|
4
|
+
}
|
|
1
5
|
function isMdxJsxElement(node) {
|
|
2
6
|
return node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement';
|
|
3
7
|
}
|
|
4
|
-
function
|
|
8
|
+
export function resolveVisibilityFor(node) {
|
|
9
|
+
var _a;
|
|
10
|
+
let invalidRaw;
|
|
11
|
+
let sawDynamic = false;
|
|
12
|
+
let sawAttribute = false;
|
|
5
13
|
for (const attr of node.attributes) {
|
|
6
14
|
if (attr.type !== 'mdxJsxAttribute' || attr.name !== 'for')
|
|
7
15
|
continue;
|
|
16
|
+
sawAttribute = true;
|
|
8
17
|
if (typeof attr.value === 'string') {
|
|
9
|
-
if (attr.value === 'humans' || attr.value === 'agents')
|
|
10
|
-
return attr.value;
|
|
18
|
+
if (attr.value === 'humans' || attr.value === 'agents') {
|
|
19
|
+
return { kind: 'audience', audience: attr.value };
|
|
20
|
+
}
|
|
21
|
+
invalidRaw !== null && invalidRaw !== void 0 ? invalidRaw : (invalidRaw = attr.value);
|
|
11
22
|
continue;
|
|
12
23
|
}
|
|
13
|
-
if (attr.value &&
|
|
14
|
-
typeof attr.value === '
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
if (attr.value && typeof attr.value === 'object') {
|
|
25
|
+
if ('value' in attr.value && typeof attr.value.value === 'string') {
|
|
26
|
+
const raw = attr.value.value.trim();
|
|
27
|
+
const quoted = raw.match(/^(["'`])((?:\\.|(?!\1)[^\\])*)\1$/);
|
|
28
|
+
if (quoted) {
|
|
29
|
+
const inner = (_a = quoted[2]) !== null && _a !== void 0 ? _a : '';
|
|
30
|
+
const isTemplateWithInterpolation = quoted[1] === '`' && inner.includes('${');
|
|
31
|
+
if (!isTemplateWithInterpolation) {
|
|
32
|
+
if (inner === 'humans' || inner === 'agents') {
|
|
33
|
+
return { kind: 'audience', audience: inner };
|
|
34
|
+
}
|
|
35
|
+
invalidRaw !== null && invalidRaw !== void 0 ? invalidRaw : (invalidRaw = inner);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
sawDynamic = true;
|
|
21
41
|
}
|
|
22
42
|
}
|
|
23
|
-
|
|
43
|
+
if (invalidRaw !== undefined)
|
|
44
|
+
return { kind: 'invalid', raw: invalidRaw };
|
|
45
|
+
if (sawDynamic)
|
|
46
|
+
return { kind: 'dynamic' };
|
|
47
|
+
if (sawAttribute)
|
|
48
|
+
return { kind: 'missing' };
|
|
49
|
+
return { kind: 'missing' };
|
|
24
50
|
}
|
|
25
51
|
// `export * from` is intentionally ignored: it exposes no statically-knowable
|
|
26
52
|
// names and creates no page-local JSX bindings in MDX, so there is nothing to
|
|
@@ -120,12 +146,15 @@ function collectJsxReferences(node) {
|
|
|
120
146
|
// `visibleNames`. Usage inside an agents block counts as visible since that
|
|
121
147
|
// content survives into the markdown output.
|
|
122
148
|
function collectJsxUsage(nodes, insideHumans, hiddenNames, visibleNames) {
|
|
123
|
-
var _a, _b;
|
|
149
|
+
var _a, _b, _c;
|
|
124
150
|
for (const node of nodes) {
|
|
125
151
|
let childInsideHumans = insideHumans;
|
|
126
152
|
if (isMdxJsxElement(node)) {
|
|
127
153
|
if (node.name === 'Visibility') {
|
|
128
|
-
|
|
154
|
+
const resolution = resolveVisibilityFor(node);
|
|
155
|
+
const isHidden = resolution.kind === 'invalid' ||
|
|
156
|
+
(resolution.kind === 'audience' && resolution.audience === 'humans');
|
|
157
|
+
if (isHidden)
|
|
129
158
|
childInsideHumans = true;
|
|
130
159
|
}
|
|
131
160
|
else {
|
|
@@ -140,6 +169,15 @@ function collectJsxUsage(nodes, insideHumans, hiddenNames, visibleNames) {
|
|
|
140
169
|
if (node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') {
|
|
141
170
|
collectEstreeJsxNames((_b = node.data) === null || _b === void 0 ? void 0 : _b.estree, insideHumans ? hiddenNames : visibleNames);
|
|
142
171
|
}
|
|
172
|
+
// Attribute-embedded usages like `<Card icon={<Logo />}>` also live in estree.
|
|
173
|
+
if (isMdxJsxElement(node)) {
|
|
174
|
+
for (const attr of node.attributes) {
|
|
175
|
+
const expression = attr.type === 'mdxJsxAttribute' ? attr.value : attr;
|
|
176
|
+
if (expression && typeof expression === 'object' && 'data' in expression) {
|
|
177
|
+
collectEstreeJsxNames((_c = expression.data) === null || _c === void 0 ? void 0 : _c.estree, insideHumans ? hiddenNames : visibleNames);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
143
181
|
if ('children' in node && Array.isArray(node.children)) {
|
|
144
182
|
collectJsxUsage(node.children, childInsideHumans, hiddenNames, visibleNames);
|
|
145
183
|
}
|
|
@@ -156,13 +194,17 @@ function transformNode(node, esmToStrip) {
|
|
|
156
194
|
return esmToStrip.has(node) ? [] : [node];
|
|
157
195
|
}
|
|
158
196
|
if (isMdxJsxElement(node) && node.name === 'Visibility') {
|
|
159
|
-
const
|
|
160
|
-
if (audience === 'humans') {
|
|
197
|
+
const resolution = resolveVisibilityFor(node);
|
|
198
|
+
if (resolution.kind === 'audience' && resolution.audience === 'humans') {
|
|
161
199
|
return [];
|
|
162
200
|
}
|
|
163
|
-
if (audience === 'agents') {
|
|
201
|
+
if (resolution.kind === 'audience' && resolution.audience === 'agents') {
|
|
164
202
|
return transformChildren(node.children, esmToStrip);
|
|
165
203
|
}
|
|
204
|
+
if (resolution.kind === 'invalid') {
|
|
205
|
+
console.warn(`<Visibility for="${resolution.raw}"> has an unknown audience — expected "humans" or "agents". The content was removed from the markdown output.`);
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
166
208
|
}
|
|
167
209
|
if ('children' in node && Array.isArray(node.children)) {
|
|
168
210
|
const next = transformChildren(node.children, esmToStrip);
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { serialize } from '@mintlify/mdx/server';
|
|
11
11
|
import { getTailwindSelectors } from '../../css/tailwind.js';
|
|
12
|
-
import { getMDXOptions, remarkMdxRemoveJs, remarkExpandContent, remarkSplitCodeGroup, remarkSplitTabs, remarkValidateSteps, remarkValidateTabs, } from '../../index.js';
|
|
12
|
+
import { getMDXOptions, remarkMdxRemoveJs, remarkExpandContent, remarkSplitCodeGroup, remarkSplitTabs, remarkValidateSteps, remarkValidateVisibility, remarkValidateTabs, } from '../../index.js';
|
|
13
13
|
import { codeStylingToThemeOrThemes } from '../getCodeStyling.js';
|
|
14
14
|
import { preprocessCustomHeadingIds } from '../preprocessCustomHeadingIds.js';
|
|
15
15
|
import { replaceVariables } from '../replaceVariables.js';
|
|
@@ -32,7 +32,12 @@ export function getMdx(_a) {
|
|
|
32
32
|
path,
|
|
33
33
|
};
|
|
34
34
|
let mdxExtracts = {};
|
|
35
|
-
let plugins = [
|
|
35
|
+
let plugins = [
|
|
36
|
+
remarkValidateSteps,
|
|
37
|
+
remarkValidateTabs,
|
|
38
|
+
remarkValidateVisibility,
|
|
39
|
+
...remarkPlugins,
|
|
40
|
+
];
|
|
36
41
|
if (pageType === 'pdf') {
|
|
37
42
|
plugins = [...plugins, remarkExpandContent, remarkSplitCodeGroup, remarkSplitTabs];
|
|
38
43
|
}
|