@mintlify/common 1.0.996 → 1.0.997
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.
|
@@ -38,6 +38,10 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
38
38
|
// the key is the node in unist
|
|
39
39
|
const tabContentMap = new Map();
|
|
40
40
|
const viewContentMap = new Map();
|
|
41
|
+
// Maps a Step node to the titleSize inherited from its parent <Steps>.
|
|
42
|
+
// At render time <Steps titleSize> is forwarded to each child <Step> that
|
|
43
|
+
// doesn't set its own titleSize, so the TOC must honor the same fallback.
|
|
44
|
+
const inheritedStepTitleSizeMap = new Map();
|
|
41
45
|
const excludedNodes = new Set();
|
|
42
46
|
visit(tree, (node) => {
|
|
43
47
|
if (node.type === 'mdxJsxFlowElement' &&
|
|
@@ -48,6 +52,20 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
48
52
|
excludedNodes.add(childNode);
|
|
49
53
|
});
|
|
50
54
|
}
|
|
55
|
+
if (node.type === 'mdxJsxFlowElement' && node.name === 'Steps') {
|
|
56
|
+
const stepsTitleSize = getStringAttribute(node.attributes, 'titleSize');
|
|
57
|
+
if (stepsTitleSize) {
|
|
58
|
+
// At render time <Steps> only forwards titleSize to its immediate
|
|
59
|
+
// child <Step>s, so mirror that here. Assigning to every descendant
|
|
60
|
+
// would leak the value into a nested <Steps> and its own steps even
|
|
61
|
+
// when that inner wrapper sets no (or a different) titleSize.
|
|
62
|
+
for (const childNode of node.children) {
|
|
63
|
+
if (childNode.type === 'mdxJsxFlowElement' && childNode.name === 'Step') {
|
|
64
|
+
inheritedStepTitleSizeMap.set(childNode, stepsTitleSize);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
51
69
|
if (node.type === 'mdxJsxFlowElement' && node.name === 'Tab') {
|
|
52
70
|
const idValue = getStringAttribute(node.attributes, 'id');
|
|
53
71
|
const titleValue = getStringAttribute(node.attributes, 'title');
|
|
@@ -79,9 +97,12 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
79
97
|
const isValidUpdate = node.type === 'mdxJsxFlowElement' &&
|
|
80
98
|
node.name === 'Update' &&
|
|
81
99
|
node.attributes.some((attr) => 'name' in attr && attr.name === 'label');
|
|
100
|
+
const stepTitleSize = node.type === 'mdxJsxFlowElement' && node.name === 'Step'
|
|
101
|
+
? ((_b = getStringAttribute(node.attributes, 'titleSize')) !== null && _b !== void 0 ? _b : inheritedStepTitleSizeMap.get(node))
|
|
102
|
+
: undefined;
|
|
82
103
|
const isValidStep = node.type === 'mdxJsxFlowElement' &&
|
|
83
104
|
node.name === 'Step' &&
|
|
84
|
-
['h2', 'h3'].includes(
|
|
105
|
+
['h2', 'h3'].includes(stepTitleSize !== null && stepTitleSize !== void 0 ? stepTitleSize : '') &&
|
|
85
106
|
((_d = (_c = getStringAttribute(node.attributes, 'title')) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : '') !== '';
|
|
86
107
|
const hasIdAttribute = node.type === 'mdxJsxFlowElement' &&
|
|
87
108
|
node.attributes.some((attr) => 'name' in attr && attr.name === 'id');
|
|
@@ -102,9 +123,8 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
102
123
|
node.depth = 1;
|
|
103
124
|
}
|
|
104
125
|
else if ('name' in node && node.name === 'Step') {
|
|
105
|
-
const titleSize = getStringAttribute(node.attributes, 'titleSize');
|
|
106
126
|
const titleSizeToLevel = { h2: 2, h3: 3, h4: 4 };
|
|
107
|
-
level = (_f = titleSizeToLevel[
|
|
127
|
+
level = (_f = titleSizeToLevel[stepTitleSize !== null && stepTitleSize !== void 0 ? stepTitleSize : '']) !== null && _f !== void 0 ? _f : 3;
|
|
108
128
|
// @ts-expect-error we're assigning to depth despite the node not containing depth in the type
|
|
109
129
|
node.depth = level;
|
|
110
130
|
}
|