mintlify 1.0.6 → 1.0.8

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 (286) hide show
  1. package/README.md +27 -3
  2. package/bin/browser.js +24 -0
  3. package/bin/browser.js.map +1 -0
  4. package/bin/constants.js +8 -0
  5. package/bin/constants.js.map +1 -0
  6. package/bin/dev/getOpenApiContext.js +46 -0
  7. package/bin/dev/getOpenApiContext.js.map +1 -0
  8. package/bin/dev/index.js +164 -0
  9. package/bin/dev/index.js.map +1 -0
  10. package/bin/dev/injectNav.js +97 -0
  11. package/bin/dev/injectNav.js.map +1 -0
  12. package/bin/dev/slugToTitle.js +8 -0
  13. package/bin/dev/slugToTitle.js.map +1 -0
  14. package/bin/downloadImage.js +27 -0
  15. package/bin/downloadImage.js.map +1 -0
  16. package/bin/index.js +49 -106
  17. package/bin/index.js.map +1 -1
  18. package/bin/init-command/index.js +51 -0
  19. package/bin/init-command/index.js.map +1 -0
  20. package/bin/init-command/templates.js +41 -0
  21. package/bin/init-command/templates.js.map +1 -0
  22. package/bin/local-preview/categorizeFiles.js +56 -0
  23. package/bin/local-preview/categorizeFiles.js.map +1 -0
  24. package/bin/local-preview/getOpenApiContext.js +46 -0
  25. package/bin/local-preview/getOpenApiContext.js.map +1 -0
  26. package/bin/local-preview/index.js +138 -0
  27. package/bin/local-preview/index.js.map +1 -0
  28. package/bin/local-preview/injectFavicons.js +72 -0
  29. package/bin/local-preview/injectFavicons.js.map +1 -0
  30. package/bin/local-preview/listener.js +112 -0
  31. package/bin/local-preview/listener.js.map +1 -0
  32. package/bin/local-preview/metadata.js +121 -0
  33. package/bin/local-preview/metadata.js.map +1 -0
  34. package/bin/local-preview/mintConfigFile.js +43 -0
  35. package/bin/local-preview/mintConfigFile.js.map +1 -0
  36. package/bin/local-preview/openApiCheck.js +16 -0
  37. package/bin/local-preview/openApiCheck.js.map +1 -0
  38. package/bin/local-preview/slugToTitle.js +8 -0
  39. package/bin/local-preview/slugToTitle.js.map +1 -0
  40. package/bin/mint/client/.babel-plugin-macrosrc.json +5 -0
  41. package/bin/mint/client/.babelrc +4 -0
  42. package/bin/mint/client/.editorconfig +12 -0
  43. package/bin/mint/client/.eslintrc.json +7 -0
  44. package/bin/mint/client/.prettierignore +4 -0
  45. package/bin/mint/client/.prettierrc +14 -0
  46. package/bin/mint/client/.vscode/launch.json +28 -0
  47. package/bin/mint/client/README.md +46 -0
  48. package/bin/mint/client/jest.config.ts +195 -0
  49. package/bin/mint/client/next-env.d.ts +4 -0
  50. package/bin/mint/client/next.config.js +152 -0
  51. package/bin/mint/client/package.json +140 -0
  52. package/bin/mint/client/postcss.config.cjs +9 -0
  53. package/bin/mint/client/prebuild/faviconConfig.js +35 -0
  54. package/bin/mint/client/prebuild/getOpenApiContext.js +53 -0
  55. package/bin/mint/client/prebuild/index.js +117 -0
  56. package/bin/mint/client/prebuild/injectNav.js +115 -0
  57. package/bin/mint/client/prebuild/slugToTitle.js +7 -0
  58. package/bin/mint/client/rehype/withApiComponents.js +60 -0
  59. package/bin/mint/client/rehype/withCodeBlocks.js +54 -0
  60. package/bin/mint/client/rehype/withLayouts.js +113 -0
  61. package/bin/mint/client/rehype/withLinkRoles.js +13 -0
  62. package/bin/mint/client/rehype/withRawComponents.js +13 -0
  63. package/bin/mint/client/rehype/withStaticProps.js +25 -0
  64. package/bin/mint/client/rehype/withSyntaxHighlighting.js +60 -0
  65. package/bin/mint/client/remark/utils.js +369 -0
  66. package/bin/mint/client/remark/withFrames.js +55 -0
  67. package/bin/mint/client/remark/withImportsInjected.js +36 -0
  68. package/bin/mint/client/remark/withNextLinks.js +37 -0
  69. package/bin/mint/client/remark/withTableOfContents.js +71 -0
  70. package/bin/mint/client/scripts/local-to-docs.js +72 -0
  71. package/bin/mint/client/scripts/local.js +177 -0
  72. package/bin/mint/client/sentry.client.config.js +15 -0
  73. package/bin/mint/client/sentry.properties +4 -0
  74. package/bin/mint/client/sentry.server.config.js +15 -0
  75. package/bin/mint/client/src/analytics/AbstractAnalyticsImplementation.ts +50 -0
  76. package/bin/mint/client/src/analytics/AnalyticsContext.ts +5 -0
  77. package/bin/mint/client/src/analytics/AnalyticsMediator.ts +101 -0
  78. package/bin/mint/client/src/analytics/FakeAnalyticsMediator.ts +9 -0
  79. package/bin/mint/client/src/analytics/GA4Script.tsx +33 -0
  80. package/bin/mint/client/src/analytics/implementations/amplitude.ts +26 -0
  81. package/bin/mint/client/src/analytics/implementations/fathom.ts +38 -0
  82. package/bin/mint/client/src/analytics/implementations/ga4.ts +33 -0
  83. package/bin/mint/client/src/analytics/implementations/hotjar.ts +53 -0
  84. package/bin/mint/client/src/analytics/implementations/mixpanel-browser.d.ts +1 -0
  85. package/bin/mint/client/src/analytics/implementations/mixpanel.ts +52 -0
  86. package/bin/mint/client/src/analytics/implementations/posthog.ts +37 -0
  87. package/bin/mint/client/src/components/Accordion/Accordion.tsx +43 -0
  88. package/bin/mint/client/src/components/Accordion/index.ts +4 -0
  89. package/bin/mint/client/src/components/ApiExample.tsx +9 -0
  90. package/bin/mint/client/src/components/Card.tsx +51 -0
  91. package/bin/mint/client/src/components/CodeGroup.tsx +132 -0
  92. package/bin/mint/client/src/components/Editor.tsx +12 -0
  93. package/bin/mint/client/src/components/Expandable.tsx +40 -0
  94. package/bin/mint/client/src/components/Heading.tsx +84 -0
  95. package/bin/mint/client/src/components/Param.tsx +56 -0
  96. package/bin/mint/client/src/components/Request.tsx +19 -0
  97. package/bin/mint/client/src/components/ResponseField.tsx +33 -0
  98. package/bin/mint/client/src/components/TabBar.tsx +61 -0
  99. package/bin/mint/client/src/config.ts +115 -0
  100. package/bin/mint/client/src/css/bar-of-progress.css +10 -0
  101. package/bin/mint/client/src/css/base.css +29 -0
  102. package/bin/mint/client/src/css/font-awesome.css +7 -0
  103. package/bin/mint/client/src/css/fonts.css +44 -0
  104. package/bin/mint/client/src/css/main.css +11 -0
  105. package/bin/mint/client/src/css/prism.css +270 -0
  106. package/bin/mint/client/src/css/utilities.css +43 -0
  107. package/bin/mint/client/src/enums/components.ts +8 -0
  108. package/bin/mint/client/src/fonts/FiraCode-VF.woff +0 -0
  109. package/bin/mint/client/src/fonts/FiraCode-VF.woff2 +0 -0
  110. package/bin/mint/client/src/fonts/IBMPlexMono-Regular.ttf +0 -0
  111. package/bin/mint/client/src/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  112. package/bin/mint/client/src/fonts/Inter-italic-latin.var.woff2 +0 -0
  113. package/bin/mint/client/src/fonts/Inter-roman-latin.var.woff2 +0 -0
  114. package/bin/mint/client/src/fonts/Pally-Variable.ttf +0 -0
  115. package/bin/mint/client/src/fonts/SourceSansPro-Regular.otf +0 -0
  116. package/bin/mint/client/src/fonts/SourceSerifPro-Regular.ttf +0 -0
  117. package/bin/mint/client/src/fonts/Synonym-Variable.ttf +0 -0
  118. package/bin/mint/client/src/fonts/Ubuntu-Mono-bold.woff2 +0 -0
  119. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.woff2 +0 -0
  120. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.zopfli.woff +0 -0
  121. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular.module.css +11 -0
  122. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.woff2 +0 -0
  123. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.zopfli.woff +0 -0
  124. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold.module.css +11 -0
  125. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.woff2 +0 -0
  126. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.zopfli.woff +0 -0
  127. package/bin/mint/client/src/fonts/generated/Pally-Variable.module.css +11 -0
  128. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.woff2 +0 -0
  129. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.zopfli.woff +0 -0
  130. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular.module.css +11 -0
  131. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.woff2 +0 -0
  132. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.zopfli.woff +0 -0
  133. package/bin/mint/client/src/fonts/generated/Synonym-Variable.module.css +11 -0
  134. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.woff2 +0 -0
  135. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.zopfli.woff +0 -0
  136. package/bin/mint/client/src/fonts/generated/TenorSans-Regular.module.css +11 -0
  137. package/bin/mint/client/src/hooks/useActionKey.ts +20 -0
  138. package/bin/mint/client/src/hooks/useIsomorphicLayoutEffect.ts +3 -0
  139. package/bin/mint/client/src/hooks/useMedia.ts +27 -0
  140. package/bin/mint/client/src/hooks/usePrevNext.ts +34 -0
  141. package/bin/mint/client/src/hooks/useTop.ts +15 -0
  142. package/bin/mint/client/src/icons/CopyToClipboard.tsx +33 -0
  143. package/bin/mint/client/src/index.d.ts +1 -0
  144. package/bin/mint/client/src/layouts/ApiSupplemental.tsx +173 -0
  145. package/bin/mint/client/src/layouts/ContentsLayout.tsx +256 -0
  146. package/bin/mint/client/src/layouts/DocumentationLayout.tsx +44 -0
  147. package/bin/mint/client/src/layouts/OpenApiContent.tsx +301 -0
  148. package/bin/mint/client/src/layouts/SidebarLayout.tsx +412 -0
  149. package/bin/mint/client/src/layouts/UserFeedback.tsx +73 -0
  150. package/bin/mint/client/src/layouts/getGroupsInDivision.ts +25 -0
  151. package/bin/mint/client/src/layouts/isPathInGroupPages.ts +10 -0
  152. package/bin/mint/client/src/metadata.ts +58 -0
  153. package/bin/mint/client/src/openapi.ts +3 -0
  154. package/bin/mint/client/src/pages/404.tsx +73 -0
  155. package/bin/mint/client/src/pages/_app.tsx +138 -0
  156. package/bin/mint/client/src/pages/_document.tsx +57 -0
  157. package/bin/mint/client/src/pages/api/issue.ts +10 -0
  158. package/bin/mint/client/src/pages/api/name.ts +8 -0
  159. package/bin/mint/client/src/pages/api/request.ts +31 -0
  160. package/bin/mint/client/src/pages/api/suggest.ts +10 -0
  161. package/bin/mint/client/src/pages/api/syntax-highlighted-json.ts +13 -0
  162. package/bin/mint/client/src/pages/api/utils.ts +6 -0
  163. package/bin/mint/client/src/pages/index.tsx +31 -0
  164. package/bin/mint/client/src/ui/Api.tsx +359 -0
  165. package/bin/mint/client/src/ui/Footer.tsx +124 -0
  166. package/bin/mint/client/src/ui/Header.tsx +370 -0
  167. package/bin/mint/client/src/ui/Logo.tsx +55 -0
  168. package/bin/mint/client/src/ui/PageHeader.tsx +51 -0
  169. package/bin/mint/client/src/ui/Search.tsx +386 -0
  170. package/bin/mint/client/src/ui/ThemeToggle.tsx +285 -0
  171. package/bin/mint/client/src/ui/Title.tsx +22 -0
  172. package/bin/mint/client/src/ui/TopLevelLink.tsx +122 -0
  173. package/bin/mint/client/src/utils/api.ts +252 -0
  174. package/bin/mint/client/src/utils/brands.ts +217 -0
  175. package/bin/mint/client/src/utils/castArray.ts +3 -0
  176. package/bin/mint/client/src/utils/childrenArray.ts +3 -0
  177. package/bin/mint/client/src/utils/fit.ts +27 -0
  178. package/bin/mint/client/src/utils/fontAwesome.ts +577 -0
  179. package/bin/mint/client/src/utils/getAnalyticsConfig.ts +14 -0
  180. package/bin/mint/client/src/utils/getLogoHref.ts +9 -0
  181. package/bin/mint/client/src/utils/getOpenApiContext.ts +26 -0
  182. package/bin/mint/client/src/utils/importAll.ts +6 -0
  183. package/bin/mint/client/src/utils/isObject.ts +3 -0
  184. package/bin/mint/client/src/utils/kebabToTitleCase.ts +3 -0
  185. package/bin/mint/client/src/utils/loadImage.ts +8 -0
  186. package/bin/mint/client/src/utils/slugToTitle.ts +7 -0
  187. package/bin/mint/client/src/utils/wait.ts +5 -0
  188. package/bin/mint/client/tailwind.config.cjs +323 -0
  189. package/bin/mint/client/test/test.test.ts +5 -0
  190. package/bin/mint/client/tsconfig.json +36 -0
  191. package/bin/mint/client/yarn.lock +9702 -0
  192. package/bin/navigation.js +4 -0
  193. package/bin/navigation.js.map +1 -0
  194. package/bin/pageTemplate.js +30 -0
  195. package/bin/pageTemplate.js.map +1 -0
  196. package/bin/scraping/combineNavWithEmptyGroupTitles.js +20 -0
  197. package/bin/scraping/combineNavWithEmptyGroupTitles.js.map +1 -0
  198. package/bin/scraping/detectFramework.js +25 -0
  199. package/bin/scraping/detectFramework.js.map +1 -0
  200. package/bin/scraping/downloadAllImages.js +57 -0
  201. package/bin/scraping/downloadAllImages.js.map +1 -0
  202. package/bin/scraping/getSitemapLinks.js +18 -0
  203. package/bin/scraping/getSitemapLinks.js.map +1 -0
  204. package/bin/scraping/replaceImagePaths.js +17 -0
  205. package/bin/scraping/replaceImagePaths.js.map +1 -0
  206. package/bin/scraping/scrapeFileGettingFileNameFromUrl.js +43 -0
  207. package/bin/scraping/scrapeFileGettingFileNameFromUrl.js.map +1 -0
  208. package/bin/scraping/scrapeGettingFileNameFromUrl.js +14 -0
  209. package/bin/scraping/scrapeGettingFileNameFromUrl.js.map +1 -0
  210. package/bin/scraping/scrapePage.js +9 -0
  211. package/bin/scraping/scrapePage.js.map +1 -0
  212. package/bin/scraping/scrapePageCommands.js +48 -0
  213. package/bin/scraping/scrapePageCommands.js.map +1 -0
  214. package/bin/scraping/scrapeSection.js +9 -0
  215. package/bin/scraping/scrapeSection.js.map +1 -0
  216. package/bin/scraping/scrapeSectionCommands.js +90 -0
  217. package/bin/scraping/scrapeSectionCommands.js.map +1 -0
  218. package/bin/scraping/site-scrapers/getLinksRecursively.js +33 -0
  219. package/bin/scraping/site-scrapers/getLinksRecursively.js.map +1 -0
  220. package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js +43 -0
  221. package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js.map +1 -0
  222. package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +52 -0
  223. package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -0
  224. package/bin/{scrapeGitBookPage.js → scraping/site-scrapers/scrapeGitBookPage.js} +10 -5
  225. package/bin/scraping/site-scrapers/scrapeGitBookPage.js.map +1 -0
  226. package/bin/scraping/site-scrapers/scrapeGitBookSection.js +51 -0
  227. package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +1 -0
  228. package/bin/scraping/site-scrapers/scrapeReadMePage.js +35 -0
  229. package/bin/scraping/site-scrapers/scrapeReadMePage.js.map +1 -0
  230. package/bin/scraping/site-scrapers/scrapeReadMeSection.js +38 -0
  231. package/bin/scraping/site-scrapers/scrapeReadMeSection.js.map +1 -0
  232. package/bin/util.js +47 -8
  233. package/bin/util.js.map +1 -1
  234. package/bin/validation/isValidLink.js +11 -0
  235. package/bin/validation/isValidLink.js.map +1 -0
  236. package/bin/validation/stopIfInvalidLink.js +9 -0
  237. package/bin/validation/stopIfInvalidLink.js.map +1 -0
  238. package/package.json +21 -4
  239. package/src/browser.ts +24 -0
  240. package/src/constants.ts +10 -0
  241. package/src/downloadImage.ts +35 -0
  242. package/src/index.ts +111 -122
  243. package/src/init-command/index.ts +59 -0
  244. package/src/{templates.ts → init-command/templates.ts} +0 -0
  245. package/src/local-preview/categorizeFiles.ts +74 -0
  246. package/src/local-preview/getOpenApiContext.ts +61 -0
  247. package/src/local-preview/index.ts +164 -0
  248. package/src/local-preview/injectFavicons.ts +76 -0
  249. package/src/local-preview/listener.ts +116 -0
  250. package/src/local-preview/metadata.ts +154 -0
  251. package/src/local-preview/mintConfigFile.ts +48 -0
  252. package/src/local-preview/openApiCheck.ts +19 -0
  253. package/src/local-preview/slugToTitle.ts +7 -0
  254. package/src/navigation.ts +12 -0
  255. package/src/pageTemplate.ts +32 -0
  256. package/src/scraping/combineNavWithEmptyGroupTitles.ts +21 -0
  257. package/src/scraping/detectFramework.ts +31 -0
  258. package/src/scraping/downloadAllImages.ts +79 -0
  259. package/src/scraping/getSitemapLinks.ts +18 -0
  260. package/src/scraping/replaceImagePaths.ts +21 -0
  261. package/src/scraping/scrapeFileGettingFileNameFromUrl.ts +81 -0
  262. package/src/scraping/scrapeGettingFileNameFromUrl.ts +50 -0
  263. package/src/scraping/scrapePage.ts +24 -0
  264. package/src/scraping/scrapePageCommands.ts +52 -0
  265. package/src/scraping/scrapeSection.ts +16 -0
  266. package/src/scraping/scrapeSectionCommands.ts +110 -0
  267. package/src/scraping/site-scrapers/getLinksRecursively.ts +40 -0
  268. package/src/scraping/site-scrapers/scrapeDocusaurusPage.ts +67 -0
  269. package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +80 -0
  270. package/src/{scrapeGitBookPage.ts → scraping/site-scrapers/scrapeGitBookPage.ts} +25 -5
  271. package/src/scraping/site-scrapers/scrapeGitBookSection.ts +77 -0
  272. package/src/scraping/site-scrapers/scrapeReadMePage.ts +57 -0
  273. package/src/scraping/site-scrapers/scrapeReadMeSection.ts +60 -0
  274. package/src/util.ts +53 -7
  275. package/src/validation/isValidLink.ts +9 -0
  276. package/src/validation/stopIfInvalidLink.ts +9 -0
  277. package/tsconfig.json +1 -1
  278. package/bin/scrapeGitBook.js +0 -28
  279. package/bin/scrapeGitBook.js.map +0 -1
  280. package/bin/scrapeGitBookPage.js.map +0 -1
  281. package/bin/scrapeReadMe.js +0 -60
  282. package/bin/scrapeReadMe.js.map +0 -1
  283. package/bin/scrapeReadMePage.js +0 -28
  284. package/bin/scrapeReadMePage.js.map +0 -1
  285. package/src/scrapeReadMe.ts +0 -79
  286. package/src/scrapeReadMePage.ts +0 -37
