@mintlify/common 1.0.1052 → 1.0.1054
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.
|
@@ -3,6 +3,7 @@ import { safeCleanHeadingId, slugify } from '../../../slugify.js';
|
|
|
3
3
|
import { createMdxJsxAttribute, getTableOfContentsTitle } from '../../lib/remark-utils.js';
|
|
4
4
|
import { isMdxJsxFragment } from '../../utils.js';
|
|
5
5
|
import { AVOIDED_PAGE_MODES, HEADING_LEVELS } from './remarkComponentIds.js';
|
|
6
|
+
import { isHiddenFromHumans, isVisibilityElement, resolveVisibilityFor, } from './remarkVisibilityForMarkdown.js';
|
|
6
7
|
import { isVariationElement, resolveVariationIds } from './variation.js';
|
|
7
8
|
export const HEADING_NAMES = ['h1', 'h2', 'h3', 'h4'];
|
|
8
9
|
const COMPONENTS_TO_EXCLUDE_HEADINGS = [
|
|
@@ -59,6 +60,14 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
59
60
|
excludedNodes.add(childNode);
|
|
60
61
|
});
|
|
61
62
|
}
|
|
63
|
+
const visibilityNode = node;
|
|
64
|
+
if (isVisibilityElement(visibilityNode) &&
|
|
65
|
+
isHiddenFromHumans(resolveVisibilityFor(visibilityNode))) {
|
|
66
|
+
visit(node, (childNode) => {
|
|
67
|
+
if (childNode !== node)
|
|
68
|
+
excludedNodes.add(childNode);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
62
71
|
if (node.type === 'mdxJsxFlowElement' && node.name === 'Steps') {
|
|
63
72
|
const stepsTitleSize = getStringAttribute(node.attributes, 'titleSize');
|
|
64
73
|
if (stepsTitleSize) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
2
|
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
3
|
-
type MdxJsxElement = MdxJsxFlowElement | MdxJsxTextElement;
|
|
3
|
+
export type MdxJsxElement = MdxJsxFlowElement | MdxJsxTextElement;
|
|
4
4
|
export declare function isVisibilityElement(node: {
|
|
5
5
|
type: string;
|
|
6
6
|
name?: string | null;
|
|
7
|
-
}):
|
|
7
|
+
}): node is MdxJsxElement;
|
|
8
8
|
export type VisibilityResolution = {
|
|
9
9
|
kind: 'audience';
|
|
10
10
|
audience: 'humans' | 'agents';
|
|
@@ -17,5 +17,5 @@ export type VisibilityResolution = {
|
|
|
17
17
|
kind: 'missing';
|
|
18
18
|
};
|
|
19
19
|
export declare function resolveVisibilityFor(node: MdxJsxElement): VisibilityResolution;
|
|
20
|
+
export declare function isHiddenFromHumans(resolution: VisibilityResolution): boolean;
|
|
20
21
|
export declare const remarkVisibilityForMarkdown: () => (tree: Root) => void;
|
|
21
|
-
export {};
|
|
@@ -48,6 +48,17 @@ export function resolveVisibilityFor(node) {
|
|
|
48
48
|
return { kind: 'missing' };
|
|
49
49
|
return { kind: 'missing' };
|
|
50
50
|
}
|
|
51
|
+
export function isHiddenFromHumans(resolution) {
|
|
52
|
+
switch (resolution.kind) {
|
|
53
|
+
case 'audience':
|
|
54
|
+
return resolution.audience === 'agents';
|
|
55
|
+
case 'invalid':
|
|
56
|
+
case 'missing':
|
|
57
|
+
return true;
|
|
58
|
+
case 'dynamic':
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
51
62
|
// `export * from` is intentionally ignored: it exposes no statically-knowable
|
|
52
63
|
// names and creates no page-local JSX bindings in MDX, so there is nothing to
|
|
53
64
|
// collect.
|