@mintlify/msft-sdk 1.1.10 → 1.1.12

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.
Files changed (45) hide show
  1. package/dist/components/content-components/code-block.js +3 -3
  2. package/dist/components/content-components/code-block.js.map +1 -1
  3. package/dist/components/content-components/default-components.js +21 -26
  4. package/dist/components/content-components/default-components.js.map +1 -1
  5. package/dist/components/content-components/details/details.js +1 -1
  6. package/dist/components/content-components/details/details.js.map +1 -1
  7. package/dist/components/content-components/home.js +3 -278
  8. package/dist/components/content-components/home.js.map +1 -1
  9. package/dist/components/content-components/image.js +80 -0
  10. package/dist/components/content-components/image.js.map +1 -0
  11. package/dist/components/content-components/param-name.js +1 -1
  12. package/dist/components/content-components/param-name.js.map +1 -1
  13. package/dist/components/content-components/zone-pivots/zone-pivot-selector.js +22 -19
  14. package/dist/components/content-components/zone-pivots/zone-pivot-selector.js.map +1 -1
  15. package/dist/components/docsLayout.js +60 -0
  16. package/dist/components/docsLayout.js.map +1 -0
  17. package/dist/components/docsPage.js +128 -0
  18. package/dist/components/docsPage.js.map +1 -0
  19. package/dist/components/nav-tree/index.js +127 -159
  20. package/dist/components/nav-tree/index.js.map +1 -1
  21. package/dist/components/nav-tree/mobile-nav.js +21 -23
  22. package/dist/components/nav-tree/mobile-nav.js.map +1 -1
  23. package/dist/components/page-context-menu.js +47 -53
  24. package/dist/components/page-context-menu.js.map +1 -1
  25. package/dist/components/toc/index.js +5 -5
  26. package/dist/components/toc/index.js.map +1 -1
  27. package/dist/index.d.ts +180 -40
  28. package/dist/index.js +62 -64
  29. package/dist/index.js.map +1 -1
  30. package/dist/parser/serialize-mdx.js +27 -22
  31. package/dist/parser/serialize-mdx.js.map +1 -1
  32. package/dist/plugins/extract-headings.js +23 -17
  33. package/dist/plugins/extract-headings.js.map +1 -1
  34. package/dist/plugins/remark/remark-heading-ids.js +21 -14
  35. package/dist/plugins/remark/remark-heading-ids.js.map +1 -1
  36. package/dist/styles.css +1 -1
  37. package/package.json +1 -1
  38. package/dist/components/Api/Api.js +0 -42
  39. package/dist/components/Api/Api.js.map +0 -1
  40. package/dist/components/Api/Api.module.css.js +0 -22
  41. package/dist/components/Api/Api.module.css.js.map +0 -1
  42. package/dist/components/nav-tree/dropdown-menu.js +0 -75
  43. package/dist/components/nav-tree/dropdown-menu.js.map +0 -1
  44. package/dist/components/page.js +0 -120
  45. package/dist/components/page.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import { Node as Node_2 } from 'unist';
8
8
  import { Node as Node_3 } from 'hast';
9
9
  import { Plugin as Plugin_2 } from 'unified';
10
10
  import * as React_2 from 'react';
11
+ import { ReactNode } from 'react';
11
12
  import { Root } from 'mdast';
12
13
  import { Root as Root_2 } from 'hast';
13
14
  import { State } from 'hast-util-to-mdast';
@@ -27,10 +28,6 @@ export declare const allComponents: {
27
28
  Summary: typeof Summary;
28
29
  };
29
30
 