@@ -0,0 +1,369 @@
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
+ }
@@ -0,0 +1,55 @@
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;
@@ -0,0 +1,36 @@
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;
@@ -0,0 +1,37 @@
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;
@@ -0,0 +1,71 @@
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;
@@ -0,0 +1,72 @@
1
+ import { existsSync } from 'fs';
2
+ import { promises } from 'fs';
3
+ import { resolve } from 'path';
4
+
5
+ const { readdir, copyFile } = promises;
6
+
7
+ const pathToMoveTo = process.argv[2] ?? '../docs';
8
+
9
+ const getFileList = async (dirName, og = dirName) => {
10
+ let files = [];
11
+ const items = await readdir(resolve(dirName), { withFileTypes: true });
12
+
13
+ for (const item of items) {
14
+ if (item.isDirectory()) {
15
+ files = [...files, ...(await getFileList(`${dirName}/${item.name}`, og))];
16
+ } else {
17
+ files.push(`${dirName}/${item.name}`);
18
+ }
19
+ }
20
+
21
+ return files;
22
+ };
23
+
24
+ const moveConfig = async () => {
25
+ try {
26
+ const configPath = resolve('./src/mint.json');
27
+ if (existsSync(configPath)) {
28
+ console.log('⚙️ Config file detected');
29
+ await copyFile(configPath, resolve(`${pathToMoveTo}/mint.json`));
30
+ console.log('🌿 Config file moved to mint.json');
31
+ }
32
+ } catch (err) {
33
+ console.log(err);
34
+ }
35
+ };
36
+
37
+ const moveFiles = async () => {
38
+ moveConfig();
39
+ let publicFileList = await getFileList('./public');
40
+ let mdxFileList = await getFileList('./src/pages');
41
+ publicFileList = publicFileList.filter((filename) => {
42
+ const startsWith = filename.startsWith('./public/favicons/');
43
+ const endsWith = filename.endsWith('.DS_Store');
44
+ return !startsWith && !endsWith;
45
+ });
46
+ mdxFileList = mdxFileList.filter((filename) => {
47
+ const extension =
48
+ filename.substring(filename.lastIndexOf('.') + 1, filename.length) || filename;
49
+ return extension && (extension === 'mdx' || extension === 'md');
50
+ });
51
+ publicFileList.forEach(async (filename) => {
52
+ const path = filename.substring(8);
53
+ await copyFile(resolve(filename), resolve(`${pathToMoveTo}${path}`));
54
+ });
55
+ console.log(`📄 ${publicFileList.length} static files moved to ${pathToMoveTo}`);
56
+
57
+ mdxFileList.forEach(async (filename) => {
58
+ const path = filename.substring(11);
59
+ await copyFile(resolve(filename), resolve(`${pathToMoveTo}${path}`));
60
+ });
61
+ console.log(`📄 ${mdxFileList.length} pages moved to ${pathToMoveTo}`);
62
+ };
63
+
64
+ (async function () {
65
+ try {
66
+ console.log('🗂 Moving files');
67
+ await moveFiles();
68
+ } catch (error) {
69
+ console.log(error);
70
+ console.error('⚠️ Error while prebuilding documents');
71
+ }
72
+ })();