mintlify 1.2.0 → 1.3.0

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 (183) hide show
  1. package/bin/index.js +0 -2
  2. package/bin/index.js.map +1 -1
  3. package/bin/util.js +40 -1
  4. package/bin/util.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/index.ts +0 -2
  7. package/src/util.ts +54 -1
  8. package/bin/local-preview/categorizeFiles.js +0 -56
  9. package/bin/local-preview/categorizeFiles.js.map +0 -1
  10. package/bin/local-preview/getOpenApiContext.js +0 -46
  11. package/bin/local-preview/getOpenApiContext.js.map +0 -1
  12. package/bin/local-preview/helper-commands/clearCommand.js +0 -27
  13. package/bin/local-preview/helper-commands/clearCommand.js.map +0 -1
  14. package/bin/local-preview/injectFavicons.js +0 -72
  15. package/bin/local-preview/injectFavicons.js.map +0 -1
  16. package/bin/local-preview/injectNav.js +0 -94
  17. package/bin/local-preview/injectNav.js.map +0 -1
  18. package/bin/local-preview/listener.js +0 -112
  19. package/bin/local-preview/listener.js.map +0 -1
  20. package/bin/local-preview/metadata.js +0 -121
  21. package/bin/local-preview/metadata.js.map +0 -1
  22. package/bin/local-preview/mintConfigFile.js +0 -43
  23. package/bin/local-preview/mintConfigFile.js.map +0 -1
  24. package/bin/local-preview/openApiCheck.js +0 -16
  25. package/bin/local-preview/openApiCheck.js.map +0 -1
  26. package/bin/local-preview/slugToTitle.js +0 -8
  27. package/bin/local-preview/slugToTitle.js.map +0 -1
  28. package/bin/mint/client/.babel-plugin-macrosrc.json +0 -5
  29. package/bin/mint/client/.babelrc +0 -4
  30. package/bin/mint/client/.editorconfig +0 -12
  31. package/bin/mint/client/.eslintrc.json +0 -7
  32. package/bin/mint/client/.prettierignore +0 -4
  33. package/bin/mint/client/.prettierrc +0 -14
  34. package/bin/mint/client/.vscode/launch.json +0 -28
  35. package/bin/mint/client/README.md +0 -44
  36. package/bin/mint/client/jest.config.ts +0 -195
  37. package/bin/mint/client/next-env.d.ts +0 -4
  38. package/bin/mint/client/next.config.js +0 -152
  39. package/bin/mint/client/package.json +0 -139
  40. package/bin/mint/client/postcss.config.cjs +0 -9
  41. package/bin/mint/client/prebuild/faviconConfig.js +0 -35
  42. package/bin/mint/client/prebuild/getOpenApiContext.js +0 -53
  43. package/bin/mint/client/prebuild/index.js +0 -117
  44. package/bin/mint/client/prebuild/injectNav.js +0 -115
  45. package/bin/mint/client/prebuild/slugToTitle.js +0 -7
  46. package/bin/mint/client/rehype/withApiComponents.js +0 -60
  47. package/bin/mint/client/rehype/withCodeBlocks.js +0 -54
  48. package/bin/mint/client/rehype/withLayouts.js +0 -113
  49. package/bin/mint/client/rehype/withLinkRoles.js +0 -13
  50. package/bin/mint/client/rehype/withRawComponents.js +0 -13
  51. package/bin/mint/client/rehype/withStaticProps.js +0 -25
  52. package/bin/mint/client/rehype/withSyntaxHighlighting.js +0 -60
  53. package/bin/mint/client/remark/utils.js +0 -369
  54. package/bin/mint/client/remark/withFrames.js +0 -55
  55. package/bin/mint/client/remark/withImportsInjected.js +0 -36
  56. package/bin/mint/client/remark/withNextLinks.js +0 -37
  57. package/bin/mint/client/remark/withTableOfContents.js +0 -71
  58. package/bin/mint/client/scripts/local.js +0 -177
  59. package/bin/mint/client/sentry.client.config.js +0 -15
  60. package/bin/mint/client/sentry.properties +0 -4
  61. package/bin/mint/client/sentry.server.config.js +0 -15
  62. package/bin/mint/client/src/analytics/AbstractAnalyticsImplementation.ts +0 -50
  63. package/bin/mint/client/src/analytics/AnalyticsContext.ts +0 -5
  64. package/bin/mint/client/src/analytics/AnalyticsMediator.ts +0 -101
  65. package/bin/mint/client/src/analytics/FakeAnalyticsMediator.ts +0 -9
  66. package/bin/mint/client/src/analytics/GA4Script.tsx +0 -33
  67. package/bin/mint/client/src/analytics/implementations/amplitude.ts +0 -26
  68. package/bin/mint/client/src/analytics/implementations/fathom.ts +0 -38
  69. package/bin/mint/client/src/analytics/implementations/ga4.ts +0 -33
  70. package/bin/mint/client/src/analytics/implementations/hotjar.ts +0 -53
  71. package/bin/mint/client/src/analytics/implementations/mixpanel-browser.d.ts +0 -1
  72. package/bin/mint/client/src/analytics/implementations/mixpanel.ts +0 -52
  73. package/bin/mint/client/src/analytics/implementations/posthog.ts +0 -37
  74. package/bin/mint/client/src/components/Accordion/Accordion.tsx +0 -43
  75. package/bin/mint/client/src/components/Accordion/index.ts +0 -4
  76. package/bin/mint/client/src/components/ApiExample.tsx +0 -9
  77. package/bin/mint/client/src/components/Card.tsx +0 -51
  78. package/bin/mint/client/src/components/CodeGroup.tsx +0 -132
  79. package/bin/mint/client/src/components/Editor.tsx +0 -12
  80. package/bin/mint/client/src/components/Expandable.tsx +0 -40
  81. package/bin/mint/client/src/components/Heading.tsx +0 -84
  82. package/bin/mint/client/src/components/Param.tsx +0 -56
  83. package/bin/mint/client/src/components/Request.tsx +0 -19
  84. package/bin/mint/client/src/components/ResponseField.tsx +0 -33
  85. package/bin/mint/client/src/components/TabBar.tsx +0 -61
  86. package/bin/mint/client/src/config.ts +0 -115
  87. package/bin/mint/client/src/css/bar-of-progress.css +0 -10
  88. package/bin/mint/client/src/css/base.css +0 -29
  89. package/bin/mint/client/src/css/font-awesome.css +0 -7
  90. package/bin/mint/client/src/css/fonts.css +0 -44
  91. package/bin/mint/client/src/css/main.css +0 -11
  92. package/bin/mint/client/src/css/prism.css +0 -270
  93. package/bin/mint/client/src/css/utilities.css +0 -43
  94. package/bin/mint/client/src/enums/components.ts +0 -8
  95. package/bin/mint/client/src/fonts/FiraCode-VF.woff +0 -0
  96. package/bin/mint/client/src/fonts/FiraCode-VF.woff2 +0 -0
  97. package/bin/mint/client/src/fonts/IBMPlexMono-Regular.ttf +0 -0
  98. package/bin/mint/client/src/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  99. package/bin/mint/client/src/fonts/Inter-italic-latin.var.woff2 +0 -0
  100. package/bin/mint/client/src/fonts/Inter-roman-latin.var.woff2 +0 -0
  101. package/bin/mint/client/src/fonts/Pally-Variable.ttf +0 -0
  102. package/bin/mint/client/src/fonts/SourceSansPro-Regular.otf +0 -0
  103. package/bin/mint/client/src/fonts/SourceSerifPro-Regular.ttf +0 -0
  104. package/bin/mint/client/src/fonts/Synonym-Variable.ttf +0 -0
  105. package/bin/mint/client/src/fonts/Ubuntu-Mono-bold.woff2 +0 -0
  106. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.woff2 +0 -0
  107. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.zopfli.woff +0 -0
  108. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular.module.css +0 -11
  109. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.woff2 +0 -0
  110. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.zopfli.woff +0 -0
  111. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold.module.css +0 -11
  112. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.woff2 +0 -0
  113. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.zopfli.woff +0 -0
  114. package/bin/mint/client/src/fonts/generated/Pally-Variable.module.css +0 -11
  115. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.woff2 +0 -0
  116. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.zopfli.woff +0 -0
  117. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular.module.css +0 -11
  118. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.woff2 +0 -0
  119. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.zopfli.woff +0 -0
  120. package/bin/mint/client/src/fonts/generated/Synonym-Variable.module.css +0 -11
  121. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.woff2 +0 -0
  122. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.zopfli.woff +0 -0
  123. package/bin/mint/client/src/fonts/generated/TenorSans-Regular.module.css +0 -11
  124. package/bin/mint/client/src/hooks/useActionKey.ts +0 -20
  125. package/bin/mint/client/src/hooks/useIsomorphicLayoutEffect.ts +0 -3
  126. package/bin/mint/client/src/hooks/useMedia.ts +0 -27
  127. package/bin/mint/client/src/hooks/usePrevNext.ts +0 -34
  128. package/bin/mint/client/src/hooks/useTop.ts +0 -15
  129. package/bin/mint/client/src/icons/CopyToClipboard.tsx +0 -33
  130. package/bin/mint/client/src/index.d.ts +0 -1
  131. package/bin/mint/client/src/layouts/ApiSupplemental.tsx +0 -173
  132. package/bin/mint/client/src/layouts/ContentsLayout.tsx +0 -256
  133. package/bin/mint/client/src/layouts/DocumentationLayout.tsx +0 -44
  134. package/bin/mint/client/src/layouts/OpenApiContent.tsx +0 -301
  135. package/bin/mint/client/src/layouts/SidebarLayout.tsx +0 -412
  136. package/bin/mint/client/src/layouts/UserFeedback.tsx +0 -73
  137. package/bin/mint/client/src/layouts/getGroupsInDivision.ts +0 -25
  138. package/bin/mint/client/src/layouts/isPathInGroupPages.ts +0 -10
  139. package/bin/mint/client/src/metadata.ts +0 -58
  140. package/bin/mint/client/src/nav.json +0 -219
  141. package/bin/mint/client/src/openapi.ts +0 -3
  142. package/bin/mint/client/src/pages/404.tsx +0 -73
  143. package/bin/mint/client/src/pages/_app.tsx +0 -138
  144. package/bin/mint/client/src/pages/_document.tsx +0 -57
  145. package/bin/mint/client/src/pages/api/issue.ts +0 -10
  146. package/bin/mint/client/src/pages/api/name.ts +0 -8
  147. package/bin/mint/client/src/pages/api/request.ts +0 -31
  148. package/bin/mint/client/src/pages/api/suggest.ts +0 -10
  149. package/bin/mint/client/src/pages/api/syntax-highlighted-json.ts +0 -13
  150. package/bin/mint/client/src/pages/api/utils.ts +0 -6
  151. package/bin/mint/client/src/pages/index.tsx +0 -31
  152. package/bin/mint/client/src/ui/Api.tsx +0 -359
  153. package/bin/mint/client/src/ui/Footer.tsx +0 -124
  154. package/bin/mint/client/src/ui/Header.tsx +0 -370
  155. package/bin/mint/client/src/ui/Logo.tsx +0 -55
  156. package/bin/mint/client/src/ui/PageHeader.tsx +0 -51
  157. package/bin/mint/client/src/ui/Search.tsx +0 -386
  158. package/bin/mint/client/src/ui/ThemeToggle.tsx +0 -285
  159. package/bin/mint/client/src/ui/Title.tsx +0 -22
  160. package/bin/mint/client/src/ui/TopLevelLink.tsx +0 -122
  161. package/bin/mint/client/src/utils/api.ts +0 -252
  162. package/bin/mint/client/src/utils/brands.ts +0 -217
  163. package/bin/mint/client/src/utils/castArray.ts +0 -3
  164. package/bin/mint/client/src/utils/childrenArray.ts +0 -3
  165. package/bin/mint/client/src/utils/fit.ts +0 -27
  166. package/bin/mint/client/src/utils/fontAwesome.ts +0 -577
  167. package/bin/mint/client/src/utils/getAnalyticsConfig.ts +0 -14
  168. package/bin/mint/client/src/utils/getLogoHref.ts +0 -9
  169. package/bin/mint/client/src/utils/getOpenApiContext.ts +0 -26
  170. package/bin/mint/client/src/utils/importAll.ts +0 -6
  171. package/bin/mint/client/src/utils/isObject.ts +0 -3
  172. package/bin/mint/client/src/utils/kebabToTitleCase.ts +0 -3
  173. package/bin/mint/client/src/utils/loadImage.ts +0 -8
  174. package/bin/mint/client/src/utils/slugToTitle.ts +0 -7
  175. package/bin/mint/client/src/utils/wait.ts +0 -5
  176. package/bin/mint/client/tailwind.config.cjs +0 -323
  177. package/bin/mint/client/test/test.test.ts +0 -5
  178. package/bin/mint/client/tsconfig.json +0 -36
  179. package/bin/mint/client/yarn.lock +0 -9702
  180. package/bin/scraping/site-scrapers/getLinksRecursively.js +0 -38
  181. package/bin/scraping/site-scrapers/getLinksRecursively.js.map +0 -1
  182. package/src/init-command/index.ts +0 -59
  183. package/src/init-command/templates.ts +0 -52