30
- export declare function Api({ children }: {
31
- children?: default_2.ReactNode;
32
- }): JSX_2.Element;
33
-
34
31
  declare interface ApiReferenceContextValue {
35
32
  apiReferenceData2?: any;
36
33
  docsConfig?: any;
@@ -87,6 +84,14 @@ export declare function ComponentsProvider({ children, LinkComponent, }: {
87
84
  LinkComponent?: LinkComponent;
88
85
  }): JSX_2.Element;
89
86
 
87
+ declare type ContextualOption = {
88
+ id: string;
89
+ title: string;
90
+ description: string;
91
+ icon: default_2.ElementType;
92
+ action: () => void;
93
+ };
94
+
90
95
  export declare function convertHtmlToMdx(html: string, options?: ConvertOptions): Promise<{
91
96
  mdx: string;
92
97
  mdxExtracts: MdxExtracts;
@@ -123,13 +128,128 @@ declare interface DetailsProps {
123
128
  open?: boolean;
124
129
  }
125
130
 
126
- export declare function DocsPage({ payload, toc, navTree, dropdown, activeHref, theme, className, pathname, markdownContent, allPages, baseUrl, bottomLinks, LinkComponent, }: DocsPageProps): JSX_2.Element;
131
+ /**
132
+ * DocsLayout component provides a complete documentation layout with sidebar navigation
133
+ * and main content area. It's designed to be scalable, customizable, and tree-shakable.
134
+ *
135
+ * @example
136
+ * ```tsx
137
+ * <DocsLayout
138
+ * navTree={{ items: [...] }}
139
+ * activeHref="/docs/getting-started"
140
+ * theme="dark"
141
+ * bottomLinks={[
142
+ * { href: "https://blog.com", label: "Blog", icon: BlogIcon }
143
+ * ]}
144
+ * LinkComponent={Link}
145
+ * >
146
+ * <YourPageContent />
147
+ * </DocsLayout>
148
+ * ```
149
+ */
150
+ export declare const DocsLayout: ({ navTree, children, activeHref, activeId, theme, className, bottomLinks, LinkComponent, localization, telemetry, showSidebar, sidebarClassName, }: DocsLayoutProps) => JSX_2.Element;
151
+
152
+ /**
153
+ * Localization strings for DocsLayout
154
+ */
155
+ export declare interface DocsLayoutLocalization {
156
+ /** Aria label for the sidebar navigation. Default: "Sidebar navigation" */
157
+ sidebarAriaLabel?: string;
158
+ }
159
+
160
+ /**
161
+ * Props for the DocsLayout component
162
+ */
163
+ export declare interface DocsLayoutProps {
164
+ /** Navigation tree data structure */
165
+ navTree: NavTreeData;
166
+ /** The main content to render in the layout */
167
+ children: ReactNode;
168
+ /** Currently active href for navigation highlighting */
169
+ activeHref?: string;
170
+ /** Currently active ID for navigation highlighting */
171
+ activeId?: string;
172
+ /** Theme for the layout */
173
+ theme?: "light" | "dark";
174
+ /** Additional CSS classes for the outer container */
175
+ className?: string;
176
+ /** Bottom links configuration (e.g., blog, GitHub, feedback) */
177
+ bottomLinks?: BottomLinkConfig[];
178
+ /** Custom Link component for navigation (e.g., React Router Link, Next.js Link) */
179
+ LinkComponent?: LinkComponent;
180
+ /** Localization strings */
181
+ localization?: DocsLayoutLocalization;
182
+ /** Telemetry configuration */
183
+ telemetry?: DocsLayoutTelemetry;
184
+ /** Whether to show the sidebar. Default: true */
185
+ showSidebar?: boolean;
186
+ /** Custom className for the sidebar to control responsive behavior.
187
+ * Default: "mint:max-lg:hidden" (hidden below lg breakpoint) */
188
+ sidebarClassName?: string;
189
+ }
190
+
191
+ /**
192
+ * Telemetry configuration for DocsLayout
193
+ */
194
+ export declare interface DocsLayoutTelemetry {
195
+ /** Activity name for bottom link clicks */
196
+ bottomLinkActivity?: string;
197
+ /** Phase for bottom link clicks (e.g., "Start", "Complete") */
198
+ bottomLinkPhase?: string;
199
+ }
200
+
201
+ /**
202
+ * DocsPage component renders a documentation page with MDX content, table of contents,
203
+ * zone pivot selectors, and page context menu. It supports full customization through
204
+ * props for localization, telemetry, and custom components.
205
+ *
206
+ * @example
207
+ * ```tsx
208
+ * <DocsPage
209
+ * payload={{
210
+ * content: "...",
211
+ * serializedContent: Content,
212
+ * title: "Getting Started",
213
+ * description: "Learn how to get started"
214
+ * }}
215
+ * toc={[{ title: "Introduction", slug: "intro", level: 2 }]}
216
+ * theme="dark"
217
+ * pathname="/docs/getting-started"
218
+ * LinkComponent={Link}
219
+ * localization={{
220
+ * onThisPage: "In this article"
221
+ * }}
222
+ * telemetry={{
223
+ * contextMenuActivity: "DocsPageContextMenu",
224
+ * contextMenuPhase: "Start"
225
+ * }}
226
+ * />
227
+ * ```
228
+ */
229
+ export declare function DocsPage({ payload, toc, navTree, activeHref, theme, className, pathname, markdownContent, allPages, baseUrl, bottomLinks, LinkComponent, localization, telemetry, contextMenu, }: DocsPagePropsWithCustomization): JSX_2.Element;
230
+
231
+ /**
232
+ * Localization strings for DocsPage component
233
+ */
234
+ export declare interface DocsPageLocalization {
235
+ /** Text for "On this page" heading. Default: "On this page" */
236
+ onThisPage?: string;
237
+ /** Loading message. Default: "Loading..." */
238
+ loading?: string;
239
+ /** Error title. Default: "Error" */
240
+ errorTitle?: string;
241
+ /** Generic error message. Default: "Something went wrong" */
242
+ errorMessage?: string;
243
+ /** Not found title. Default: "Page not found" */
244
+ notFoundTitle?: string;
245
+ /** Not found message. Default: "The page you're looking for doesn't exist" */
246
+ notFoundMessage?: string;
247
+ }
127
248
 
128
249
  export declare interface DocsPageProps {
129
250
  payload: PayloadData;
130
251
  toc?: TocItem[];
131
252
  navTree?: NavTreeData;
132
- dropdown?: DropdownConfig;
133
253
  activeHref?: string;
134
254
  theme?: "light" | "dark";
135
255
  className?: string;
@@ -141,35 +261,34 @@ export declare interface DocsPageProps {
141
261
  LinkComponent?: LinkComponent;
142
262
  }
143
263
 
144
- export declare interface DropdownConfig {
145
- title: string;
146
- description: string;
147
- icon?: default_2.ComponentType<{
148
- className?: string;
149
- }>;
150
- color?: {
151
- light?: string;
152
- dark?: string;
153
- };
154
- items?: DropdownItem[];
155
- }
156
-
157
- export declare interface DropdownItem {
158
- title: string;
159
- href?: string;
160
- description?: string;
161
- icon?: default_2.ComponentType<{
162
- className?: string;
163
- }>;
164
- }
165
-
166
- export declare function DropdownMenu({ dropdown, isActive, activeHref, className, }: DropdownMenuProps): JSX_2.Element;
167
-
168
- declare interface DropdownMenuProps {
169
- dropdown: DropdownConfig;
170
- isActive?: boolean;
171
- activeHref?: string;
172
- className?: string;
264
+ /**
265
+ * Enhanced DocsPageProps with localization and telemetry support
266
+ */
267
+ export declare interface DocsPagePropsWithCustomization extends DocsPageProps {
268
+ /** Localization strings */
269
+ localization?: DocsPageLocalization;
270
+ /** Telemetry configuration */
271
+ telemetry?: DocsPageTelemetry;
272
+ /** Context menu configuration */
273
+ contextMenu?: PageContextMenuConfig;
274
+ }
275
+
276
+ /**
277
+ * Telemetry configuration for DocsPage
278
+ */
279
+ export declare interface DocsPageTelemetry {
280
+ /** Activity name for page context menu interactions */
281
+ contextMenuActivity?: string;
282
+ /** Phase for context menu interactions */
283
+ contextMenuPhase?: string;
284
+ /** Activity name for TOC link clicks */
285
+ tocLinkActivity?: string;
286
+ /** Phase for TOC link clicks */
287
+ tocLinkPhase?: string;
288
+ /** Activity name for zone pivot selector changes */
289
+ zonePivotActivity?: string;
290
+ /** Phase for zone pivot changes */
291
+ zonePivotPhase?: string;
173
292
  }
174
293
 
175
294
  export declare type ElementType = {
@@ -284,7 +403,7 @@ declare interface MDXRendererProps {
284
403
  components?: MDXComponents;
285
404
  }
286
405
 
287
- export declare function MobileNavTree({ isOpen, setIsOpen, navTree, activeId, className, theme, dropdown, activeHref, bottomLinks, LinkComponent, }: MobileNavTreeProps): JSX_2.Element;
406
+ export declare function MobileNavTree({ isOpen, setIsOpen, navTree, activeId, className, theme, activeHref, bottomLinks, LinkComponent, }: MobileNavTreeProps): JSX_2.Element;
288
407
 
289
408
  declare interface MobileNavTreeProps {
290
409
  isOpen: boolean;
@@ -293,7 +412,6 @@ declare interface MobileNavTreeProps {
293
412
  activeId?: string;
294
413
  className?: string;
295
414
  theme?: "light" | "dark" | "system";
296
- dropdown?: DropdownConfig;
297
415
  activeHref?: string;
298
416
  bottomLinks?: BottomLinkConfig[];
299
417
  LinkComponent?: LinkComponent;
@@ -310,7 +428,7 @@ export declare interface NavItem {
310
428
  method?: string;
311
429
  }
312
430
 
313
- export declare function NavTree({ navTree, activeId, className, dropdown, activeHref, theme, bottomLinks, }: NavTreeProps): JSX_2.Element | null;
431
+ export declare function NavTree({ navTree, activeId, className, activeHref, theme, bottomLinks, }: NavTreeProps): JSX_2.Element | null;
314
432
 
315
433
  export declare interface NavTreeData {
316
434
  items: NavItem[];
@@ -320,7 +438,6 @@ declare interface NavTreeProps {
320
438
  navTree: NavTreeData;
321
439
  activeId?: string;
322
440
  className?: string;
323
- dropdown?: DropdownConfig;
324
441
  activeHref?: string;
325
442
  theme?: "light" | "dark" | "system";
326
443
  bottomLinks?: BottomLinkConfig[];
@@ -328,6 +445,24 @@ declare interface NavTreeProps {
328
445
 
329
446
  export declare const PageContextMenu: ({ className, pathname, markdownContent, onCopyMarkdown, onViewMarkdown, allPages, baseUrl, }: PageContextMenuProps) => JSX_2.Element;
330
447
 
448
+ /**
449
+ * Configuration for the page context menu
450
+ */
451
+ export declare interface PageContextMenuConfig {
452
+ /** Custom actions for the page context menu. If provided, these will replace the default actions. */
453
+ customActions?: ContextualOption[];
454
+ /** Callback fired after markdown is successfully copied */
455
+ onCopyMarkdown?: () => void;
456
+ /** Custom handler for "Copy Page" action. If provided, replaces default copy behavior. */
457
+ onCopyPage?: () => void | Promise<void>;
458
+ /** Custom handler for "View as Markdown" action. If provided, replaces default view behavior. */
459
+ onViewMarkdown?: (pathname: string) => void;
460
+ /** Custom handler for "View llms.txt" action. If provided, replaces default behavior. */
461
+ onViewLlmsTxt?: () => void;
462
+ /** Custom handler for "View llms-full.txt" action. If provided, replaces default behavior. */
463
+ onViewLlmsFullTxt?: () => void;
464
+ }
465
+
331
466
  export declare interface PageContextMenuProps {
332
467
  className?: string;
333
468
  pathname: string;
@@ -390,7 +525,12 @@ export declare function removeHtmlComments(root: Root_2): void;
390
525
 
391
526
  export declare const sanitizePreTags: Plugin_2<[], Node_3>;
392
527
 
393
- export declare function serializeMdx(mdxString: string): Promise<default_2.ComponentType>;
528
+ export declare function serializeMdx(mdxString: string): Promise<SerializeMdxResult>;
529
+
530
+ export declare interface SerializeMdxResult {
531
+ Content: default_2.ComponentType;
532
+ headings: TocItem[];
533
+ }
394
534
 
395
535
  export declare function Summary({ children, isOpen }: SummaryProps): JSX_2.Element;
396
536
 
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { DocsPage as r } from "./components/page.js";
2
- import { MDXRenderer as m } from "./components/mdx-renderer.js";
3
- import { PlainTextPage as a } from "./components/plain-text-page.js";
4
- import { createDefaultComponents as f, defaultComponents as l } from "./components/content-components/default-components.js";
5
- import { ComponentsProvider as s, useComponents as d } from "./context/components-context.js";
6
- import { NavTree as T } from "./components/nav-tree/index.js";
7
- import { Api as b } from "./components/Api/Api.js";
8
- import { ApiReferenceProvider2 as P, useApiReference as H } from "./components/Api/ApiReferenceProvider.js";
9
- import { TableOfContents as y } from "./components/toc/index.js";
1
+ import { DocsPage as r } from "./components/docsPage.js";
2
+ import { DocsLayout as m } from "./components/docsLayout.js";
3
+ import { MDXRenderer as a } from "./components/mdx-renderer.js";
4
+ import { PlainTextPage as f } from "./components/plain-text-page.js";
5
+ import { createDefaultComponents as n, defaultComponents as s } from "./components/content-components/default-components.js";
6
+ import { ComponentsProvider as i, useComponents as T } from "./context/components-context.js";
7
+ import { NavTree as b } from "./components/nav-tree/index.js";
8
+ import { ApiReferenceProvider2 as P, useApiReference as y } from "./components/Api/ApiReferenceProvider.js";
9
+ import { TableOfContents as c } from "./components/toc/index.js";
10
10
  import { PivotAwareTOC as u } from "./components/toc/pivot-aware-toc.js";
11
- import { PageContextMenu as M } from "./components/page-context-menu.js";
11
+ import { PageContextMenu as k } from "./components/page-context-menu.js";
12
12
  import { copyMarkdownToClipboard as w, getPageMarkdown as R, useMarkdownCopy as D } from "./hooks/useMarkdownCopy.js";
13
- import { generateLlmsFullTxt as Z, generateLlmsTxt as A } from "./utils/generate-llms-txt.js";
14
- import { getNodeText as F } from "./utils/get-node-text.js";
13
+ import { generateLlmsFullTxt as Z, generateLlmsTxt as L } from "./utils/generate-llms-txt.js";
14
+ import { getNodeText as A } from "./utils/get-node-text.js";
15
15
  import { capitalize as B } from "./utils/string.js";
16
16
  import { cn as I } from "./utils/cn.js";
17
17
  import { getClassNames as S, getTextContent as J, isElement as X } from "./utils/rehype.js";
@@ -29,53 +29,51 @@ import { ZonePivotProvider as se } from "./components/content-components/zone-pi
29
29
  import { ZonePivotSelector as ie } from "./components/content-components/zone-pivots/zone-pivot-selector.js";
30
30
  import { ParamName as Ce } from "./components/content-components/param-name.js";
31
31
  import { Tabs as ge } from "./components/content-components/tabs/tabs.js";
32
- import { Tab as He } from "./components/content-components/tabs/tab.js";
33
- import { Details as ye, Summary as ce } from "./components/content-components/details/details.js";
34
- import { Table as he, TableBody as Me, TableCaption as ke, TableCell as we, TableFooter as Re, TableHead as De, TableHeader as Ne, TableRow as Ze } from "./components/content-components/table/index.js";
32
+ import { Tab as ye } from "./components/content-components/tabs/tab.js";
33
+ import { Details as ce, Summary as ve } from "./components/content-components/details/details.js";
34
+ import { Table as he, TableBody as ke, TableCaption as Me, TableCell as we, TableFooter as Re, TableHead as De, TableHeader as Ne, TableRow as Ze } from "./components/content-components/table/index.js";
35
35
  import { allComponents as ze } from "./components/content-components/all-components.js";
36
- import { Home as Le } from "./components/content-components/home.js";
37
- import { DropdownMenu as Ee } from "./components/nav-tree/dropdown-menu.js";
38
- import { MobileNavTree as Oe } from "./components/nav-tree/mobile-nav.js";
39
- import { rehypeCodeblocks as Je } from "./plugins/rehype/rehype-code-blocks.js";
40
- import { remarkHeadingIds as je } from "./plugins/remark/remark-heading-ids.js";
41
- import { sanitizePreTags as Ge } from "./plugins/sanitize/rehype-pre-to-mdx-fence.js";
42
- import { rehypeCallouts as Qe } from "./plugins/sanitize/rehype-callouts.js";
43
- import { rehypeParamName as Ve } from "./plugins/sanitize/rehype-param-name.js";
44
- import { rehypeTabs as Ye } from "./plugins/sanitize/rehype-tabs.js";
45
- import { rehypeDetails as $e } from "./plugins/sanitize/rehype-details.js";
46
- import { rehypeHeadingIds as oo } from "./plugins/sanitize/rehype-heading-ids.js";
47
- import { rehypeZonePivots as to } from "./plugins/sanitize/rehype-zone-pivots.js";
48
- import { mdxJsxFlowElementHandler as po, rehypeRemark as ao } from "./plugins/sanitize/rehype-remark.js";
49
- import { tableCellHandler as fo, tableHandler as lo, tableRowHandler as no } from "./plugins/sanitize/rehype-table-align.js";
36
+ import { Home as Fe } from "./components/content-components/home.js";
37
+ import { MobileNavTree as Ee } from "./components/nav-tree/mobile-nav.js";
38
+ import { rehypeCodeblocks as Oe } from "./plugins/rehype/rehype-code-blocks.js";
39
+ import { remarkHeadingIds as Je } from "./plugins/remark/remark-heading-ids.js";
40
+ import { sanitizePreTags as je } from "./plugins/sanitize/rehype-pre-to-mdx-fence.js";
41
+ import { rehypeCallouts as Ge } from "./plugins/sanitize/rehype-callouts.js";
42
+ import { rehypeParamName as Qe } from "./plugins/sanitize/rehype-param-name.js";
43
+ import { rehypeTabs as Ve } from "./plugins/sanitize/rehype-tabs.js";
44
+ import { rehypeDetails as Ye } from "./plugins/sanitize/rehype-details.js";
45
+ import { rehypeHeadingIds as $e } from "./plugins/sanitize/rehype-heading-ids.js";
46
+ import { rehypeZonePivots as oo } from "./plugins/sanitize/rehype-zone-pivots.js";
47
+ import { mdxJsxFlowElementHandler as to, rehypeRemark as mo } from "./plugins/sanitize/rehype-remark.js";
48
+ import { tableCellHandler as ao, tableHandler as xo, tableRowHandler as fo } from "./plugins/sanitize/rehype-table-align.js";
50
49
  export {
51
- b as Api,
52
50
  P as ApiReferenceProvider2,
53
51
  pe as Callout,
54
52
  $ as CodeBlock,
55
- s as ComponentsProvider,
56
- ye as Details,
53
+ i as ComponentsProvider,
54
+ ce as Details,
55
+ m as DocsLayout,
57
56
  r as DocsPage,
58
- Ee as DropdownMenu,
59
57
  oe as Heading,
60
- Le as Home,
58
+ Fe as Home,
61
59
  te as Link,
62
- m as MDXRenderer,
63
- Oe as MobileNavTree,
64
- T as NavTree,
65
- M as PageContextMenu,
60
+ a as MDXRenderer,
61
+ Ee as MobileNavTree,
62
+ b as NavTree,
63
+ k as PageContextMenu,
66
64
  Ce as ParamName,
67
65
  u as PivotAwareTOC,
68
- a as PlainTextPage,
69
- ce as Summary,
70
- He as Tab,
66
+ f as PlainTextPage,
67
+ ve as Summary,
68
+ ye as Tab,
71
69
  he as Table,
72
- Me as TableBody,
73
- ke as TableCaption,
70
+ ke as TableBody,
71
+ Me as TableCaption,
74
72
  we as TableCell,
75
73
  Re as TableFooter,
76
74
  De as TableHead,
77
75
  Ne as TableHeader,
78
- y as TableOfContents,
76
+ c as TableOfContents,
79
77
  Ze as TableRow,
80
78
  ge as Tabs,
81
79
  xe as ZonePivot,
@@ -87,35 +85,35 @@ export {
87
85
  I as cn,
88
86
  q as convertHtmlToMdx,
89
87
  w as copyMarkdownToClipboard,
90
- f as createDefaultComponents,
91
- l as defaultComponents,
88
+ n as createDefaultComponents,
89
+ s as defaultComponents,
92
90
  U as extractHeadings,
93
91
  Z as generateLlmsFullTxt,
94
- A as generateLlmsTxt,
92
+ L as generateLlmsTxt,
95
93
  S as getClassNames,
96
- F as getNodeText,
94
+ A as getNodeText,
97
95
  R as getPageMarkdown,
98
96
  J as getTextContent,
99
97
  X as isElement,
100
- po as mdxJsxFlowElementHandler,
101
- Qe as rehypeCallouts,
102
- Je as rehypeCodeblocks,
103
- $e as rehypeDetails,
104
- oo as rehypeHeadingIds,
105
- Ve as rehypeParamName,
106
- ao as rehypeRemark,
98
+ to as mdxJsxFlowElementHandler,
99
+ Ge as rehypeCallouts,
100
+ Oe as rehypeCodeblocks,
101
+ Ye as rehypeDetails,
102
+ $e as rehypeHeadingIds,
103
+ Qe as rehypeParamName,
104
+ mo as rehypeRemark,
107
105
  W as rehypeRemoveHtmlComments,
108
- Ye as rehypeTabs,
109
- to as rehypeZonePivots,
110
- je as remarkHeadingIds,
106
+ Ve as rehypeTabs,
107
+ oo as rehypeZonePivots,
108
+ Je as remarkHeadingIds,
111
109
  Y as removeHtmlComments,
112
- Ge as sanitizePreTags,
110
+ je as sanitizePreTags,
113
111
  K as serializeMdx,
114
- fo as tableCellHandler,
115
- lo as tableHandler,
116
- no as tableRowHandler,
117
- H as useApiReference,
118
- d as useComponents,
112
+ ao as tableCellHandler,
113
+ xo as tableHandler,
114
+ fo as tableRowHandler,
115
+ y as useApiReference,
116
+ T as useComponents,
119
117
  D as useMarkdownCopy
120
118
  };
121
119
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,28 +1,33 @@
1
- import * as i from "react/jsx-runtime";
2
- import { jsx as n } from "react/jsx-runtime";
3
- import { compile as a, run as p } from "@mdx-js/mdx";
4
- import s from "remark-gfm";
5
- import { rehypeCodeblocks as c } from "../plugins/rehype/rehype-code-blocks.js";
6
- import { remarkHeadingIds as f } from "../plugins/remark/remark-heading-ids.js";
7
- import { defaultComponents as l } from "../components/content-components/default-components.js";
8
- async function x(r) {
1
+ import * as a from "react/jsx-runtime";
2
+ import { jsx as s } from "react/jsx-runtime";
3
+ import { compile as p, run as c } from "@mdx-js/mdx";
4
+ import d from "remark-gfm";
5
+ import { extractHeadings as f } from "../plugins/extract-headings.js";
6
+ import { rehypeCodeblocks as l } from "../plugins/rehype/rehype-code-blocks.js";
7
+ import { remarkHeadingIds as u } from "../plugins/remark/remark-heading-ids.js";
8
+ import { defaultComponents as g } from "../components/content-components/default-components.js";
9
+ async function H(t) {
10
+ var r;
9
11
  try {
10
- const o = await a(r, {
12
+ const o = await p(t, {
11
13
  outputFormat: "function-body",
12
- remarkPlugins: [s, f],
13
- rehypePlugins: [c]
14
- }), t = String(o), { default: e } = await p(t, {
15
- ...i
14
+ remarkPlugins: [d, u, f],
15
+ rehypePlugins: [l]
16
+ }), n = String(o), e = ((r = o.data) == null ? void 0 : r.headings) || [], { default: m } = await c(n, {
17
+ ...a
16
18
  });
17
- return (m) => /* @__PURE__ */ n(
18
- e,
19
- {
20
- ...m,
21
- components: {
22
- ...l
19
+ return {
20
+ Content: (i) => /* @__PURE__ */ s(
21
+ m,
22
+ {
23
+ ...i,
24
+ components: {
25
+ ...g
26
+ }
23
27
  }
24
- }
25
- );
28
+ ),
29
+ headings: e
30
+ };
26
31
  } catch (o) {
27
32
  throw console.error(
28
33
  "MDX compilation failed:",
@@ -31,6 +36,6 @@ async function x(r) {
31
36
  }
32
37
  }
33
38
  export {
34
- x as serializeMdx
39
+ H as serializeMdx
35
40
  };
36
41
  //# sourceMappingURL=serialize-mdx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serialize-mdx.js","sources":["../../src/parser/serialize-mdx.tsx"],"sourcesContent":["import { compile } from \"@mdx-js/mdx\";\nimport { run } from \"@mdx-js/mdx\";\nimport * as runtime from \"react/jsx-runtime\";\nimport React from \"react\";\nimport remarkGfm from \"remark-gfm\";\nimport { rehypeCodeblocks, remarkHeadingIds } from \"../plugins\";\nimport { defaultComponents } from \"../components\";\n\nexport async function serializeMdx(\n mdxString: string\n): Promise<React.ComponentType> {\n try {\n const compiled = await compile(mdxString, {\n outputFormat: \"function-body\",\n remarkPlugins: [remarkGfm, remarkHeadingIds],\n rehypePlugins: [rehypeCodeblocks],\n });\n\n const compiledMdx = String(compiled);\n\n const { default: Content } = await run(compiledMdx, {\n ...runtime,\n });\n\n return (props) => (\n <Content\n {...props}\n components={{\n ...defaultComponents,\n }}\n />\n );\n } catch (error) {\n console.error(\n \"MDX compilation failed:\",\n error instanceof Error ? error.message : String(error)\n );\n throw error;\n }\n}\n"],"names":["serializeMdx","mdxString","compiled","compile","remarkGfm","remarkHeadingIds","rehypeCodeblocks","compiledMdx","Content","run","runtime","props","jsx","defaultComponents","error"],"mappings":";;;;;;;AAQA,eAAsBA,EACpBC,GAC8B;AAC9B,MAAI;AACF,UAAMC,IAAW,MAAMC,EAAQF,GAAW;AAAA,MACxC,cAAc;AAAA,MACd,eAAe,CAACG,GAAWC,CAAgB;AAAA,MAC3C,eAAe,CAACC,CAAgB;AAAA,IAAA,CACjC,GAEKC,IAAc,OAAOL,CAAQ,GAE7B,EAAE,SAASM,EAAA,IAAY,MAAMC,EAAIF,GAAa;AAAA,MAClD,GAAGG;AAAA,IAAA,CACJ;AAED,WAAO,CAACC,MACN,gBAAAC;AAAA,MAACJ;AAAA,MAAA;AAAA,QACE,GAAGG;AAAA,QACJ,YAAY;AAAA,UACV,GAAGE;AAAA,QAAA;AAAA,MACL;AAAA,IAAA;AAAA,EAGN,SAASC,GAAO;AACd,kBAAQ;AAAA,MACN;AAAA,MACAA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK;AAAA,IAAA,GAEjDA;AAAA,EACR;AACF;"}
1
+ {"version":3,"file":"serialize-mdx.js","sources":["../../src/parser/serialize-mdx.tsx"],"sourcesContent":["import { compile } from \"@mdx-js/mdx\";\nimport { run } from \"@mdx-js/mdx\";\nimport * as runtime from \"react/jsx-runtime\";\nimport React from \"react\";\nimport remarkGfm from \"remark-gfm\";\nimport { rehypeCodeblocks, remarkHeadingIds } from \"../plugins\";\nimport { extractHeadings } from \"../plugins/extract-headings\";\nimport { defaultComponents } from \"../components\";\nimport type { TocItem } from \"../types\";\n\nexport interface SerializeMdxResult {\n Content: React.ComponentType;\n headings: TocItem[];\n}\n\nexport async function serializeMdx(\n mdxString: string\n): Promise<SerializeMdxResult> {\n try {\n const compiled = await compile(mdxString, {\n outputFormat: \"function-body\",\n remarkPlugins: [remarkGfm, remarkHeadingIds, extractHeadings],\n rehypePlugins: [rehypeCodeblocks],\n });\n\n const compiledMdx = String(compiled);\n\n const headings = (compiled.data?.headings as TocItem[]) || [];\n\n const { default: Content } = await run(compiledMdx, {\n ...runtime,\n });\n\n const Component = (props: Record<string, unknown>) => (\n <Content\n {...props}\n components={{\n ...defaultComponents,\n }}\n />\n );\n\n return {\n Content: Component,\n headings,\n };\n } catch (error) {\n console.error(\n \"MDX compilation failed:\",\n error instanceof Error ? error.message : String(error)\n );\n throw error;\n }\n}\n"],"names":["serializeMdx","mdxString","compiled","compile","remarkGfm","remarkHeadingIds","extractHeadings","rehypeCodeblocks","compiledMdx","headings","_a","Content","run","runtime","props","jsx","defaultComponents","error"],"mappings":";;;;;;;;AAeA,eAAsBA,EACpBC,GAC6B;;AAC7B,MAAI;AACF,UAAMC,IAAW,MAAMC,EAAQF,GAAW;AAAA,MACxC,cAAc;AAAA,MACd,eAAe,CAACG,GAAWC,GAAkBC,CAAe;AAAA,MAC5D,eAAe,CAACC,CAAgB;AAAA,IAAA,CACjC,GAEKC,IAAc,OAAON,CAAQ,GAE7BO,MAAYC,IAAAR,EAAS,SAAT,gBAAAQ,EAAe,aAA0B,CAAA,GAErD,EAAE,SAASC,EAAA,IAAY,MAAMC,EAAIJ,GAAa;AAAA,MAClD,GAAGK;AAAA,IAAA,CACJ;AAWD,WAAO;AAAA,MACL,SAVgB,CAACC,MACjB,gBAAAC;AAAA,QAACJ;AAAA,QAAA;AAAA,UACE,GAAGG;AAAA,UACJ,YAAY;AAAA,YACV,GAAGE;AAAA,UAAA;AAAA,QACL;AAAA,MAAA;AAAA,MAMF,UAAAP;AAAA,IAAA;AAAA,EAEJ,SAASQ,GAAO;AACd,kBAAQ;AAAA,MACN;AAAA,MACAA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK;AAAA,IAAA,GAEjDA;AAAA,EACR;AACF;"}
@@ -1,28 +1,34 @@
1
- import { visit as a } from "unist-util-visit";
2
- import o from "@sindresorhus/slugify";
3
- function l(e) {
4
- return e.children.filter((t) => t.type === "text").map((t) => t.value).join("").replace(/\s*\([^)]*\)\s*/g, " ").trim();
1
+ import { visit as l } from "unist-util-visit";
2
+ import g from "@sindresorhus/slugify";
3
+ function p(n) {
4
+ return n.children.filter((t) => t.type === "text").map((t) => t.value).join("").replace(/\s*\([^)]*\)\s*/g, " ").trim();
5
5
  }
6
- function g() {
7
- return (e, n) => {
8
- const i = [];
9
- a(e, "heading", (t) => {
10
- const r = t.depth;
11
- if (r >= 2 && r <= 3) {
12
- const c = l(t), s = o(c.replace(/\./g, "-"));
6
+ function h() {
7
+ return (n, s) => {
8
+ const i = [], t = /* @__PURE__ */ new Map();
9
+ l(n, "heading", (r) => {
10
+ const c = r.depth;
11
+ if (c === 2) {
12
+ const o = p(r);
13
+ let e = g(o.replace(/\./g, "-"));
14
+ if (t.has(e)) {
15
+ const a = t.get(e) + 1;
16
+ t.set(e, a), e = `${e}-${a}`;
17
+ } else
18
+ t.set(e, 1);
13
19
  i.push({
14
- title: c,
15
- slug: s,
16
- level: r
20
+ title: o,
21
+ slug: e,
22
+ level: c
17
23
  });
18
24
  }
19
- }), n.data = {
20
- ...n.data,
25
+ }), s.data = {
26
+ ...s.data,
21
27
  headings: i
22
28
  };
23
29
  };
24
30
  }
25
31
  export {
26
- g as extractHeadings
32
+ h as extractHeadings
27
33
  };
28
34
  //# sourceMappingURL=extract-headings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract-headings.js","sources":["../../src/plugins/extract-headings.ts"],"sourcesContent":["import { visit } from \"unist-util-visit\";\nimport type { Node } from \"unist\";\nimport type { TocItem } from \"../types\";\nimport slugify from \"@sindresorhus/slugify\";\n\nfunction getHeadingText(node: Record<string, unknown>): string {\n const children = node.children as Array<Record<string, unknown>>;\n const text = children\n .filter((child) => child.type === \"text\")\n .map((child) => child.value as string)\n .join(\"\");\n\n return text.replace(/\\s*\\([^)]*\\)\\s*/g, \" \").trim();\n}\n\nexport function extractHeadings() {\n return (tree: Node, file: unknown) => {\n const headings: TocItem[] = [];\n\n visit(tree, \"heading\", (node: Record<string, unknown>) => {\n const depth = node.depth as number;\n if (depth >= 2 && depth <= 3) {\n const text = getHeadingText(node);\n const slug = slugify(text.replace(/\\./g, '-'));\n\n headings.push({\n title: text,\n slug,\n level: depth,\n });\n }\n });\n\n (file as Record<string, unknown>).data = {\n ...((file as Record<string, unknown>).data as Record<string, unknown>),\n headings,\n };\n };\n}\n"],"names":["getHeadingText","node","child","extractHeadings","tree","file","headings","visit","depth","text","slug","slugify"],"mappings":";;AAKA,SAASA,EAAeC,GAAuC;AAO7D,SANiBA,EAAK,SAEnB,OAAO,CAACC,MAAUA,EAAM,SAAS,MAAM,EACvC,IAAI,CAACA,MAAUA,EAAM,KAAe,EACpC,KAAK,EAAE,EAEE,QAAQ,oBAAoB,GAAG,EAAE,KAAA;AAC/C;AAEO,SAASC,IAAkB;AAChC,SAAO,CAACC,GAAYC,MAAkB;AACpC,UAAMC,IAAsB,CAAA;AAE5B,IAAAC,EAAMH,GAAM,WAAW,CAACH,MAAkC;AACxD,YAAMO,IAAQP,EAAK;AACnB,UAAIO,KAAS,KAAKA,KAAS,GAAG;AAC5B,cAAMC,IAAOT,EAAeC,CAAI,GAC1BS,IAAOC,EAAQF,EAAK,QAAQ,OAAO,GAAG,CAAC;AAE7C,QAAAH,EAAS,KAAK;AAAA,UACZ,OAAOG;AAAA,UACP,MAAAC;AAAA,UACA,OAAOF;AAAA,QAAA,CACR;AAAA,MACH;AAAA,IACF,CAAC,GAEAH,EAAiC,OAAO;AAAA,MACvC,GAAKA,EAAiC;AAAA,MACtC,UAAAC;AAAA,IAAA;AAAA,EAEJ;AACF;"}
1
+ {"version":3,"file":"extract-headings.js","sources":["../../src/plugins/extract-headings.ts"],"sourcesContent":["import { visit } from \"unist-util-visit\";\nimport type { Node } from \"unist\";\nimport type { TocItem } from \"../types\";\nimport slugify from \"@sindresorhus/slugify\";\n\nfunction getHeadingText(node: Record<string, unknown>): string {\n const children = node.children as Array<Record<string, unknown>>;\n const text = children\n .filter((child) => child.type === \"text\")\n .map((child) => child.value as string)\n .join(\"\");\n\n return text.replace(/\\s*\\([^)]*\\)\\s*/g, \" \").trim();\n}\n\nexport function extractHeadings() {\n return (tree: Node, file: unknown) => {\n const headings: TocItem[] = [];\n const slugCounts = new Map<string, number>();\n\n visit(tree, \"heading\", (node: Record<string, unknown>) => {\n const depth = node.depth as number;\n if (depth === 2) {\n const text = getHeadingText(node);\n let slug = slugify(text.replace(/\\./g, '-'));\n\n // Handle duplicate slugs by adding a counter\n if (slugCounts.has(slug)) {\n const count = slugCounts.get(slug)! + 1;\n slugCounts.set(slug, count);\n slug = `${slug}-${count}`;\n } else {\n slugCounts.set(slug, 1);\n }\n\n headings.push({\n title: text,\n slug,\n level: depth,\n });\n }\n });\n\n (file as Record<string, unknown>).data = {\n ...((file as Record<string, unknown>).data as Record<string, unknown>),\n headings,\n };\n };\n}\n"],"names":["getHeadingText","node","child","extractHeadings","tree","file","headings","slugCounts","visit","depth","text","slug","slugify","count"],"mappings":";;AAKA,SAASA,EAAeC,GAAuC;AAO7D,SANiBA,EAAK,SAEnB,OAAO,CAACC,MAAUA,EAAM,SAAS,MAAM,EACvC,IAAI,CAACA,MAAUA,EAAM,KAAe,EACpC,KAAK,EAAE,EAEE,QAAQ,oBAAoB,GAAG,EAAE,KAAA;AAC/C;AAEO,SAASC,IAAkB;AAChC,SAAO,CAACC,GAAYC,MAAkB;AACpC,UAAMC,IAAsB,CAAA,GACtBC,wBAAiB,IAAA;AAEvB,IAAAC,EAAMJ,GAAM,WAAW,CAACH,MAAkC;AACxD,YAAMQ,IAAQR,EAAK;AACnB,UAAIQ,MAAU,GAAG;AACf,cAAMC,IAAOV,EAAeC,CAAI;AAChC,YAAIU,IAAOC,EAAQF,EAAK,QAAQ,OAAO,GAAG,CAAC;AAG3C,YAAIH,EAAW,IAAII,CAAI,GAAG;AACxB,gBAAME,IAAQN,EAAW,IAAII,CAAI,IAAK;AACtC,UAAAJ,EAAW,IAAII,GAAME,CAAK,GAC1BF,IAAO,GAAGA,CAAI,IAAIE,CAAK;AAAA,QACzB;AACE,UAAAN,EAAW,IAAII,GAAM,CAAC;AAGxB,QAAAL,EAAS,KAAK;AAAA,UACZ,OAAOI;AAAA,UACP,MAAAC;AAAA,UACA,OAAOF;AAAA,QAAA,CACR;AAAA,MACH;AAAA,IACF,CAAC,GAEAJ,EAAiC,OAAO;AAAA,MACvC,GAAKA,EAAiC;AAAA,MACtC,UAAAC;AAAA,IAAA;AAAA,EAEJ;AACF;"}