mintlify 1.1.4 → 1.1.6

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 (175) hide show
  1. package/bin/local-preview/helper-commands/cleanCommand.js +8 -0
  2. package/bin/local-preview/helper-commands/cleanCommand.js.map +1 -0
  3. package/bin/local-preview/index.js +4 -6
  4. package/bin/local-preview/index.js.map +1 -1
  5. package/bin/local-preview/utils/categorizeFiles.js +10 -3
  6. package/bin/local-preview/utils/categorizeFiles.js.map +1 -1
  7. package/bin/local-preview/utils/getOpenApiContext.js +21 -9
  8. package/bin/local-preview/utils/getOpenApiContext.js.map +1 -1
  9. package/bin/local-preview/utils/listener.js +10 -6
  10. package/bin/local-preview/utils/listener.js.map +1 -1
  11. package/bin/local-preview/utils/metadata.js +4 -8
  12. package/bin/local-preview/utils/metadata.js.map +1 -1
  13. package/bin/local-preview/utils/openApiCheck.js +3 -4
  14. package/bin/local-preview/utils/openApiCheck.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/local-preview/index.ts +4 -6
  17. package/src/local-preview/utils/categorizeFiles.ts +12 -4
  18. package/src/local-preview/utils/getOpenApiContext.ts +27 -11
  19. package/src/local-preview/utils/listener.ts +14 -6
  20. package/src/local-preview/utils/metadata.ts +4 -8
  21. package/src/local-preview/utils/openApiCheck.ts +4 -5
  22. package/bin/local-preview/injectNav.js +0 -94
  23. package/bin/local-preview/injectNav.js.map +0 -1
  24. package/bin/mint/client/.babel-plugin-macrosrc.json +0 -5
  25. package/bin/mint/client/.babelrc +0 -4
  26. package/bin/mint/client/.editorconfig +0 -12
  27. package/bin/mint/client/.eslintrc.json +0 -7
  28. package/bin/mint/client/.prettierignore +0 -4
  29. package/bin/mint/client/.prettierrc +0 -14
  30. package/bin/mint/client/.vscode/launch.json +0 -28
  31. package/bin/mint/client/README.md +0 -44
  32. package/bin/mint/client/jest.config.ts +0 -195
  33. package/bin/mint/client/next-env.d.ts +0 -4
  34. package/bin/mint/client/next.config.js +0 -152
  35. package/bin/mint/client/package.json +0 -139
  36. package/bin/mint/client/postcss.config.cjs +0 -9
  37. package/bin/mint/client/prebuild/faviconConfig.js +0 -35
  38. package/bin/mint/client/prebuild/getOpenApiContext.js +0 -53
  39. package/bin/mint/client/prebuild/index.js +0 -117
  40. package/bin/mint/client/prebuild/injectNav.js +0 -115
  41. package/bin/mint/client/prebuild/slugToTitle.js +0 -7
  42. package/bin/mint/client/rehype/withApiComponents.js +0 -60
  43. package/bin/mint/client/rehype/withCodeBlocks.js +0 -54
  44. package/bin/mint/client/rehype/withLayouts.js +0 -113
  45. package/bin/mint/client/rehype/withLinkRoles.js +0 -13
  46. package/bin/mint/client/rehype/withRawComponents.js +0 -13
  47. package/bin/mint/client/rehype/withStaticProps.js +0 -25
  48. package/bin/mint/client/rehype/withSyntaxHighlighting.js +0 -60
  49. package/bin/mint/client/remark/utils.js +0 -369
  50. package/bin/mint/client/remark/withFrames.js +0 -55
  51. package/bin/mint/client/remark/withImportsInjected.js +0 -36
  52. package/bin/mint/client/remark/withNextLinks.js +0 -37
  53. package/bin/mint/client/remark/withTableOfContents.js +0 -71
  54. package/bin/mint/client/scripts/local.js +0 -177
  55. package/bin/mint/client/sentry.client.config.js +0 -15
  56. package/bin/mint/client/sentry.properties +0 -4
  57. package/bin/mint/client/sentry.server.config.js +0 -15
  58. package/bin/mint/client/src/analytics/AbstractAnalyticsImplementation.ts +0 -50
  59. package/bin/mint/client/src/analytics/AnalyticsContext.ts +0 -5
  60. package/bin/mint/client/src/analytics/AnalyticsMediator.ts +0 -101
  61. package/bin/mint/client/src/analytics/FakeAnalyticsMediator.ts +0 -9
  62. package/bin/mint/client/src/analytics/GA4Script.tsx +0 -33
  63. package/bin/mint/client/src/analytics/implementations/amplitude.ts +0 -26
  64. package/bin/mint/client/src/analytics/implementations/fathom.ts +0 -38
  65. package/bin/mint/client/src/analytics/implementations/ga4.ts +0 -33
  66. package/bin/mint/client/src/analytics/implementations/hotjar.ts +0 -53
  67. package/bin/mint/client/src/analytics/implementations/mixpanel-browser.d.ts +0 -1
  68. package/bin/mint/client/src/analytics/implementations/mixpanel.ts +0 -52
  69. package/bin/mint/client/src/analytics/implementations/posthog.ts +0 -37
  70. package/bin/mint/client/src/components/Accordion/Accordion.tsx +0 -43
  71. package/bin/mint/client/src/components/Accordion/index.ts +0 -4
  72. package/bin/mint/client/src/components/ApiExample.tsx +0 -9
  73. package/bin/mint/client/src/components/Card.tsx +0 -51
  74. package/bin/mint/client/src/components/CodeGroup.tsx +0 -132
  75. package/bin/mint/client/src/components/Editor.tsx +0 -12
  76. package/bin/mint/client/src/components/Expandable.tsx +0 -40
  77. package/bin/mint/client/src/components/Heading.tsx +0 -84
  78. package/bin/mint/client/src/components/Param.tsx +0 -56
  79. package/bin/mint/client/src/components/Request.tsx +0 -19
  80. package/bin/mint/client/src/components/ResponseField.tsx +0 -33
  81. package/bin/mint/client/src/components/TabBar.tsx +0 -61
  82. package/bin/mint/client/src/config.ts +0 -115
  83. package/bin/mint/client/src/css/bar-of-progress.css +0 -10
  84. package/bin/mint/client/src/css/base.css +0 -29
  85. package/bin/mint/client/src/css/font-awesome.css +0 -7
  86. package/bin/mint/client/src/css/fonts.css +0 -44
  87. package/bin/mint/client/src/css/main.css +0 -11
  88. package/bin/mint/client/src/css/prism.css +0 -270
  89. package/bin/mint/client/src/css/utilities.css +0 -43
  90. package/bin/mint/client/src/enums/components.ts +0 -8
  91. package/bin/mint/client/src/fonts/FiraCode-VF.woff +0 -0
  92. package/bin/mint/client/src/fonts/FiraCode-VF.woff2 +0 -0
  93. package/bin/mint/client/src/fonts/IBMPlexMono-Regular.ttf +0 -0
  94. package/bin/mint/client/src/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  95. package/bin/mint/client/src/fonts/Inter-italic-latin.var.woff2 +0 -0
  96. package/bin/mint/client/src/fonts/Inter-roman-latin.var.woff2 +0 -0
  97. package/bin/mint/client/src/fonts/Pally-Variable.ttf +0 -0
  98. package/bin/mint/client/src/fonts/SourceSansPro-Regular.otf +0 -0
  99. package/bin/mint/client/src/fonts/SourceSerifPro-Regular.ttf +0 -0
  100. package/bin/mint/client/src/fonts/Synonym-Variable.ttf +0 -0
  101. package/bin/mint/client/src/fonts/Ubuntu-Mono-bold.woff2 +0 -0
  102. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.woff2 +0 -0
  103. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.zopfli.woff +0 -0
  104. package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular.module.css +0 -11
  105. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.woff2 +0 -0
  106. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.zopfli.woff +0 -0
  107. package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold.module.css +0 -11
  108. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.woff2 +0 -0
  109. package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.zopfli.woff +0 -0
  110. package/bin/mint/client/src/fonts/generated/Pally-Variable.module.css +0 -11
  111. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.woff2 +0 -0
  112. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.zopfli.woff +0 -0
  113. package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular.module.css +0 -11
  114. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.woff2 +0 -0
  115. package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.zopfli.woff +0 -0
  116. package/bin/mint/client/src/fonts/generated/Synonym-Variable.module.css +0 -11
  117. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.woff2 +0 -0
  118. package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.zopfli.woff +0 -0
  119. package/bin/mint/client/src/fonts/generated/TenorSans-Regular.module.css +0 -11
  120. package/bin/mint/client/src/hooks/useActionKey.ts +0 -20
  121. package/bin/mint/client/src/hooks/useIsomorphicLayoutEffect.ts +0 -3
  122. package/bin/mint/client/src/hooks/useMedia.ts +0 -27
  123. package/bin/mint/client/src/hooks/usePrevNext.ts +0 -34
  124. package/bin/mint/client/src/hooks/useTop.ts +0 -15
  125. package/bin/mint/client/src/icons/CopyToClipboard.tsx +0 -33
  126. package/bin/mint/client/src/index.d.ts +0 -1
  127. package/bin/mint/client/src/layouts/ApiSupplemental.tsx +0 -173
  128. package/bin/mint/client/src/layouts/ContentsLayout.tsx +0 -256
  129. package/bin/mint/client/src/layouts/DocumentationLayout.tsx +0 -44
  130. package/bin/mint/client/src/layouts/OpenApiContent.tsx +0 -301
  131. package/bin/mint/client/src/layouts/SidebarLayout.tsx +0 -412
  132. package/bin/mint/client/src/layouts/UserFeedback.tsx +0 -73
  133. package/bin/mint/client/src/layouts/getGroupsInDivision.ts +0 -25
  134. package/bin/mint/client/src/layouts/isPathInGroupPages.ts +0 -10
  135. package/bin/mint/client/src/metadata.ts +0 -58
  136. package/bin/mint/client/src/nav.json +0 -219
  137. package/bin/mint/client/src/openapi.ts +0 -3
  138. package/bin/mint/client/src/pages/404.tsx +0 -73
  139. package/bin/mint/client/src/pages/_app.tsx +0 -138
  140. package/bin/mint/client/src/pages/_document.tsx +0 -57
  141. package/bin/mint/client/src/pages/api/issue.ts +0 -10
  142. package/bin/mint/client/src/pages/api/name.ts +0 -8
  143. package/bin/mint/client/src/pages/api/request.ts +0 -31
  144. package/bin/mint/client/src/pages/api/suggest.ts +0 -10
  145. package/bin/mint/client/src/pages/api/syntax-highlighted-json.ts +0 -13
  146. package/bin/mint/client/src/pages/api/utils.ts +0 -6
  147. package/bin/mint/client/src/pages/index.tsx +0 -31
  148. package/bin/mint/client/src/ui/Api.tsx +0 -359
  149. package/bin/mint/client/src/ui/Footer.tsx +0 -124
  150. package/bin/mint/client/src/ui/Header.tsx +0 -370
  151. package/bin/mint/client/src/ui/Logo.tsx +0 -55
  152. package/bin/mint/client/src/ui/PageHeader.tsx +0 -51
  153. package/bin/mint/client/src/ui/Search.tsx +0 -386
  154. package/bin/mint/client/src/ui/ThemeToggle.tsx +0 -285
  155. package/bin/mint/client/src/ui/Title.tsx +0 -22
  156. package/bin/mint/client/src/ui/TopLevelLink.tsx +0 -122
  157. package/bin/mint/client/src/utils/api.ts +0 -252
  158. package/bin/mint/client/src/utils/brands.ts +0 -217
  159. package/bin/mint/client/src/utils/castArray.ts +0 -3
  160. package/bin/mint/client/src/utils/childrenArray.ts +0 -3
  161. package/bin/mint/client/src/utils/fit.ts +0 -27
  162. package/bin/mint/client/src/utils/fontAwesome.ts +0 -577
  163. package/bin/mint/client/src/utils/getAnalyticsConfig.ts +0 -14
  164. package/bin/mint/client/src/utils/getLogoHref.ts +0 -9
  165. package/bin/mint/client/src/utils/getOpenApiContext.ts +0 -26
  166. package/bin/mint/client/src/utils/importAll.ts +0 -6
  167. package/bin/mint/client/src/utils/isObject.ts +0 -3
  168. package/bin/mint/client/src/utils/kebabToTitleCase.ts +0 -3
  169. package/bin/mint/client/src/utils/loadImage.ts +0 -8
  170. package/bin/mint/client/src/utils/slugToTitle.ts +0 -7
  171. package/bin/mint/client/src/utils/wait.ts +0 -5
  172. package/bin/mint/client/tailwind.config.cjs +0 -323
  173. package/bin/mint/client/test/test.test.ts +0 -5
  174. package/bin/mint/client/tsconfig.json +0 -36
  175. package/bin/mint/client/yarn.lock +0 -9702