@@ -1,369 +0,0 @@
1
- import * as acorn from 'acorn';
2
- import { fromMarkdown } from 'mdast-util-from-markdown';
3
- import { mdxJsxFromMarkdown } from 'mdast-util-mdx-jsx';
4
- import { mdxjsEsmFromMarkdown } from 'mdast-util-mdxjs-esm';
5
- import { mdxJsx } from 'micromark-extension-mdx-jsx';
6
- import { mdxjsEsm } from 'micromark-extension-mdxjs-esm';
7
- import Prism from 'prismjs';
8
- import loadLanguages from 'prismjs/components/index.js';
9
- import redent from 'redent';
10
-
11
- loadLanguages();
12
-
13
- const HTML_TAG =
14
- /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/gi;
15
- const PSEUDO_CLASSES = [
16
- 'active',
17
- 'any-link',
18
- 'blank',
19
- 'checked',
20
- 'current',
21
- 'default',
22
- 'defined',
23
- 'dir',
24
- 'disabled',
25
- 'drop',
26
- 'empty',
27
- 'enabled',
28
- 'first',
29
- 'first-child',
30
- 'first-of-type',
31
- 'fullscreen',
32
- 'future',
33
- 'focus',
34
- 'focus-visible',
35
- 'focus-within',
36
- 'has',
37
- 'host',
38
- 'host',
39
- 'host-context',
40
- 'hover',
41
- 'indeterminate',
42
- 'in-range',
43
- 'invalid',
44
- 'is',
45
- 'lang',
46
- 'last-child',
47
- 'last-of-type',
48
- 'left',
49
- 'link',
50
- 'local-link',
51
- 'not',
52
- 'nth-child',
53
- 'nth-col',
54
- 'nth-last-child',
55
- 'nth-last-col',
56
- 'nth-last-of-type',
57
- 'nth-of-type',
58
- 'only-child',
59
- 'only-of-type',
60
- 'optional',
61
- 'out-of-range',
62
- 'past',
63
- 'picture-in-picture',
64
- 'placeholder-shown',
65
- 'read-only',
66
- 'read-write',
67
- 'required',
68
- 'right',
69
- 'root',
70
- 'scope',
71
- 'state',
72
- 'target',
73
- 'target-within',
74
- 'user-invalid',
75
- 'valid',
76
- 'visited',
77
- 'where',
78
- ];
79
-
80
- Prism.hooks.add('wrap', (env) => {
81
- if (env.type === 'atrule') {
82
- const content = env.content.replace(HTML_TAG, '');
83
- if (content.startsWith('@apply')) {
84
- env.classes.push('atapply');
85
- }
86
- } else if (env.type === 'pseudo-class') {
87
- if (!new RegExp(`^::?(${PSEUDO_CLASSES.join('|')})`).test(env.content)) {
88
- env.classes = env.classes.filter((x) => x !== 'pseudo-class');
89
- }
90
- }
91
- });
92
-
93
- Prism.hooks.add('after-tokenize', ({ language, tokens }) => {
94
- if (language === 'css') {
95
- fixSelectorEscapeTokens(tokens);
96
- }
97
- });
98
-
99
- export function fixSelectorEscapeTokens(tokens) {
100
- for (let token of tokens) {
101
- if (typeof token === 'string') continue;
102
- if (token.type !== 'selector') continue;
103
- for (let i = 0; i < token.content.length; i++) {
104
- if (token.content[i] === '\\' && token.content[i - 1]?.type === 'class') {
105
- token.content[i] = new Prism.Token('punctuation', token.content[i]);
106
- token.content[i + 1].type = 'class';
107
- }
108
- }
109
- }
110
- }
111
-
112
- export const createMdxJsxAttribute = (key, value) => {
113
- return {
114
- type: 'mdxJsxAttribute',
115
- name: key,
116
- value,
117
- };
118
- };
119
-
120
- export const tomdxJsxFlowElement = (input) => {
121
- const tree = fromMarkdown(input, {
122
- extensions: [mdxJsx({ acorn: acorn, addResult: true })],
123
- mdastExtensions: [mdxJsxFromMarkdown()],
124
- });
125
- return tree.children[0];
126
- };
127
-
128
- export const getEsmNode = (input) => {
129
- const tree = fromMarkdown(input, {
130
- extensions: [mdxjsEsm({ acorn, addResult: true })],
131
- mdastExtensions: [mdxjsEsmFromMarkdown],
132
- });
133
- return tree.children[0];
134
- };
135
-
136
- export function addImportString(tree, jsx) {
137
- tree.children.unshift(getEsmNode(jsx));
138
- }
139
-
140
- export function addImport(tree, mod, name) {
141
- const jsx = `import { ${name} as _${name} } from '${mod}'`;
142
- tree.children.unshift(getEsmNode(jsx));
143
- return `_${name}`;
144
- }
145
-
146
- export function addDefaultImport(tree, mod, name) {
147
- const jsx = `import _${name} from '${mod}'`;
148
- tree.children.unshift(getEsmNode(jsx));
149
- return `_${name}`;
150
- }
151
-
152
- export function addExport(tree, name, value) {
153
- const jsx = `export const ${name} = ${JSON.stringify(value)}`;
154
- tree.children.push(getEsmNode(jsx));
155
- }
156
-
157
- function hasLineHighlights(code) {
158
- return code.split('\n').some((line) => line === '' || /^[> ] /.test(line));
159
- }
160
-
161
- export function highlightCode(code, prismLanguage) {
162
- const isDiff = prismLanguage.startsWith('diff-');
163
- const language = isDiff ? prismLanguage.substr(5) : prismLanguage;
164
- const grammar = Prism.languages[language];
165
- if (!grammar) {
166
- console.warn(`Unrecognised language: ${prismLanguage}`);
167
- return Prism.util.encode(code);
168
- }
169
-
170
- let addedLines = [];
171
- let removedLines = [];
172
- if (isDiff) {
173
- code = code.replace(/(?:^[+\- ] |^[+-]$)/gm, (match, offset) => {
174
- let line = code.substr(0, offset).split('\n').length - 1;
175
- if (match.startsWith('+')) {
176
- addedLines.push(line);
177
- } else if (match.startsWith('-')) {
178
- removedLines.push(line);
179
- }
180
- return '';
181
- });
182
- }
183
-
184
- let highlightedLines = [];
185
-
186
- if (hasLineHighlights(code)) {
187
- let match;
188
- let re = /^>/m;
189
- while ((match = re.exec(code)) !== null) {
190
- let line = code.substr(0, match.index).split('\n').length - 1;
191
- highlightedLines.push(line);
192
- code = code.substr(0, match.index) + ' ' + code.substr(match.index + 1);
193
- }
194
- code = redent(code);
195
- }
196
-
197
- function stringify(line, className) {
198
- let empty = line.every((token) => token.empty);
199
-
200
- if (!className && empty) {
201
- return '\n';
202
- }
203
-
204
- let commonTypes = [];
205
- for (let i = 0; i < line.length; i++) {
206
- let token = line[i];
207
- if (i === 0) {
208
- commonTypes.push(...token.types);
209
- } else {
210
- commonTypes = commonTypes.filter((type) => token.types.includes(type));
211
- }
212
- }
213
- if (commonTypes.length) {
214
- for (let i = 0; i < line.length; i++) {
215
- let token = line[i];
216
- token.types = token.types.filter((type) => !commonTypes.includes(type));
217
- }
218
- }
219
-
220
- let lineClassName = ['token', ...commonTypes, className].filter(Boolean).join(' ');
221
-
222
- if (empty) {
223
- return `<span class="${lineClassName}">\n</span>`;
224
- }
225
-
226
- return `<span class="${lineClassName}">${line
227
- .map((token) =>
228
- token.types.length
229
- ? `<span class="token ${token.types.join(' ')}">${token.content}</span>`
230
- : token.content
231
- )
232
- .join('')}\n</span>`;
233
- }
234
-
235
- if (highlightedLines.length && language !== 'demo') {
236
- let lines = normalizeTokens(Prism.util.encode(Prism.tokenize(code, grammar)));
237
-
238
- code = lines
239
- .map((line, index) =>
240
- stringify(
241
- line,
242
- `block${
243
- highlightedLines.includes(index)
244
- ? ' -mx-5 pr-5 border-l-4 border-primary-light bg-primary-light/[0.15]'
245
- : ''
246
- }`
247
- )
248
- )
249
- .join('');
250
- } else {
251
- code = Prism.highlight(code, grammar, prismLanguage);
252
- }
253
-
254
- return language === 'html'
255
- ? code.replace(
256
- /\*\*(.*?)\*\*/g,
257
- (_, text) => `<span class="code-highlight bg-code-highlight">${text}</span>`
258
- )
259
- : code;
260
- }
261
-
262
- // https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/utils/normalizeTokens.js
263
-
264
- const newlineRe = /\r\n|\r|\n/;
265
-
266
- // Empty lines need to contain a single empty token, denoted with { empty: true }
267
- function normalizeEmptyLines(line) {
268
- if (line.length === 0) {
269
- line.push({
270
- types: ['plain'],
271
- content: '',
272
- empty: true,
273
- });
274
- } else if (line.length === 1 && line[0].content === '') {
275
- line[0].empty = true;
276
- }
277
- }
278
-
279
- function appendTypes(types, add) {
280
- const typesSize = types.length;
281
- if (typesSize > 0 && types[typesSize - 1] === add) {
282
- return types;
283
- }
284
-
285
- return types.concat(add);
286
- }
287
-
288
- // Takes an array of Prism's tokens and groups them by line, turning plain
289
- // strings into tokens as well. Tokens can become recursive in some cases,
290
- // which means that their types are concatenated. Plain-string tokens however
291
- // are always of type "plain".
292
- // This is not recursive to avoid exceeding the call-stack limit, since it's unclear
293
- // how nested Prism's tokens can become
294
- export function normalizeTokens(tokens) {
295
- const typeArrStack = [[]];
296
- const tokenArrStack = [tokens];
297
- const tokenArrIndexStack = [0];
298
- const tokenArrSizeStack = [tokens.length];
299
-
300
- let i = 0;
301
- let stackIndex = 0;
302
- let currentLine = [];
303
-
304
- const acc = [currentLine];
305
-
306
- while (stackIndex > -1) {
307
- while ((i = tokenArrIndexStack[stackIndex]++) < tokenArrSizeStack[stackIndex]) {
308
- let content;
309
- let types = typeArrStack[stackIndex];
310
-
311
- const tokenArr = tokenArrStack[stackIndex];
312
- const token = tokenArr[i];
313
-
314
- // Determine content and append type to types if necessary
315
- if (typeof token === 'string') {
316
- types = stackIndex > 0 ? types : ['plain'];
317
- content = token;
318
- } else {
319
- types = appendTypes(types, token.type);
320
- if (token.alias) {
321
- types = appendTypes(types, token.alias);
322
- }
323
-
324
- content = token.content;
325
- }
326
-
327
- // If token.content is an array, increase the stack depth and repeat this while-loop
328
- if (typeof content !== 'string') {
329
- stackIndex++;
330
- typeArrStack.push(types);
331
- tokenArrStack.push(content);
332
- tokenArrIndexStack.push(0);
333
- tokenArrSizeStack.push(content.length);
334
- continue;
335
- }
336
-
337
- // Split by newlines
338
- const splitByNewlines = content.split(newlineRe);
339
- const newlineCount = splitByNewlines.length;
340
-
341
- currentLine.push({ types, content: splitByNewlines[0] });
342
-
343
- // Create a new line for each string on a new line
344
- for (let i = 1; i < newlineCount; i++) {
345
- normalizeEmptyLines(currentLine);
346
- acc.push((currentLine = []));
347
- currentLine.push({ types, content: splitByNewlines[i] });
348
- }
349
- }
350
-
351
- // Decreate the stack depth
352
- stackIndex--;
353
- typeArrStack.pop();
354
- tokenArrStack.pop();
355
- tokenArrIndexStack.pop();
356
- tokenArrSizeStack.pop();
357
- }
358
-
359
- normalizeEmptyLines(currentLine);
360
- return acc;
361
- }
362
-
363
- export function simplifyToken(token) {
364
- if (typeof token === 'string') return token;
365
- return [
366
- token.type,
367
- Array.isArray(token.content) ? token.content.map(simplifyToken) : token.content,
368
- ];
369
- }
@@ -1,55 +0,0 @@
1
- import { addImport, tomdxJsxFlowElement } from './utils.js';
2
-
3
- const withFrames = () => {
4
- return (tree) => {
5
- let preTree = { children: [] };
6
- let componentName;
7
-
8
- tree.children = tree.children.map((node, index) => {
9
- // Start of horizontal block: -- block
10
- if (
11
- node.type === 'paragraph' &&
12
- node.children.length === 1 &&
13
- node.children[0].value === '-- block'
14
- ) {
15
- node.type = 'jsx';
16
- node.value = `<div className='grid md:grid-cols-2 md:gap-8'><div>`;
17
- }
18
-
19
- // Start a new column: -- column
20
- if (
21
- node.type === 'paragraph' &&
22
- node.children.length === 1 &&
23
- node.children[0].value === '-- column'
24
- ) {
25
- node.type = 'jsx';
26
- node.value = `</div><div>`;
27
- }
28
-
29
- // End of horizontal block: -- /block
30
- if (
31
- node.type === 'paragraph' &&
32
- node.children.length === 1 &&
33
- node.children[0].value === '-- /block'
34
- ) {
35
- node.type = 'jsx';
36
- node.value = `</div></div>`;
37
- }
38
-
39
- if (node.type === 'mdxJsxFlowElement' && (node.name === 'Example' || node.name === 'Frame')) {
40
- if (!componentName) {
41
- componentName = addImport(preTree, '@mintlify/components', 'Frame');
42
- }
43
- node.name = componentName;
44
- }
45
- if (node.type === 'jsx') {
46
- node = tomdxJsxFlowElement(node.value);
47
- }
48
- return node;
49
- });
50
-
51
- tree.children = [...preTree.children, ...tree.children];
52
- };
53
- };
54
-
55
- export default withFrames;
@@ -1,36 +0,0 @@
1
- import { addImportString } from './utils.js';
2
-
3
- const imports = `
4
- import { Accordion, AccordionGroup } from '@/components/Accordion'
5
- import { Heading } from '@/components/Heading'
6
- import { CodeGroup, SnippetGroup } from '@/components/CodeGroup'
7
- import { RequestSimple } from '@/components/Request'
8
- import { RequestExample, ResponseExample } from '@/components/ApiExample'
9
- import { Param, ParamField } from '@/components/Param'
10
- import { Card } from '@/components/Card'
11
- import { ResponseField } from '@/components/ResponseField'
12
- import { Expandable } from '@/components/Expandable'
13
- import { CardGroup, Info, Warning, Note, Tip, Check } from '@mintlify/components'
14
- import { Tabs, Tab } from '@mintlify/components'
15
- import { Tooltip } from '@mintlify/components'
16
- import { solid, regular, light, thin, duotone, brands } from '@fortawesome/fontawesome-svg-core/import.macro'
17
- `;
18
-
19
- const withImportsInjected = () => {
20
- return (tree) => {
21
- tree.children = tree.children.filter((node) => {
22
- return (
23
- (node.type === 'import' && !node.value?.includes('@/components/')) || node.type !== 'import'
24
- );
25
- });
26
-
27
- imports
28
- .trim()
29
- .split('\n')
30
- .forEach((importLine) => {
31
- addImportString(tree, importLine);
32
- });
33
- };
34
- };
35
-
36
- export default withImportsInjected;
@@ -1,37 +0,0 @@
1
- import { addDefaultImport, tomdxJsxFlowElement } from './utils.js';
2
-
3
- const isAbsoluteUrl = (str) => /^[a-z][a-z0-9+.-]*:/.test(str);
4
-
5
- const withNextLinks = () => {
6
- return (tree) => {
7
- const component = addDefaultImport(tree, 'next/link', 'Link');
8
- function walk(root) {
9
- if (!root.children) return;
10
- let i = 0;
11
- while (i < root.children.length) {
12
- let node = root.children[i];
13
- if (node.type === 'link' && isAbsoluteUrl(node.url)) {
14
- const link = `<${component} href="${node.url}" passHref><a target="_blank">${node.children[0].value}</a></${component}>`;
15
- root.children[i] = {
16
- ...root.children[i],
17
- ...tomdxJsxFlowElement(link),
18
- type: 'mdxJsxFlowElement',
19
- };
20
- } else if (node.type === 'link') {
21
- // Is relative url path
22
- const link = `<${component} href="${node.url}" passHref><a>${node.children[0].value}</a></${component}>`;
23
- root.children[i] = {
24
- ...root.children[i],
25
- ...tomdxJsxFlowElement(link),
26
- type: 'mdxJsxFlowElement',
27
- };
28
- }
29
- walk(root.children[i]);
30
- i += 1;
31
- }
32
- }
33
- walk(tree);
34
- };
35
- };
36
-
37
- export default withNextLinks;
@@ -1,71 +0,0 @@
1
- import slugify from '@sindresorhus/slugify';
2
-
3
- import { addImport, addExport, createMdxJsxAttribute } from './utils.js';
4
-
5
- const withTableOfContents = () => {
6
- return (tree) => {
7
- const component = addImport(tree, '@/components/Heading', 'Heading');
8
- const contents = [];
9
- let hasTopLayer = false;
10
- for (let nodeIndex = 0; nodeIndex < tree.children.length; nodeIndex++) {
11
- let node = tree.children[nodeIndex];
12
-
13
- if (node.type === 'heading' && [1, 2, 3, 4].includes(node.depth)) {
14
- let level = node.depth;
15
- let title = node.children
16
- .filter(
17
- (node, i, a) =>
18
- (node.type === 'text' &&
19
- (a[i - 1]?.type !== 'mdxJsxFlowElement' ||
20
- !a[i - 1]?.value.startsWith('<small'))) ||
21
- node.type === 'inlineCode'
22
- )
23
- .map((node) => node.value)
24
- .join('');
25
- let slug = slugify(title);
26
-
27
- // if a header with the exact same title shows up - make the slug unique
28
- let allOtherSlugs = contents.flatMap((entry) => [
29
- entry.slug,
30
- ...entry.children?.map(({ slug }) => slug),
31
- ]);
32
- let slugIndex = 1;
33
- while (allOtherSlugs.indexOf(slug) > -1) {
34
- slug = `${slugify(title)}-${slugIndex}`;
35
- slugIndex++;
36
- }
37
-
38
- let mdxJsxAttributes = [
39
- createMdxJsxAttribute('level', level),
40
- createMdxJsxAttribute('id', slug),
41
- ];
42
-
43
- if (tree.children[nodeIndex + 1]) {
44
- let { children, position, value, ...element } = tree.children[nodeIndex + 1];
45
- if (typeof element?.depth !== 'undefined') {
46
- mdxJsxAttributes.push(createMdxJsxAttribute('nextElementDepth', element.depth));
47
- }
48
- }
49
-
50
- node.attributes = mdxJsxAttributes;
51
- node.type = 'mdxJsxFlowElement';
52
- node.name = component;
53
- const depth = node.depth;
54
- if (level <= 2) {
55
- hasTopLayer = true;
56
- contents.push({ title, slug, depth, children: [] });
57
- } else {
58
- // Account if there is no first layer
59
- let arrToPushInto = contents;
60
- if (hasTopLayer) {
61
- arrToPushInto = contents[contents.length - 1].children;
62
- }
63
- arrToPushInto.push({ title, slug, depth, children: [] });
64
- }
65
- }
66
- }
67
- addExport(tree, 'tableOfContents', contents);
68
- };
69
- };
70
-
71
- export default withTableOfContents;