@mintlify/common 1.0.1030 → 1.0.1031
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/plugins/remark/index.d.ts +1 -0
- package/dist/mdx/plugins/remark/index.js +1 -0
- package/dist/mdx/plugins/remark/remarkComponentIds.js +3 -2
- package/dist/mdx/plugins/remark/remarkValidateAccordions.d.ts +2 -0
- package/dist/mdx/plugins/remark/remarkValidateAccordions.js +29 -0
- package/dist/mdx/server-only/getMdx.js +2 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ export * from './remarkSplitCodeGroup.js';
|
|
|
14
14
|
export * from './remarkSplitTabs.js';
|
|
15
15
|
export * from './remarkComponentIds.js';
|
|
16
16
|
export * from './remarkMdxExtractPanel.js';
|
|
17
|
+
export * from './remarkValidateAccordions.js';
|
|
17
18
|
export * from './remarkValidateSteps.js';
|
|
18
19
|
export * from './remarkValidateVisibility.js';
|
|
19
20
|
export * from './remarkValidateTabs.js';
|
|
@@ -14,6 +14,7 @@ export * from './remarkSplitCodeGroup.js';
|
|
|
14
14
|
export * from './remarkSplitTabs.js';
|
|
15
15
|
export * from './remarkComponentIds.js';
|
|
16
16
|
export * from './remarkMdxExtractPanel.js';
|
|
17
|
+
export * from './remarkValidateAccordions.js';
|
|
17
18
|
export * from './remarkValidateSteps.js';
|
|
18
19
|
export * from './remarkValidateVisibility.js';
|
|
19
20
|
export * from './remarkValidateTabs.js';
|
|
@@ -165,8 +165,9 @@ export const remarkComponentIds = (pageMetadata) => (tree) => {
|
|
|
165
165
|
if (hasId)
|
|
166
166
|
return;
|
|
167
167
|
const title = titleAttr.value;
|
|
168
|
-
const
|
|
169
|
-
accordionCounts.
|
|
168
|
+
const baseSlug = generateComponentId(title);
|
|
169
|
+
const count = (_a = accordionCounts.get(baseSlug)) !== null && _a !== void 0 ? _a : 0;
|
|
170
|
+
accordionCounts.set(baseSlug, count + 1);
|
|
170
171
|
node.attributes.push(createMdxJsxAttribute('id', generateComponentId(title, count)));
|
|
171
172
|
});
|
|
172
173
|
// Generate IDs for View components from their title.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
import { generateComponentId } from './remarkComponentIds.js';
|
|
3
|
+
const findAttribute = (node, name) => node.attributes.find((attr) => attr.type === 'mdxJsxAttribute' && attr.name === name);
|
|
4
|
+
export const remarkValidateAccordions = () => (tree) => {
|
|
5
|
+
const seenSlugs = new Set();
|
|
6
|
+
const validate = (node) => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
if (node.name !== 'Accordion')
|
|
9
|
+
return;
|
|
10
|
+
const titleValue = (_a = findAttribute(node, 'title')) === null || _a === void 0 ? void 0 : _a.value;
|
|
11
|
+
if (titleValue != null && typeof titleValue !== 'string') {
|
|
12
|
+
console.warn('<Accordion> has a non-string title expression — deep linking is disabled for that accordion. Use a plain string title.');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!titleValue) {
|
|
16
|
+
console.warn('<Accordion> is missing a title — its content will not deep-link correctly. Add a descriptive title.');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const idValue = (_b = findAttribute(node, 'id')) === null || _b === void 0 ? void 0 : _b.value;
|
|
20
|
+
const slug = typeof idValue === 'string' && idValue ? idValue : generateComponentId(titleValue);
|
|
21
|
+
if (seenSlugs.has(slug)) {
|
|
22
|
+
console.warn(`<Accordion title="${titleValue}"> duplicates another accordion title on this page — deep links and assistive technology may target the wrong accordion. Use unique titles.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
seenSlugs.add(slug);
|
|
26
|
+
};
|
|
27
|
+
visit(tree, 'mdxJsxFlowElement', validate);
|
|
28
|
+
visit(tree, 'mdxJsxTextElement', validate);
|
|
29
|
+
};
|
|
@@ -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, remarkValidateVisibility, remarkValidateTabs, } from '../../index.js';
|
|
12
|
+
import { getMDXOptions, remarkMdxRemoveJs, remarkExpandContent, remarkSplitCodeGroup, remarkSplitTabs, remarkValidateAccordions, 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';
|
|
@@ -36,6 +36,7 @@ export function getMdx(_a) {
|
|
|
36
36
|
remarkValidateSteps,
|
|
37
37
|
remarkValidateTabs,
|
|
38
38
|
remarkValidateVisibility,
|
|
39
|
+
remarkValidateAccordions,
|
|
39
40
|
...remarkPlugins,
|
|
40
41
|
];
|
|
41
42
|
if (pageType === 'pdf') {
|