@mintlify/common 1.0.876 → 1.0.877

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,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, count?: number): string;
3
+ export declare function generateComponentId(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,7 +3,7 @@ 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, count) {
6
+ export function generateComponentId(title, count) {
7
7
  const base = defaultSlugify(title.replace(':', '-'), { decamelize: false });
8
8
  return count != null && count > 0 ? `${base}-${count}` : base;
9
9
  }
@@ -129,6 +129,27 @@ export const remarkComponentIds = (pageMetadata) => (tree) => {
129
129
  const title = titleAttr.value;
130
130
  const count = (_a = accordionCounts.get(title)) !== null && _a !== void 0 ? _a : 0;
131
131
  accordionCounts.set(title, count + 1);
132
- node.attributes.push(createMdxJsxAttribute('id', generateAccordionId(title, count)));
132
+ node.attributes.push(createMdxJsxAttribute('id', generateComponentId(title, count)));
133
+ });
134
+ // Generate IDs for View components from their title.
135
+ // Counter is keyed by the base slug (not the raw title) so distinct titles that
136
+ // slugify to the same id (e.g. "Setup-Advanced" and "Setup: Advanced") still get
137
+ // unique ids — required for URL hash sharing.
138
+ const viewCounts = new Map();
139
+ visit(tree, 'mdxJsxFlowElement', (node) => {
140
+ var _a;
141
+ if (node.name !== 'View')
142
+ return;
143
+ const titleAttr = node.attributes.find((attr) => 'name' in attr && attr.name === 'title');
144
+ if (!titleAttr || typeof titleAttr.value !== 'string' || !titleAttr.value)
145
+ return;
146
+ const hasId = node.attributes.some((attr) => 'name' in attr && attr.name === 'id');
147
+ if (hasId)
148
+ return;
149
+ const title = titleAttr.value;
150
+ const baseSlug = generateComponentId(title);
151
+ const count = (_a = viewCounts.get(baseSlug)) !== null && _a !== void 0 ? _a : 0;
152
+ viewCounts.set(baseSlug, count + 1);
153
+ node.attributes.push(createMdxJsxAttribute('id', generateComponentId(title, count)));
133
154
  });
134
155
  };
@@ -61,6 +61,9 @@ export const remarkExtractMultiView = (mdxExtracts) => {
61
61
  ` Learn more: https://www.mintlify.com/docs/components/view\n`);
62
62
  return;
63
63
  }
64
+ // Extract the id attribute (set by remarkComponentIds or explicit) so the
65
+ // client can match URL hashes back to the correct view for shareable links.
66
+ const id = getStringValue(node.attributes.find((attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'id'));
64
67
  const viewItem = {
65
68
  title,
66
69
  content,
@@ -71,6 +74,9 @@ export const remarkExtractMultiView = (mdxExtracts) => {
71
74
  if (iconType) {
72
75
  viewItem.iconType = iconType;
73
76
  }
77
+ if (id) {
78
+ viewItem.id = id;
79
+ }
74
80
  multiViews.push(viewItem);
75
81
  }
76
82
  }