@@ -1,139 +0,0 @@
1
- {
2
- "private": true,
3
- "type": "module",
4
- "scripts": {
5
- "prebuild": "node prebuild index.ts",
6
- "local": "node scripts/local",
7
- "dev": "next dev",
8
- "build": "next build",
9
- "start": "next start",
10
- "export": "next build && next export",
11
- "format": "prettier '{src,remark,scripts}/**/*.{css,js,mdx}' --write",
12
- "test": "jest"
13
- },
14
- "browserslist": [
15
- "> 1%"
16
- ],
17
- "dependencies": {
18
- "@amplitude/analytics-browser": "^1.2.0",
19
- "@babel/plugin-transform-react-jsx": "^7.14.9",
20
- "@babel/preset-env": "^7.1.6",
21
- "@badrap/bar-of-progress": "^0.1.1",
22
- "@fortawesome/fontawesome-svg-core": "^6.1.2",
23
- "@fortawesome/free-brands-svg-icons": "^6.1.2",
24
- "@fortawesome/pro-duotone-svg-icons": "^6.1.2",
25
- "@fortawesome/pro-light-svg-icons": "^6.1.2",
26
- "@fortawesome/pro-regular-svg-icons": "^6.1.2",
27
- "@fortawesome/pro-solid-svg-icons": "^6.1.2",
28
- "@fortawesome/pro-thin-svg-icons": "^6.1.2",
29
- "@fortawesome/react-fontawesome": "^0.2.0",
30
- "@headlessui/react": "^1.6.6",
31
- "@heroicons/react": "^1.0.6",
32
- "@juggle/resize-observer": "^3.2.0",
33
- "@mdx-js/loader": "^2.1.3",
34
- "@mdx-js/react": "^2.1.3",
35
- "@mintlify/components": "^0.1.23",
36
- "@next/bundle-analyzer": "^12.3.1",
37
- "@next/mdx": "^12.3.0",
38
- "@sentry/nextjs": "^7.9.0",
39
- "@sindresorhus/slugify": "^1.1.0",
40
- "@svgr/webpack": "^6.3.1",
41
- "@tailwindcss/aspect-ratio": "^0.4.2",
42
- "@tailwindcss/line-clamp": "^0.3.1",
43
- "@tailwindcss/typography": "^0.5.0",
44
- "acorn": "8.8.0",
45
- "algoliasearch": "^4.14.0",
46
- "autoprefixer": "^10.4.0",
47
- "axios": "^0.27.2",
48
- "babel-plugin-macros": "^3.1.0",
49
- "brotli-size": "^4.0.0",
50
- "clean-css": "^4.2.3",
51
- "clsx": "^1.1.1",
52
- "deasync": "^0.1.20",
53
- "debounce": "^1.2.0",
54
- "dlv": "^1.1.3",
55
- "exec-sh": "^0.3.4",
56
- "fathom-client": "^3.5.0",
57
- "feed": "^4.2.2",
58
- "file-loader": "^6.0.0",
59
- "focus-visible": "^5.1.0",
60
- "front-matter": "^4.0.2",
61
- "fs-extra": "^10.1.0",
62
- "github-url-to-object": "^4.0.6",
63
- "glob": "^7.1.6",
64
- "gsap": "^3.6.0",
65
- "gzip-size": "^5.1.1",
66
- "hast-util-from-html": "^1.0.0",
67
- "hast-util-to-html": "^8.0.3",
68
- "html-react-parser": "^3.0.4",
69
- "intersection-observer": "^0.11.0",
70
- "is-absolute-url": "^4.0.1",
71
- "just-group-by": "^1.0.0",
72
- "mdast-util-from-markdown": "^1.2.0",
73
- "mdast-util-mdx-jsx": "^2.1.0",
74
- "mdast-util-mdxjs-esm": "^1.3.0",
75
- "micromark-extension-mdx-jsx": "^1.0.3",
76
- "mini-svg-data-uri": "^1.4.3",
77
- "minimatch": "^3.0.4",
78
- "mixpanel-browser": "^2.45.0",
79
- "next": "^12.2.5",
80
- "openapi-types": "^12.0.0",
81
- "postcss": "^8.4.5",
82
- "postcss-focus-visible": "^5.0.0",
83
- "postcss-import": "^14.0.1",
84
- "posthog-js": "^1.29.3",
85
- "prismjs": "^1.27.0",
86
- "react": "^18.2.0",
87
- "react-dom": "^18.2.0",
88
- "react-hotjar": "^5.1.0",
89
- "react-hotkeys-hook": "^3.4.7",
90
- "react-intersection-observer": "^8.29.0",
91
- "react-use-rect": "^2.0.4",
92
- "redent": "^3.0.0",
93
- "remark-gfm": "^3.0.1",
94
- "remark-smartypants": "^2.0.0",
95
- "seedrandom": "^3.0.5",
96
- "simple-functional-loader": "^1.2.1",
97
- "stringify-object": "^3.3.0",
98
- "tailwindcss": "^3.1.6",
99
- "tinytime": "^0.2.6",
100
- "webpack": "^5.74.0",
101
- "zustand": "^4.0.0-rc.0"
102
- },
103
- "devDependencies": {
104
- "@apidevtools/swagger-parser": "^10.1.0",
105
- "@babel/core": "^7.0.0-0",
106
- "@babel/plugin-syntax-flow": "^7.14.5",
107
- "@next/eslint-plugin-next": "^12.3.0",
108
- "@trivago/prettier-plugin-sort-imports": "^3.3.0",
109
- "@types/github-url-to-object": "^4.0.1",
110
- "@types/glob": "^7.2.0",
111
- "@types/jest": "^29.1.2",
112
- "@types/mdx-js__react": "^1.5.5",
113
- "@types/node": "^18.0.5",
114
- "@types/prismjs": "^1.26.0",
115
- "@types/react": "18.0.1",
116
- "@types/react-dom": "^18.0.6",
117
- "@types/seedrandom": "^3.0.2",
118
- "@typescript-eslint/eslint-plugin": "^5.35.1",
119
- "@typescript-eslint/parser": "^5.35.1",
120
- "babel-eslint": "10.x",
121
- "eslint": "^8.22.0",
122
- "eslint-config-react-app": "^7.0.1",
123
- "eslint-plugin-flowtype": "4.x",
124
- "eslint-plugin-import": "2.x",
125
- "eslint-plugin-jsx-a11y": "6.x",
126
- "eslint-plugin-react": "7.x",
127
- "eslint-plugin-react-hooks": "^4.6.0",
128
- "favicons": "7.0.0-beta.4",
129
- "gray-matter": "^4.0.3",
130
- "hast-util-to-string": "^2.0.0",
131
- "jest": "^29.1.2",
132
- "prettier": "^2.5.0",
133
- "refractor": "^4.8.0",
134
- "ts-node": "^10.9.1",
135
- "typescript": "^4.7.4",
136
- "unist-util-filter": "^4.0.0",
137
- "unist-util-visit": "^2.0.3"
138
- }
139
- }
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- plugins: [
3
- 'postcss-import',
4
- 'tailwindcss/nesting',
5
- 'tailwindcss',
6
- 'postcss-focus-visible',
7
- 'autoprefixer',
8
- ],
9
- }
@@ -1,35 +0,0 @@
1
- const faviconConfig = (name) => ({
2
- path: '/favicons', // Path for overriding default icons path. `string`
3
- appName: name, // Your application's name. `string`
4
- appShortName: name, // Your application's short_name. `string`. Optional. If not set, appName will be used
5
- appDescription: null, // Your application's description. `string`
6
- developerName: null, // Your (or your developer's) name. `string`
7
- developerURL: null, // Your (or your developer's) URL. `string`
8
- dir: 'auto', // Primary text direction for name, short_name, and description
9
- lang: 'en-US', // Primary language for name and short_name
10
- background: '#fff', // Background colour for flattened icons. `string`
11
- theme_color: '#fff', // Theme color user for example in Android's task switcher. `string`
12
- appleStatusBarStyle: 'black-translucent', // Style for Apple status bar: "black-translucent", "default", "black". `string`
13
- display: 'standalone', // Preferred display mode: "fullscreen", "standalone", "minimal-ui" or "browser". `string`
14
- orientation: 'any', // Default orientation: "any", "natural", "portrait" or "landscape". `string`
15
- scope: '/', // set of URLs that the browser considers within your app
16
- start_url: '/?homescreen=1', // Start URL when launching the application from a device. `string`
17
- preferRelatedApplications: false, // Should the browser prompt the user to install the native companion app. `boolean`
18
- relatedApplications: undefined, // Information about the native companion apps. This will only be used if `preferRelatedApplications` is `true`. `Array<{ id: string, url: string, platform: string }>`
19
- version: '1.0', // Your application's version string. `string`
20
- logging: false, // Print logs to console? `boolean`
21
- pixel_art: false, // Keeps pixels "sharp" when scaling up, for pixel art. Only supported in offline mode.
22
- loadManifestWithCredentials: true, // Browsers don't send cookies when fetching a manifest, enable this to fix that. `boolean`
23
- manifestMaskable: false, // Maskable source image(s) for manifest.json. "true" to use default source. More information at https://web.dev/maskable-icon/. `boolean`, `string`, `buffer` or array of `string`
24
- icons: {
25
- android: ['android-chrome-192x192.png', 'android-chrome-256x256.png'],
26
- appleIcon: ['apple-touch-icon.png'],
27
- appleStartup: false,
28
- favicons: true,
29
- windows: ['mstile-150x150.png'],
30
- yandex: false,
31
- firefox: false,
32
- },
33
- });
34
-
35
- export default faviconConfig;
@@ -1,53 +0,0 @@
1
- export const extractMethodAndEndpoint = (api) => {
2
- const methodRegex = /^get|post|put|delete|patch/i;
3
- const trimmed = api.trim();
4
- const foundMethod = trimmed.match(methodRegex);
5
-
6
- const endIndexOfMethod = foundMethod ? api.indexOf(foundMethod[0]) + foundMethod[0].length : 0;
7
-
8
- return {
9
- method: foundMethod ? foundMethod[0].toUpperCase() : undefined,
10
- endpoint: api.substring(endIndexOfMethod).trim(),
11
- };
12
- };
13
-
14
- export const getOpenApiOperationMethodAndEndpoint = (openApiObj, openApiMetaField) => {
15
- const { endpoint, method } = extractMethodAndEndpoint(openApiMetaField);
16
-
17
- const path = openApiObj?.paths && openApiObj.paths[endpoint];
18
-
19
- if (path == null) {
20
- return {};
21
- }
22
-
23
- let operation;
24
- if (method) {
25
- operation = path[method.toLowerCase()];
26
- } else {
27
- const firstOperationKey = Object.keys(path)[0];
28
- operation = path[firstOperationKey];
29
- }
30
-
31
- return {
32
- operation,
33
- method,
34
- endpoint,
35
- };
36
- };
37
-
38
- export const getOpenApiTitleAndDescription = (openApiObj, openApiMetaField) => {
39
- if (openApiObj == null || !openApiMetaField || openApiMetaField == null) {
40
- return {};
41
- }
42
-
43
- const { operation } = getOpenApiOperationMethodAndEndpoint(openApiObj, openApiMetaField);
44
-
45
- if (operation == null) {
46
- return {};
47
- }
48
-
49
- return {
50
- title: operation.summary,
51
- description: operation.description,
52
- };
53
- };
@@ -1,117 +0,0 @@
1
- import axios from 'axios';
2
- import favicons from 'favicons';
3
- import fs from 'fs-extra';
4
- import { dirname } from 'path';
5
- import { resolve } from 'path';
6
- import { fileURLToPath } from 'url';
7
-
8
- import faviconConfig from './faviconConfig.js';
9
- import { createPage, injectNav } from './injectNav.js';
10
-
11
- const API_ENDPOINT = 'https://docs.mintlify.com';
12
-
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = dirname(__filename);
15
-
16
- const injectMarkdownFilesAndNav = (markdownFiles, openApiObj, configObj) => {
17
- let pages = {};
18
- markdownFiles.forEach((markdownFile) => {
19
- const path = __dirname + `/../src/pages/${markdownFile.path}`;
20
- const page = createPage(markdownFile.path, markdownFile.content, openApiObj);
21
- if (page != null) {
22
- pages = {
23
- ...pages,
24
- ...page,
25
- };
26
- }
27
-
28
- fs.outputFileSync(path, Buffer.from(markdownFile.content), { flag: 'w' });
29
- });
30
-
31
- console.log(`📄 ${markdownFiles.length} pages injected`);
32
-
33
- injectNav(pages, configObj);
34
- };
35
-
36
- const injectStaticFiles = (staticFiles) => {
37
- staticFiles.forEach((staticFile) => {
38
- const path = __dirname + `/../public/${staticFile.path}`;
39
- fs.outputFileSync(path, Buffer.from(staticFile.content), { flag: 'w' });
40
- });
41
-
42
- console.log(`📄 ${staticFiles.length} static files injected`);
43
- };
44
-
45
- const injectConfig = (config) => {
46
- const path = __dirname + `/../src/mint.json`;
47
- const buffer = Buffer.from(config);
48
- fs.outputFileSync(path, buffer, { flag: 'w' });
49
- console.log('⚙️ Config file set properly as mint.json');
50
- return JSON.parse(buffer.toString());
51
- };
52
-
53
- const injectFavicons = async (config) => {
54
- const buffer = Buffer.from(config);
55
- const configJSON = JSON.parse(buffer.toString());
56
-
57
- if (configJSON?.favicon == null) return;
58
-
59
- const desiredPath = resolve(__dirname + `/../public/${configJSON.favicon}`);
60
- const favicon = fs.readFileSync(desiredPath);
61
- if (favicon == null) return;
62
- console.log('Generating favicons...');
63
- favicons(favicon, faviconConfig(config?.name), (err, response) => {
64
- if (err) {
65
- console.log(err.message); // Error description e.g. "An unknown error has occurred"
66
- return;
67
- }
68
- response.images.forEach((img) => {
69
- const path = __dirname + `/../public/favicons/${img.name}`;
70
- fs.outputFileSync(path, Buffer.from(img.contents), { flag: 'w' });
71
- });
72
- response.files.forEach((file) => {
73
- const path = __dirname + `/../public/favicons/${file.name}`;
74
- fs.outputFileSync(path, file.contents, { flag: 'w' });
75
- });
76
- console.log('Favicons generated');
77
- });
78
- };
79
-
80
- const injectOpenApi = async (openApi) => {
81
- const path = __dirname + `/../src/openapi.json`;
82
- if (openApi) {
83
- const buffer = Buffer.from(openApi);
84
- fs.outputFileSync(path, buffer, { flag: 'w' });
85
- console.log('🖥️ OpenAPI file detected and set as openapi.json');
86
- return JSON.parse(buffer.toString());
87
- }
88
-
89
- fs.outputFileSync(path, '{}', { flag: 'w' });
90
- };
91
-
92
- const getAllFilesAndConfig = async () => {
93
- const ref = process.env.GIT_REF;
94
- const {
95
- data: { markdownFiles, staticFiles, config, openApi },
96
- } = await axios.get(`${API_ENDPOINT}/api/v1/sites/files`, {
97
- headers: { Authorization: `Bearer ${process.env.INTERNAL_SITE_BEARER_TOKEN}` },
98
- params: {
99
- ref,
100
- },
101
- });
102
- const openApiObj = await injectOpenApi(openApi);
103
- const configObj = await injectConfig(config);
104
- injectMarkdownFilesAndNav(markdownFiles, openApiObj, configObj);
105
- injectStaticFiles(staticFiles);
106
- injectFavicons(config);
107
- };
108
-
109
- (async function () {
110
- try {
111
- console.log('🔍 Fetching files');
112
- await getAllFilesAndConfig();
113
- } catch (error) {
114
- console.log(error);
115
- console.error('⚠️ Error while prebuilding documents');
116
- }
117
- })();
@@ -1,115 +0,0 @@
1
- import fs from 'fs-extra';
2
- import matter from 'gray-matter';
3
- import { dirname } from 'path';
4
- import { fileURLToPath } from 'url';
5
-
6
- import { getOpenApiTitleAndDescription } from './getOpenApiContext.js';
7
- import { slugToTitle } from './slugToTitle.js';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = dirname(__filename);
11
-
12
- // End matter is front matter, but at the end
13
- const getIndexOfEndMatter = (fileContents) => {
14
- const frontMatters = fileContents.match(
15
- /---\n(title:.+\n|description:.+\n|sidebarTitle:.+\n|api:.+\n|openapi:.+\n)+---$/m
16
- );
17
- if (frontMatters) {
18
- return fileContents.indexOf(frontMatters[0]);
19
- }
20
-
21
- return -1;
22
- };
23
-
24
- export const potentiallyRemoveEndMatter = (fileContents) => {
25
- const endMatterIndex = getIndexOfEndMatter(fileContents);
26
-
27
- if (endMatterIndex === -1) {
28
- return fileContents;
29
- }
30
-
31
- return fileContents.substring(0, endMatterIndex);
32
- };
33
-
34
- const getMetadata = (fileContents) => {
35
- const { data } = matter(fileContents);
36
-
37
- if (Object.keys(data).length > 0) {
38
- return data;
39
- }
40
-
41
- const startIndex = getIndexOfEndMatter(fileContents);
42
- if (startIndex === -1) {
43
- return {};
44
- }
45
-
46
- const fileContentFromFrontMatter = fileContents.substring(startIndex);
47
- const { data: nonTopFrontMatter } = matter(fileContentFromFrontMatter);
48
- return nonTopFrontMatter;
49
- };
50
-
51
- export const createPage = (path, content, openApiObj) => {
52
- const slug = path.replace(/\.mdx?$/, '');
53
- let defaultTitle = slugToTitle(slug);
54
- const fileContents = Buffer.from(content).toString();
55
- const metadata = getMetadata(fileContents);
56
- // Append data from OpenAPI if it exists
57
- const { title, description } = getOpenApiTitleAndDescription(openApiObj, metadata?.openapi);
58
- if (title) {
59
- defaultTitle = title;
60
- }
61
- return {
62
- [slug]: { title: defaultTitle, description, ...metadata, href: `/${slug}` },
63
- };
64
- };
65
-
66
- export const injectNav = (pages, configObj) => {
67
- const path = __dirname + `/../src/metadata.json`;
68
- const createNav = (nav) => {
69
- return {
70
- group: nav.group,
71
- pages: nav.pages.map((page) => {
72
- if (typeof page === 'string') {
73
- return pages[page];
74
- }
75
-
76
- return createNav(page);
77
- }),
78
- };
79
- };
80
-
81
- if (configObj?.navigation == null) {
82
- return;
83
- }
84
-
85
- let navFile = configObj.navigation.map((nav) => createNav(nav));
86
- const filterOutNullInPages = (pages) => {
87
- const newPages = [];
88
- pages.forEach((page) => {
89
- if (page == null) {
90
- return;
91
- }
92
- if (page?.pages) {
93
- const newGroup = filterOutNullInGroup(page);
94
- newPages.push(newGroup);
95
- } else {
96
- newPages.push(page);
97
- }
98
- });
99
-
100
- return newPages;
101
- };
102
- const filterOutNullInGroup = (group) => {
103
- const newPages = filterOutNullInPages(group.pages);
104
- const newGroup = {
105
- ...group,
106
- pages: newPages,
107
- };
108
- return newGroup;
109
- };
110
- const newNavFile = navFile.map((group) => {
111
- return filterOutNullInGroup(group);
112
- });
113
- fs.outputFileSync(path, JSON.stringify(newNavFile, null, 2), { flag: 'w' });
114
- console.log(`⛵️ Navigation generated and injected`);
115
- };
@@ -1,7 +0,0 @@
1
- export const slugToTitle = (slug) => {
2
- const slugArr = slug.split('/');
3
- let defaultTitle = slugArr[slugArr.length - 1].split('-').join(' '); //replace all dashes
4
- defaultTitle = defaultTitle.split('_').join(' '); //replace all underscores
5
- defaultTitle = defaultTitle.charAt(0).toUpperCase() + defaultTitle.slice(1); //capitalize first letter
6
- return defaultTitle;
7
- };
@@ -1,60 +0,0 @@
1
- import { toHtml } from 'hast-util-to-html';
2
- import { filter } from 'unist-util-filter';
3
- import visit from 'unist-util-visit';
4
-
5
- import { addExport } from '../remark/utils.js';
6
-
7
- const langFilename = (className) => {
8
- switch (className) {
9
- case 'language-shell':
10
- return 'Bash';
11
- case 'language-json':
12
- return 'JSON';
13
- case 'language-js':
14
- return 'JavaScript';
15
- default:
16
- const language = className.substring(9);
17
- return language.charAt(0).toUpperCase() + language.slice(1);
18
- }
19
- };
20
- const withApiComponents = () => {
21
- return (tree) => {
22
- let apiComponents = [];
23
- visit(tree, 'mdxJsxFlowElement', (node, _, parent) => {
24
- if (['ResponseExample', 'RequestExample'].includes(node.name)) {
25
- // remove all jsx components to convert to html (removes <ResponseExample> and <Editor>)
26
- const children = node.children.map((child, i) => {
27
- const preComponent = child.children[0];
28
- const html = toHtml(preComponent);
29
- let filename =
30
- preComponent?.properties?.className?.length > 1
31
- ? langFilename(preComponent?.properties?.className[0])
32
- : '';
33
- if (child?.attributes && child.attributes.length > 0) {
34
- filename = child.attributes[0]?.value;
35
- }
36
- return {
37
- filename,
38
- html,
39
- };
40
- });
41
- apiComponents.push({
42
- type: node.name,
43
- children,
44
- });
45
- }
46
-
47
- if (parent.type === 'root' && (node.name === 'Param' || node.name === 'ParamField')) {
48
- apiComponents.push({
49
- type: 'ParamField',
50
- children: node.children,
51
- attributes: node.attributes,
52
- });
53
- }
54
- });
55
- addExport(tree, 'apiComponents', apiComponents);
56
- return filter(tree, (node) => !['ResponseExample', 'RequestExample'].includes(node.name));
57
- };
58
- };
59
-
60
- export default withApiComponents;
@@ -1,54 +0,0 @@
1
- import { fromHtml } from 'hast-util-from-html';
2
- import visit from 'unist-util-visit';
3
-
4
- import { addImport } from '../remark/utils.js';
5
-
6
- const withCodeBlocks = () => {
7
- return (tree) => {
8
- let preTree = { children: [] };
9
- let componentName;
10
-
11
- visit(tree, 'element', (node, i, parent) => {
12
- if (node?.tagName !== 'pre') return node;
13
- if (node?.children && node?.children[0]?.tagName !== 'code') return node;
14
- const code = node.children[0];
15
- const copyToClipboard = fromHtml(
16
- `<span class="copy-to-clipboard w-5 z-10 flex absolute right-5"><svg class="top-5 h-5 fill-slate-500 hover:fill-slate-300 cursor-pointer" viewBox="0 0 20 20"><path d="M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z" /><path d="M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z" /></svg><div class="tooltip hidden absolute bottom-full left-1/2 mb-3.5 pb-1 -translate-x-1/2"><div class="relative bg-primary-dark text-white text-xs leading-6 font-medium px-1.5 rounded-lg" data-reach-alert="true"><span>Copied</span><svg aria-hidden="true" width="16" height="6" viewBox="0 0 16 6" class="text-primary-dark absolute top-full left-1/2 -mt-px -ml-2"><path fillRule="evenodd" clipRule="evenodd" d="M15 0H1V1.00366V1.00366V1.00371H1.01672C2.72058 1.0147 4.24225 2.74704 5.42685 4.72928C6.42941 6.40691 9.57154 6.4069 10.5741 4.72926C11.7587 2.74703 13.2803 1.0147 14.9841 1.00371H15V0Z" fill="currentColor"></path></svg></div></div></span>`,
17
- { fragment: true }
18
- );
19
-
20
- const prepend = (value, array) => {
21
- var newArray = array.slice();
22
- newArray.unshift(value);
23
- return newArray;
24
- };
25
- node.children = prepend(copyToClipboard, node.children);
26
- let filename = undefined;
27
- if (['RequestExample', 'ResponseExample'].includes(parent.name)) {
28
- const parentType = parent.name.slice(0, -7);
29
- filename = i === 0 ? parentType : `${parentType} ${i + 1}`;
30
- node.children[0].data.meta = filename;
31
- }
32
-
33
- if (code.data?.meta) {
34
- filename = code.data.meta;
35
- }
36
- if (filename) {
37
- if (!componentName) {
38
- componentName = addImport(preTree, '@/components/Editor', 'Editor');
39
- }
40
- const wrap = {
41
- type: 'mdxJsxFlowElement',
42
- name: componentName,
43
- attributes: [{ type: 'mdxJsxAttribute', name: 'filename', value: filename }],
44
- data: { _mdxExplicitJsx: true },
45
- };
46
- wrap.children = [node];
47
- parent.children[i] = wrap;
48
- }
49
- });
50
- tree.children = [...preTree.children, ...tree.children];
51
- };
52
- };
53
-
54
- export default withCodeBlocks;