@mintlify/common 1.0.741 → 1.0.743

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.
@@ -1,3 +1,3 @@
1
1
  export const createPathArr = (filePath) => {
2
- return filePath.split('/').filter((dir) => dir !== '');
2
+ return filePath.split(/[\\/]/).filter((dir) => dir !== '');
3
3
  };
@@ -1,6 +1,6 @@
1
1
  import type { PageMetaTags } from '@mintlify/models';
2
2
  import type { Root } from 'mdast';
3
- export declare function generateAccordionId(title: string): string;
3
+ export declare function generateAccordionId(title: string, count?: number): string;
4
4
  export declare const HEADING_LEVELS: number[];
5
5
  export declare const AVOIDED_PAGE_MODES: string[];
6
6
  export declare const CHILD_TAB_IDS_ATTRIBUTE = "data-child-tab-ids";
@@ -3,8 +3,9 @@ import { visit } from 'unist-util-visit';
3
3
  import { slugify } from '../../../slugify.js';
4
4
  import { createMdxJsxAttribute } from '../../lib/remark-utils.js';
5
5
  import { getTableOfContentsTitle } from '../../lib/remark-utils.js';
6
- export function generateAccordionId(title) {
7
- return defaultSlugify(title.replace(':', '-'), { decamelize: false });
6
+ export function generateAccordionId(title, count) {
7
+ const base = defaultSlugify(title.replace(':', '-'), { decamelize: false });
8
+ return count != null && count > 0 ? `${base}-${count}` : base;
8
9
  }
9
10
  export const HEADING_LEVELS = [1, 2, 3, 4];
10
11
  export const AVOIDED_PAGE_MODES = ['custom', 'frame'];
@@ -106,4 +107,20 @@ export const remarkComponentIds = (pageMetadata) => (tree) => {
106
107
  };
107
108
  precomputeTabSlugs(tree);
108
109
  processTabsRecursively(tree);
110
+ const accordionCounts = new Map();
111
+ visit(tree, 'mdxJsxFlowElement', (node) => {
112
+ var _a;
113
+ if (node.name !== 'Accordion')
114
+ return;
115
+ const titleAttr = node.attributes.find((attr) => 'name' in attr && attr.name === 'title');
116
+ if (!titleAttr || typeof titleAttr.value !== 'string' || !titleAttr.value)
117
+ return;
118
+ const hasId = node.attributes.some((attr) => 'name' in attr && attr.name === 'id');
119
+ if (hasId)
120
+ return;
121
+ const title = titleAttr.value;
122
+ const count = (_a = accordionCounts.get(title)) !== null && _a !== void 0 ? _a : 0;
123
+ accordionCounts.set(title, count + 1);
124
+ node.attributes.push(createMdxJsxAttribute('id', generateAccordionId(title, count)));
125
+ });
109
126
  };