@mintlify/common 1.0.1022 → 1.0.1024

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 (39) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/mdx/plugins/remark/remarkMermaid.js +12 -5
  4. package/dist/navigation/decoratedNavigationConfig.d.ts +2 -0
  5. package/dist/navigation/decoratedNavigationConfig.js +204 -0
  6. package/dist/navigation/filterDivisions.d.ts +65 -0
  7. package/dist/navigation/filterDivisions.js +697 -0
  8. package/dist/navigation/filterDivisions.test.d.ts +1 -0
  9. package/dist/navigation/filterDivisions.test.js +670 -0
  10. package/dist/navigation/getScopedNavForPath.test.d.ts +1 -0
  11. package/dist/navigation/getScopedNavForPath.test.js +135 -0
  12. package/dist/navigation/getVersionOrLanguageFromPath.d.ts +12 -0
  13. package/dist/navigation/getVersionOrLanguageFromPath.js +71 -0
  14. package/dist/navigation/getVersionOrLanguageFromPath.test.d.ts +1 -0
  15. package/dist/navigation/getVersionOrLanguageFromPath.test.js +133 -0
  16. package/dist/navigation/index.d.ts +5 -0
  17. package/dist/navigation/index.js +5 -0
  18. package/dist/navigation/isCommonPage.d.ts +8 -0
  19. package/dist/navigation/isCommonPage.js +36 -0
  20. package/dist/navigation/isCommonPage.test.d.ts +1 -0
  21. package/dist/navigation/isCommonPage.test.js +56 -0
  22. package/dist/navigation/pathsDifferByOneSegment.test.d.ts +1 -0
  23. package/dist/navigation/pathsDifferByOneSegment.test.js +91 -0
  24. package/dist/navigation/scopeNavToPath.d.ts +18 -0
  25. package/dist/navigation/scopeNavToPath.js +455 -0
  26. package/dist/navigation/scopeNavToPath.test.d.ts +1 -0
  27. package/dist/navigation/scopeNavToPath.test.js +117 -0
  28. package/dist/navigation/scopeOffPathDivisions.test.d.ts +1 -0
  29. package/dist/navigation/scopeOffPathDivisions.test.js +852 -0
  30. package/dist/navigation/scopeProductNav.test.d.ts +1 -0
  31. package/dist/navigation/scopeProductNav.test.js +288 -0
  32. package/dist/navigation/updateFirstHrefInDivision.d.ts +29 -0
  33. package/dist/navigation/updateFirstHrefInDivision.js +383 -0
  34. package/dist/paths/isEqualIgnoringLeadingSlash.d.ts +1 -0
  35. package/dist/paths/isEqualIgnoringLeadingSlash.js +21 -0
  36. package/dist/paths/isEqualIgnoringLeadingSlash.test.d.ts +1 -0
  37. package/dist/paths/isEqualIgnoringLeadingSlash.test.js +43 -0
  38. package/dist/tsconfig.build.tsbuildinfo +1 -1
  39. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -36,3 +36,4 @@ export * from './validateRedirectUrl.js';
36
36
  export * from './isAllowedRedirectUri.js';
37
37
  export * from './knownMcpClients.js';
38
38
  export * from './live-preview.js';
39
+ export * from './paths/isEqualIgnoringLeadingSlash.js';
package/dist/index.js CHANGED
@@ -36,3 +36,4 @@ export * from './validateRedirectUrl.js';
36
36
  export * from './isAllowedRedirectUri.js';
37
37
  export * from './knownMcpClients.js';
38
38
  export * from './live-preview.js';
39
+ export * from './paths/isEqualIgnoringLeadingSlash.js';
@@ -2,6 +2,8 @@ import { visit } from 'unist-util-visit';
2
2
  import { MetaOptions } from '../rehype/rehypeCodeBlocks/metaOptions.js';
3
3
  const REACT_COMPONENT_NAME = 'Mermaid';
4
4
  const RESERVED_KEYS = ['placement', 'actions'];
5
+ const MERMAID_PLACEMENTS = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
6
+ const DEFAULT_MERMAID_PLACEMENT = 'bottom-right';
5
7
  export const remarkMermaid = () => (tree) => {
6
8
  var _a;
7
9
  const codeblocks = [];
@@ -49,11 +51,16 @@ export const remarkMermaid = () => (tree) => {
49
51
  },
50
52
  ];
51
53
  if (placement) {
52
- attributes.push({
53
- type: 'mdxJsxAttribute',
54
- name: 'placement',
55
- value: placement,
56
- });
54
+ if (MERMAID_PLACEMENTS.includes(placement)) {
55
+ attributes.push({
56
+ type: 'mdxJsxAttribute',
57
+ name: 'placement',
58
+ value: placement,
59
+ });
60
+ }
61
+ else {
62
+ console.warn(`Invalid mermaid placement "${placement}" — expected one of: ${MERMAID_PLACEMENTS.join(', ')}. Falling back to ${DEFAULT_MERMAID_PLACEMENT}.`);
63
+ }
57
64
  }
