@mintlify/common 1.0.623 → 1.0.624
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.
|
@@ -14,6 +14,7 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
14
14
|
let hasTopLayer = false;
|
|
15
15
|
// the key is the node in unist
|
|
16
16
|
const tabContentMap = new Map();
|
|
17
|
+
const viewContentMap = new Map();
|
|
17
18
|
const excludedNodes = new Set();
|
|
18
19
|
visit(tree, (node) => {
|
|
19
20
|
if (node.type === 'mdxJsxFlowElement' &&
|
|
@@ -40,12 +41,25 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
}
|
|
44
|
+
if (node.type === 'mdxJsxFlowElement' && node.name === 'View') {
|
|
45
|
+
const titleAttr = node.attributes.find((attr) => 'name' in attr && attr.name === 'title');
|
|
46
|
+
let viewId;
|
|
47
|
+
if (titleAttr && 'value' in titleAttr && typeof titleAttr.value === 'string') {
|
|
48
|
+
viewId = titleAttr.value;
|
|
49
|
+
}
|
|
50
|
+
if (viewId) {
|
|
51
|
+
visit(node, (childNode) => {
|
|
52
|
+
viewContentMap.set(childNode, viewId);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
43
56
|
});
|
|
44
57
|
visit(tree, (node) => {
|
|
45
58
|
var _a, _b, _c, _d, _e;
|
|
46
59
|
if (excludedNodes.has(node))
|
|
47
60
|
return;
|
|
48
61
|
const currentTabId = tabContentMap.get(node);
|
|
62
|
+
const currentViewId = viewContentMap.get(node);
|
|
49
63
|
const isValidHeading = node.type === 'heading' && HEADING_LEVELS.includes(node.depth);
|
|
50
64
|
const isValidMdxHeading = node.type === 'mdxJsxFlowElement' && HEADING_NAMES.includes((_a = node.name) !== null && _a !== void 0 ? _a : '');
|
|
51
65
|
const isTransformedHeading = node.type === 'mdxJsxFlowElement' && node.name === 'Heading';
|
|
@@ -118,7 +132,14 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
118
132
|
const depth = node.depth;
|
|
119
133
|
if (level !== undefined && Number(level) <= 2) {
|
|
120
134
|
hasTopLayer = true;
|
|
121
|
-
contents.push({
|
|
135
|
+
contents.push({
|
|
136
|
+
title,
|
|
137
|
+
slug,
|
|
138
|
+
depth,
|
|
139
|
+
children: [],
|
|
140
|
+
tabId: currentTabId,
|
|
141
|
+
viewId: currentViewId,
|
|
142
|
+
});
|
|
122
143
|
}
|
|
123
144
|
else {
|
|
124
145
|
// Account if there is no first layer
|
|
@@ -126,7 +147,14 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
|
|
|
126
147
|
if (hasTopLayer) {
|
|
127
148
|
arrToPushInto = (_e = (_d = contents.at(-1)) === null || _d === void 0 ? void 0 : _d.children) !== null && _e !== void 0 ? _e : [];
|
|
128
149
|
}
|
|
129
|
-
arrToPushInto.push({
|
|
150
|
+
arrToPushInto.push({
|
|
151
|
+
title,
|
|
152
|
+
slug,
|
|
153
|
+
depth,
|
|
154
|
+
children: [],
|
|
155
|
+
tabId: currentTabId,
|
|
156
|
+
viewId: currentViewId,
|
|
157
|
+
});
|
|
130
158
|
}
|
|
131
159
|
});
|
|
132
160
|
if (mdxExtracts) {
|