58
65
  if (actions !== undefined) {
59
66
  attributes.push({
@@ -0,0 +1,2 @@
1
+ import { DecoratedNavigationConfig } from '@mintlify/validation';
2
+ export declare const decoratedNavigationConfig: DecoratedNavigationConfig;
@@ -0,0 +1,204 @@
1
+ export const decoratedNavigationConfig = {
2
+ global: {
3
+ anchors: [
4
+ {
5
+ anchor: 'Documentation',
6
+ href: 'https://mintlify.com/docs',
7
+ icon: 'book-open-cover',
8
+ },
9
+ {
10
+ anchor: 'Community',
11
+ href: 'https://mintlify.com/community',
12
+ icon: 'slack',
13
+ },
14
+ ],
15
+ },
16
+ versions: [
17
+ {
18
+ version: 'v2',
19
+ anchors: [
20
+ {
21
+ anchor: 'Documentation',
22
+ icon: 'book-open',
23
+ tabs: [
24
+ {
25
+ tab: 'Documentation',
26
+ groups: [
27
+ {
28
+ group: 'Get Started',
29
+ pages: [
30
+ {
31
+ title: 'Introduction',
32
+ href: '/introduction',
33
+ },
34
+ {
35
+ title: 'Quickstart',
36
+ href: '/quickstart',
37
+ },
38
+ {
39
+ title: 'Development',
40
+ href: '/development',
41
+ },
42
+ {
43
+ group: 'Editing',
44
+ pages: [
45
+ {
46
+ title: 'Web Editor',
47
+ href: '/web-editor',
48
+ },
49
+ {
50
+ title: 'CLI',
51
+ href: '/cli',
52
+ },
53
+ ],
54
+ },
55
+ ],
56
+ },
57
+ {
58
+ group: 'Essentials',
59
+ pages: [
60
+ {
61
+ title: 'Markdown',
62
+ href: '/essentials/markdown',
63
+ },
64
+ {
65
+ title: 'Code',
66
+ href: '/essentials/code',
67
+ },
68
+ ],
69
+ },
70
+ ],
71
+ },
72
+ {
73
+ tab: 'API Reference',
74
+ groups: [
75
+ {
76
+ group: 'API Documentation',
77
+ pages: [
78
+ {
79
+ title: 'Introduction',
80
+ href: '/api-reference/introduction',
81
+ },
82
+ ],
83
+ },
84
+ {
85
+ group: 'Endpoint Examples',
86
+ pages: [
87
+ {
88
+ title: 'Get API',
89
+ href: '/api-reference/endpoint/get',
90
+ },
91
+ {
92
+ title: 'Create API',
93
+ href: '/api-reference/endpoint/create',
94
+ },
95
+ {
96
+ title: 'Delete API',
97
+ href: '/api-reference/endpoint/delete',
98
+ },
99
+ ],
100
+ },
101
+ ],
102
+ },
103
+ ],
104
+ },
105
+ ],
106
+ },
107
+ {
108
+ version: 'v1',
109
+ anchors: [
110
+ {
111
+ anchor: 'Blog',
112
+ href: 'https://mintlify.com/blog',
113
+ icon: 'newspaper',
114
+ },
115
+ {
116
+ anchor: 'Home',
117
+ icon: 'book-open',
118
+ tabs: [
119
+ {
120
+ tab: 'Documentation',
121
+ groups: [
122
+ {
123
+ group: 'Get Started',
124
+ pages: [
125
+ {
126
+ title: 'Introduction',
127
+ href: '/introduction',
128
+ },
129
+ {
130
+ title: 'Quickstart',
131
+ href: '/quickstart',
132
+ },
133
+ {
134
+ title: 'Development',
135
+ href: '/development',
136
+ },
137
+ ],
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ tab: 'Components',
143
+ groups: [
144
+ {
145
+ group: 'Organization Components',
146
+ pages: [
147
+ {
148
+ title: 'Accordions',
149
+ description: 'A dropdown component for toggling content',
150
+ icon: 'square-caret-down',
151
+ href: '/content/components/accordion',
152
+ },
153
+ {
154
+ title: 'Accordion Group',
155
+ description: 'Group multiple accordions into a single display.',
156
+ icon: 'table-rows',
157
+ href: '/content/components/accordion-group',
158
+ },
159
+ ],
160
+ },
161
+ {
162
+ group: 'Context Components',
163
+ pages: [
164
+ {
165
+ title: 'Callout Boxes',
166
+ description: 'Use callouts to create add eye-catching context to your content',
167
+ icon: 'circle-exclamation',
168
+ href: '/content/components/callouts',
169
+ },
170
+ {
171
+ title: 'Code Blocks',
172
+ description: 'Display code with optional syntax highlighting',
173
+ icon: 'code',
174
+ href: '/content/components/code',
175
+ },
176
+ {
177
+ title: 'Code Groups',
178
+ description: 'The CodeGroup component lets you combine code blocks in a display separated by tabs',
179
+ icon: 'rectangle-code',
180
+ href: '/content/components/code-group',
181
+ },
182
+ ],
183
+ },
184
+ ],
185
+ },
186
+ ],
187
+ },
188
+ ],
189
+ },
190
+ {
191
+ version: 'v0',
192
+ pages: [
193
+ {
194
+ title: 'Hello World',
195
+ href: '/hello-world',
196
+ },
197
+ {
198
+ title: 'Hello World 2',
199
+ href: '/hello-world-2',
200
+ },
201
+ ],
202
+ },
203
+ ],
204
+ };
@@ -0,0 +1,65 @@
1
+ import { LocaleType } from '@mintlify/models';
2
+ import { DecoratedAnchorConfig, DecoratedDropdownConfig, DecoratedLanguageConfig, DecoratedNavigationConfig, DecoratedPageOrGroupConfig, DecoratedTabConfig, DecoratedVersionConfig, DecoratedMenuItemConfig, DecoratedProductConfig } from '@mintlify/validation';
3
+ import { DivisionMatch } from './updateFirstHrefInDivision.js';
4
+ export type FilterDivisionsParams = {
5
+ currentPath: string;
6
+ currentVersion: string | undefined;
7
+ currentLanguage: LocaleType | undefined;
8
+ currentProduct?: string;
9
+ decoratedNav: DecoratedNavigationConfig | DecoratedPageOrGroupConfig | undefined;
10
+ userGroups: Set<string>;
11
+ isPreview?: boolean;
12
+ shouldUseDivisionMatch: boolean;
13
+ cache: {
14
+ dropdownCache: Map<string, string>;
15
+ };
16
+ };
17
+ export type DivisionState = {
18
+ name: string;
19
+ href: string;
20
+ isActive: boolean;
21
+ isGlobal: boolean;
22
+ };
23
+ export declare const isActiveDivision: <T extends object>(item: T) => item is T & {
24
+ isActive: true;
25
+ };
26
+ export type TabsResult = DecoratedTabConfig & DivisionState & {
27
+ menu?: MenuResult[];
28
+ };
29
+ export type AnchorsResult = DecoratedAnchorConfig & DivisionState;
30
+ export type VersionsResult = DecoratedVersionConfig & DivisionState;
31
+ export type LanguagesResult = DecoratedLanguageConfig & DivisionState;
32
+ export type DropdownsResult = DecoratedDropdownConfig & DivisionState;
33
+ export type MenuResult = DecoratedMenuItemConfig & DivisionState;
34
+ export type ProductsResult = DecoratedProductConfig & DivisionState & {
35
+ menu?: MenuResult[];
36
+ };
37
+ export type FilterDivisionsResult = {
38
+ tabs: TabsResult[];
39
+ anchors: AnchorsResult[];
40
+ versions: VersionsResult[];
41
+ languages: LanguagesResult[];
42
+ dropdowns: DropdownsResult[];
43
+ products: ProductsResult[];
44
+ groupsOrPages: DecoratedPageOrGroupConfig[];
45
+ firstHrefInVersion: Map<string | undefined, DivisionMatch>;
46
+ firstHrefInLanguage: Map<LocaleType | undefined, DivisionMatch>;
47
+ };
48
+ export type NavigationDivisions = {
49
+ tabs: Array<TabsResult>;
50
+ anchors: Array<AnchorsResult>;
51
+ versions: Array<VersionsResult>;
52
+ languages: Array<LanguagesResult>;
53
+ dropdowns: Array<DropdownsResult>;
54
+ products: Array<ProductsResult>;
55
+ menu: Array<MenuResult>;
56
+ };
57
+ export declare const filterDivisions: ({ currentPath, currentVersion, currentLanguage, currentProduct, decoratedNav, userGroups, shouldUseDivisionMatch, cache, isPreview, }: FilterDivisionsParams) => FilterDivisionsResult;
58
+ /**
59
+ * TODO: we should add cache for versions and languages in the future
60
+ * Generate a cache key for the dropdowns
61
+ * @param dropdowns - the dropdowns to generate a cache key for
62
+ * @param parentContext - optional parent context to make the key unique across different parent divisions
63
+ * @returns the cache key
64
+ */
65
+ export declare function generateCacheKey<T extends 'dropdowns'>(divisions: T extends 'dropdowns' ? DecoratedDropdownConfig[] : never, parentContext?: string): string;