@depup/nextra 4.6.1-depup.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 (293) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/changes.json +110 -0
  4. package/dist/client/components/banner/close-banner-button.d.ts +8 -0
  5. package/dist/client/components/banner/close-banner-button.js +45 -0
  6. package/dist/client/components/banner/index.client.d.ts +5 -0
  7. package/dist/client/components/banner/index.client.js +46 -0
  8. package/dist/client/components/banner/index.d.ts +51 -0
  9. package/dist/client/components/banner/index.js +93 -0
  10. package/dist/client/components/bleed.d.ts +63 -0
  11. package/dist/client/components/bleed.js +54 -0
  12. package/dist/client/components/button.d.ts +9 -0
  13. package/dist/client/components/button.js +55 -0
  14. package/dist/client/components/callout.d.ts +136 -0
  15. package/dist/client/components/callout.js +99 -0
  16. package/dist/client/components/cards.d.ts +104 -0
  17. package/dist/client/components/cards.js +132 -0
  18. package/dist/client/components/collapse.d.ts +12 -0
  19. package/dist/client/components/collapse.js +143 -0
  20. package/dist/client/components/file-tree/file.d.ts +9 -0
  21. package/dist/client/components/file-tree/file.js +43 -0
  22. package/dist/client/components/file-tree/folder.d.ts +12 -0
  23. package/dist/client/components/file-tree/folder.js +94 -0
  24. package/dist/client/components/file-tree/index.d.ts +57 -0
  25. package/dist/client/components/file-tree/index.js +12 -0
  26. package/dist/client/components/file-tree/tree.d.ts +5 -0
  27. package/dist/client/components/file-tree/tree.js +41 -0
  28. package/dist/client/components/head.d.ts +139 -0
  29. package/dist/client/components/head.js +202 -0
  30. package/dist/client/components/image-zoom.d.ts +6 -0
  31. package/dist/client/components/image-zoom.js +79 -0
  32. package/dist/client/components/index.d.ts +56 -0
  33. package/dist/client/components/index.js +42 -0
  34. package/dist/client/components/playground.d.ts +90 -0
  35. package/dist/client/components/playground.js +103 -0
  36. package/dist/client/components/popup/index.client.d.ts +7 -0
  37. package/dist/client/components/popup/index.client.js +83 -0
  38. package/dist/client/components/popup/index.d.ts +12 -0
  39. package/dist/client/components/popup/index.js +11 -0
  40. package/dist/client/components/search.d.ts +88 -0
  41. package/dist/client/components/search.js +426 -0
  42. package/dist/client/components/select.d.ts +19 -0
  43. package/dist/client/components/select.js +109 -0
  44. package/dist/client/components/skip-nav/index.client.d.ts +5 -0
  45. package/dist/client/components/skip-nav/index.client.js +45 -0
  46. package/dist/client/components/skip-nav/index.d.ts +6 -0
  47. package/dist/client/components/skip-nav/index.js +24 -0
  48. package/dist/client/components/steps.d.ts +64 -0
  49. package/dist/client/components/steps.js +74 -0
  50. package/dist/client/components/tabs/index.client.d.ts +21 -0
  51. package/dist/client/components/tabs/index.client.js +243 -0
  52. package/dist/client/components/tabs/index.d.ts +53 -0
  53. package/dist/client/components/tabs/index.js +9 -0
  54. package/dist/client/evaluate.d.ts +30 -0
  55. package/dist/client/evaluate.js +17 -0
  56. package/dist/client/hocs/index.d.ts +4 -0
  57. package/dist/client/hocs/index.js +6 -0
  58. package/dist/client/hocs/with-github-alert.d.ts +11 -0
  59. package/dist/client/hocs/with-github-alert.js +30 -0
  60. package/dist/client/hocs/with-icons.d.ts +6 -0
  61. package/dist/client/hocs/with-icons.js +76 -0
  62. package/dist/client/hooks/index.d.ts +4 -0
  63. package/dist/client/hooks/index.js +10 -0
  64. package/dist/client/hooks/use-copy.d.ts +9 -0
  65. package/dist/client/hooks/use-copy.js +77 -0
  66. package/dist/client/hooks/use-fs-route.d.ts +3 -0
  67. package/dist/client/hooks/use-fs-route.js +20 -0
  68. package/dist/client/hooks/use-hash.d.ts +3 -0
  69. package/dist/client/hooks/use-hash.js +20 -0
  70. package/dist/client/hooks/use-mounted.d.ts +3 -0
  71. package/dist/client/hooks/use-mounted.js +13 -0
  72. package/dist/client/icons/arrow-right.d.ts +5 -0
  73. package/dist/client/icons/arrow-right.js +24 -0
  74. package/dist/client/icons/chatgpt.d.ts +2 -0
  75. package/dist/client/icons/chatgpt.js +24 -0
  76. package/dist/client/icons/check.d.ts +2 -0
  77. package/dist/client/icons/check.js +24 -0
  78. package/dist/client/icons/claude.d.ts +2 -0
  79. package/dist/client/icons/claude.js +81 -0
  80. package/dist/client/icons/copy.d.ts +2 -0
  81. package/dist/client/icons/copy.js +31 -0
  82. package/dist/client/icons/cpp.d.ts +2 -0
  83. package/dist/client/icons/cpp.js +24 -0
  84. package/dist/client/icons/cross-circled.d.ts +2 -0
  85. package/dist/client/icons/cross-circled.js +24 -0
  86. package/dist/client/icons/csharp.d.ts +2 -0
  87. package/dist/client/icons/csharp.js +24 -0
  88. package/dist/client/icons/css.d.ts +2 -0
  89. package/dist/client/icons/css.js +24 -0
  90. package/dist/client/icons/discord.d.ts +2 -0
  91. package/dist/client/icons/discord.js +24 -0
  92. package/dist/client/icons/expand.d.ts +2 -0
  93. package/dist/client/icons/expand.js +31 -0
  94. package/dist/client/icons/file.d.ts +2 -0
  95. package/dist/client/icons/file.js +24 -0
  96. package/dist/client/icons/folder-open.d.ts +2 -0
  97. package/dist/client/icons/folder-open.js +24 -0
  98. package/dist/client/icons/folder.d.ts +2 -0
  99. package/dist/client/icons/folder.js +24 -0
  100. package/dist/client/icons/github-caution.d.ts +2 -0
  101. package/dist/client/icons/github-caution.js +24 -0
  102. package/dist/client/icons/github-important.d.ts +2 -0
  103. package/dist/client/icons/github-important.js +24 -0
  104. package/dist/client/icons/github-note.d.ts +2 -0
  105. package/dist/client/icons/github-note.js +24 -0
  106. package/dist/client/icons/github-tip.d.ts +2 -0
  107. package/dist/client/icons/github-tip.js +24 -0
  108. package/dist/client/icons/github-warning.d.ts +2 -0
  109. package/dist/client/icons/github-warning.js +24 -0
  110. package/dist/client/icons/github.d.ts +2 -0
  111. package/dist/client/icons/github.js +24 -0
  112. package/dist/client/icons/globe.d.ts +2 -0
  113. package/dist/client/icons/globe.js +24 -0
  114. package/dist/client/icons/go.d.ts +2 -0
  115. package/dist/client/icons/go.js +46 -0
  116. package/dist/client/icons/graphql.d.ts +2 -0
  117. package/dist/client/icons/graphql.js +56 -0
  118. package/dist/client/icons/index.d.ts +2 -0
  119. package/dist/client/icons/index.js +92 -0
  120. package/dist/client/icons/javascript.d.ts +2 -0
  121. package/dist/client/icons/javascript.js +24 -0
  122. package/dist/client/icons/json.d.ts +2 -0
  123. package/dist/client/icons/json.js +41 -0
  124. package/dist/client/icons/link-arrow.d.ts +2 -0
  125. package/dist/client/icons/link-arrow.js +31 -0
  126. package/dist/client/icons/link.d.ts +2 -0
  127. package/dist/client/icons/link.js +24 -0
  128. package/dist/client/icons/markdown.d.ts +2 -0
  129. package/dist/client/icons/markdown.js +24 -0
  130. package/dist/client/icons/mdx.d.ts +2 -0
  131. package/dist/client/icons/mdx.js +24 -0
  132. package/dist/client/icons/menu.d.ts +2 -0
  133. package/dist/client/icons/menu.js +36 -0
  134. package/dist/client/icons/moon.d.ts +2 -0
  135. package/dist/client/icons/moon.js +24 -0
  136. package/dist/client/icons/move.d.ts +2 -0
  137. package/dist/client/icons/move.js +24 -0
  138. package/dist/client/icons/python.d.ts +2 -0
  139. package/dist/client/icons/python.js +31 -0
  140. package/dist/client/icons/react.d.ts +2 -0
  141. package/dist/client/icons/react.js +38 -0
  142. package/dist/client/icons/rust.d.ts +2 -0
  143. package/dist/client/icons/rust.js +31 -0
  144. package/dist/client/icons/spinner.d.ts +2 -0
  145. package/dist/client/icons/spinner.js +31 -0
  146. package/dist/client/icons/sun.d.ts +2 -0
  147. package/dist/client/icons/sun.js +24 -0
  148. package/dist/client/icons/svelte.d.ts +2 -0
  149. package/dist/client/icons/svelte.js +31 -0
  150. package/dist/client/icons/terminal.d.ts +2 -0
  151. package/dist/client/icons/terminal.js +24 -0
  152. package/dist/client/icons/terraform.d.ts +2 -0
  153. package/dist/client/icons/terraform.js +24 -0
  154. package/dist/client/icons/typescript.d.ts +2 -0
  155. package/dist/client/icons/typescript.js +24 -0
  156. package/dist/client/icons/word-wrap.d.ts +2 -0
  157. package/dist/client/icons/word-wrap.js +24 -0
  158. package/dist/client/icons/x.d.ts +2 -0
  159. package/dist/client/icons/x.js +24 -0
  160. package/dist/client/mdx-components/anchor.d.ts +10 -0
  161. package/dist/client/mdx-components/anchor.js +109 -0
  162. package/dist/client/mdx-components/code.d.ts +7 -0
  163. package/dist/client/mdx-components/code.js +52 -0
  164. package/dist/client/mdx-components/details.d.ts +5 -0
  165. package/dist/client/mdx-components/details.js +166 -0
  166. package/dist/client/mdx-components/image.d.ts +28 -0
  167. package/dist/client/mdx-components/image.js +39 -0
  168. package/dist/client/mdx-components/index.d.ts +11 -0
  169. package/dist/client/mdx-components/index.js +16 -0
  170. package/dist/client/mdx-components/pre/copy-to-clipboard.d.ts +5 -0
  171. package/dist/client/mdx-components/pre/copy-to-clipboard.js +49 -0
  172. package/dist/client/mdx-components/pre/index.d.ts +16 -0
  173. package/dist/client/mdx-components/pre/index.js +156 -0
  174. package/dist/client/mdx-components/pre/toggle-word-wrap-button.d.ts +7 -0
  175. package/dist/client/mdx-components/pre/toggle-word-wrap-button.js +31 -0
  176. package/dist/client/mdx-components/summary.d.ts +5 -0
  177. package/dist/client/mdx-components/summary.js +80 -0
  178. package/dist/client/mdx-components/table.d.ts +57 -0
  179. package/dist/client/mdx-components/table.js +95 -0
  180. package/dist/client/mdx-components.d.ts +89 -0
  181. package/dist/client/mdx-components.js +15 -0
  182. package/dist/client/mdx-remote.d.ts +62 -0
  183. package/dist/client/mdx-remote.js +36 -0
  184. package/dist/client/normalize-pages.d.ts +84 -0
  185. package/dist/client/normalize-pages.js +232 -0
  186. package/dist/client/package.json +1 -0
  187. package/dist/client/pages.d.ts +131 -0
  188. package/dist/client/pages.js +39 -0
  189. package/dist/client/remove-links.d.ts +6 -0
  190. package/dist/client/remove-links.js +35 -0
  191. package/dist/client/setup-page.d.ts +18 -0
  192. package/dist/client/setup-page.js +14 -0
  193. package/dist/server/compile-metadata.d.ts +12 -0
  194. package/dist/server/compile-metadata.js +39 -0
  195. package/dist/server/compile.d.ts +39 -0
  196. package/dist/server/compile.js +158 -0
  197. package/dist/server/constants.d.ts +15 -0
  198. package/dist/server/constants.js +22 -0
  199. package/dist/server/fetch-filepaths-from-github.d.ts +10 -0
  200. package/dist/server/fetch-filepaths-from-github.js +36 -0
  201. package/dist/server/index.d.ts +39 -0
  202. package/dist/server/index.js +203 -0
  203. package/dist/server/loader.d.ts +18 -0
  204. package/dist/server/loader.js +155 -0
  205. package/dist/server/locales.d.ts +22 -0
  206. package/dist/server/locales.js +38 -0
  207. package/dist/server/page-map/find-meta-and-page-file-paths.d.ts +8 -0
  208. package/dist/server/page-map/find-meta-and-page-file-paths.js +32 -0
  209. package/dist/server/page-map/get.d.ts +50 -0
  210. package/dist/server/page-map/get.js +28 -0
  211. package/dist/server/page-map/index-page.d.ts +21 -0
  212. package/dist/server/page-map/index-page.js +57 -0
  213. package/dist/server/page-map/index.d.ts +26 -0
  214. package/dist/server/page-map/index.js +24 -0
  215. package/dist/server/page-map/merge-meta-with-page-map.d.ts +17 -0
  216. package/dist/server/page-map/merge-meta-with-page-map.js +74 -0
  217. package/dist/server/page-map/normalize.d.ts +17 -0
  218. package/dist/server/page-map/normalize.js +122 -0
  219. package/dist/server/page-map/placeholder.d.ts +2 -0
  220. package/dist/server/page-map/placeholder.js +0 -0
  221. package/dist/server/page-map/to-ast.d.ts +18 -0
  222. package/dist/server/page-map/to-ast.js +47 -0
  223. package/dist/server/page-map/to-js.d.ts +21 -0
  224. package/dist/server/page-map/to-js.js +72 -0
  225. package/dist/server/page-map/to-page-map.d.ts +26 -0
  226. package/dist/server/page-map/to-page-map.js +101 -0
  227. package/dist/server/recma-plugins/index.d.ts +3 -0
  228. package/dist/server/recma-plugins/index.js +4 -0
  229. package/dist/server/recma-plugins/recma-rewrite.d.ts +11 -0
  230. package/dist/server/recma-plugins/recma-rewrite.js +98 -0
  231. package/dist/server/rehype-plugins/index.d.ts +18 -0
  232. package/dist/server/rehype-plugins/index.js +16 -0
  233. package/dist/server/rehype-plugins/rehype-better-react-mathjax.d.ts +24 -0
  234. package/dist/server/rehype-plugins/rehype-better-react-mathjax.js +96 -0
  235. package/dist/server/rehype-plugins/rehype-extract-toc-content.d.ts +6 -0
  236. package/dist/server/rehype-plugins/rehype-extract-toc-content.js +119 -0
  237. package/dist/server/rehype-plugins/rehype-twoslash-popup.d.ts +6 -0
  238. package/dist/server/rehype-plugins/rehype-twoslash-popup.js +50 -0
  239. package/dist/server/rehype-plugins/rehype.d.ts +21 -0
  240. package/dist/server/rehype-plugins/rehype.js +84 -0
  241. package/dist/server/remark-plugins/index.d.ts +15 -0
  242. package/dist/server/remark-plugins/index.js +26 -0
  243. package/dist/server/remark-plugins/remark-assign-frontmatter.d.ts +10 -0
  244. package/dist/server/remark-plugins/remark-assign-frontmatter.js +24 -0
  245. package/dist/server/remark-plugins/remark-custom-heading-id.d.ts +9 -0
  246. package/dist/server/remark-plugins/remark-custom-heading-id.js +18 -0
  247. package/dist/server/remark-plugins/remark-export-only-metadata.d.ts +6 -0
  248. package/dist/server/remark-plugins/remark-export-only-metadata.js +18 -0
  249. package/dist/server/remark-plugins/remark-export-source-code.d.ts +6 -0
  250. package/dist/server/remark-plugins/remark-export-source-code.js +35 -0
  251. package/dist/server/remark-plugins/remark-headings.d.ts +12 -0
  252. package/dist/server/remark-plugins/remark-headings.js +133 -0
  253. package/dist/server/remark-plugins/remark-link-rewrite.d.ts +11 -0
  254. package/dist/server/remark-plugins/remark-link-rewrite.js +12 -0
  255. package/dist/server/remark-plugins/remark-mdx-disable-explicit-jsx.d.ts +10 -0
  256. package/dist/server/remark-plugins/remark-mdx-disable-explicit-jsx.js +10 -0
  257. package/dist/server/remark-plugins/remark-mdx-frontmatter.d.ts +6 -0
  258. package/dist/server/remark-plugins/remark-mdx-frontmatter.js +37 -0
  259. package/dist/server/remark-plugins/remark-mdx-title.d.ts +10 -0
  260. package/dist/server/remark-plugins/remark-mdx-title.js +53 -0
  261. package/dist/server/remark-plugins/remark-remove-imports.d.ts +6 -0
  262. package/dist/server/remark-plugins/remark-remove-imports.js +12 -0
  263. package/dist/server/remark-plugins/remark-static-image.d.ts +6 -0
  264. package/dist/server/remark-plugins/remark-static-image.js +107 -0
  265. package/dist/server/schemas.d.ts +352 -0
  266. package/dist/server/schemas.js +240 -0
  267. package/dist/server/tsdoc/base.d.ts +38 -0
  268. package/dist/server/tsdoc/base.js +284 -0
  269. package/dist/server/tsdoc/index.d.ts +6 -0
  270. package/dist/server/tsdoc/index.js +10 -0
  271. package/dist/server/tsdoc/tsdoc.d.ts +102 -0
  272. package/dist/server/tsdoc/tsdoc.js +262 -0
  273. package/dist/server/tsdoc/types.d.ts +64 -0
  274. package/dist/server/tsdoc/types.js +0 -0
  275. package/dist/server/tsdoc/zod-to-ts.d.ts +5 -0
  276. package/dist/server/tsdoc/zod-to-ts.js +107 -0
  277. package/dist/server/twoslash.d.ts +6 -0
  278. package/dist/server/twoslash.js +60 -0
  279. package/dist/server/utils.d.ts +12 -0
  280. package/dist/server/utils.js +45 -0
  281. package/dist/types.d.ts +128 -0
  282. package/dist/types.generated.d.ts +203 -0
  283. package/dist/types.generated.js +0 -0
  284. package/dist/types.js +0 -0
  285. package/loader.cjs +24 -0
  286. package/package.json +265 -0
  287. package/styles/cards.css +24 -0
  288. package/styles/code-block.css +266 -0
  289. package/styles/default.css +55 -0
  290. package/styles/react-medium-image-zoom.css +101 -0
  291. package/styles/scrollbar.css +14 -0
  292. package/styles/steps.css +22 -0
  293. package/styles/subheading-anchor.css +25 -0
@@ -0,0 +1,131 @@
1
+ import { EvaluateResult } from '../types.js';
2
+ import 'mdast';
3
+ import 'next';
4
+ import 'react';
5
+ import 'zod';
6
+ import '../server/schemas.js';
7
+ import './lib/index.js';
8
+ import 'rehype-katex/lib/index.js';
9
+ import 'better-react-mathjax';
10
+ import 'rehype-pretty-code';
11
+ import '../types.generated.js';
12
+ import '@mdx-js/mdx';
13
+ import 'rehype-katex';
14
+
15
+ /**
16
+ * Function to import an MDX/Markdown page from the `content` directory.
17
+ *
18
+ * This function is essential for Nextra's dynamic page loading from a catch-all route.
19
+ *
20
+ * @returns
21
+ * A Promise that resolves to an object containing:
22
+ * - `default`: The MDX component to render
23
+ * - `toc`: Table of contents list
24
+ * - `metadata`: Page's front matter or `metadata` object including `title`, `description`, etc.
25
+ *
26
+ * @example
27
+ * ### Basic usage in a dynamic Next.js route
28
+ *
29
+ * ```ts
30
+ * const { default: MDXContent, toc, metadata } = await importPage(['docs', 'getting-started'])
31
+ * ```
32
+ *
33
+ * ### Usage with i18n
34
+ *
35
+ * ```ts
36
+ * const { default: MDXContent } = await importPage(['docs', 'getting-started'], 'en')
37
+ * ```
38
+ *
39
+ * ### Import page's front matter in `generateMetadata` function
40
+ *
41
+ * ```ts
42
+ * // app/[[...mdxPath]]/page.tsx
43
+ * import { importPage } from 'nextra/pages'
44
+ *
45
+ * export async function generateMetadata(props) {
46
+ * const params = await props.params
47
+ * const { metadata } = await importPage(params.mdxPath)
48
+ * return metadata
49
+ * }
50
+ * ```
51
+ *
52
+ * ### Import page in a catch-all route
53
+ *
54
+ * ```tsx
55
+ * // app/[[...mdxPath]]/page.tsx
56
+ * import { generateStaticParamsFor, importPage } from 'nextra/pages'
57
+ * import { useMDXComponents as getMDXComponents } from 'path/to/your/mdx-components'
58
+ *
59
+ * export const generateStaticParams = generateStaticParamsFor('mdxPath')
60
+ *
61
+ * const Wrapper = getMDXComponents().wrapper
62
+ *
63
+ * export default async function Page(props) {
64
+ * const params = await props.params
65
+ * const result = await importPage(params.mdxPath)
66
+ * const { default: MDXContent, toc, metadata } = result
67
+ * return (
68
+ * <Wrapper toc={toc} metadata={metadata}>
69
+ * <MDXContent {...props} params={params} />
70
+ * </Wrapper>
71
+ * )
72
+ * }
73
+ * ```
74
+ *
75
+ * @see
76
+ * - [Content Directory Documentation](https://nextra.site/docs/file-conventions/content-directory)
77
+ * - [Next.js Dynamic Routes](https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes)
78
+ * - [Next.js Metadata API](https://nextjs.org/docs/app/building-your-application/optimizing/metadata)
79
+ */
80
+ declare function importPage(
81
+ /**
82
+ * Array of path segments representing the route to the page.
83
+ *
84
+ * E.g., for the route `/docs/getting-started/installation`, pass `['docs', 'getting-started', 'installation']`.
85
+ * @default []
86
+ */
87
+ pathSegments?: string[],
88
+ /**
89
+ * The language segment when using i18n.
90
+ * @default ''
91
+ */
92
+ lang?: string): Promise<EvaluateResult>;
93
+ /**
94
+ * Generates static parameters based on your `content` directory structure.
95
+ *
96
+ * This helper function is designed to work with Next.js' `generateStaticParams` function to create
97
+ * static paths for all your MDX/Markdown pages.
98
+ *
99
+ * @returns A function that generates an array of parameters for static page generation.
100
+ *
101
+ * @example
102
+ * ### Basic usage with a catch-all route
103
+ *
104
+ * ```ts
105
+ * // app/[[...slug]]/page.tsx
106
+ * export const generateStaticParams = generateStaticParamsFor('slug')
107
+ * ```
108
+ *
109
+ * ### Usage with i18n support
110
+ *
111
+ * ```ts
112
+ * // app/[locale]/[[...mdxPath]]/page.tsx
113
+ * export const generateStaticParams = generateStaticParamsFor('mdxPath', 'locale')
114
+ * ```
115
+ *
116
+ * @see
117
+ * - [Next.js `generateStaticParams` function](https://nextjs.org/docs/app/api-reference/functions/generate-static-params)
118
+ * - [Content Directory Structure](https://nextra.site/docs/file-conventions/content-directory)
119
+ */
120
+ declare function generateStaticParamsFor(
121
+ /** The name of your catch-all route segment (e.g., `'slug'`, `'mdxPath'`). */
122
+ segmentKey: string,
123
+ /**
124
+ * The name of the locale segment when you have i18n.
125
+ * @default "lang"
126
+ */
127
+ localeSegmentKey?: string): () => Promise<{
128
+ [x: string]: string | string[];
129
+ }[]>;
130
+
131
+ export { generateStaticParamsFor, importPage };
@@ -0,0 +1,39 @@
1
+ "use no memo";
2
+ import { notFound } from "next/navigation";
3
+ import { getRouteToFilepath } from "../server/page-map/get.js";
4
+ import { logger } from "../server/utils.js";
5
+ async function importPage(pathSegments = [], lang = "") {
6
+ const RouteToFilepath = await getRouteToFilepath(lang);
7
+ const pathname = pathSegments.join("/");
8
+ const decodedPath = decodeURIComponent(pathname);
9
+ const pagePath = RouteToFilepath[decodedPath];
10
+ try {
11
+ return require(`private-next-content-dir/${lang && `${lang}/`}${pagePath}`);
12
+ } catch (error) {
13
+ logger.error("Error while loading", {
14
+ pathSegments
15
+ }, error);
16
+ notFound();
17
+ }
18
+ }
19
+ function generateStaticParamsFor(segmentKey, localeSegmentKey = "lang") {
20
+ return async () => {
21
+ const locales = JSON.parse(process.env.NEXTRA_LOCALES);
22
+ const result = [];
23
+ for (const locale of locales) {
24
+ const RouteToFilepath = await getRouteToFilepath(locale);
25
+ const routes = Object.keys(RouteToFilepath);
26
+ result.push(...routes.map((route) => ({
27
+ ...locale && {
28
+ [localeSegmentKey]: locale
29
+ },
30
+ [segmentKey]: route.split("/")
31
+ })));
32
+ }
33
+ return result;
34
+ };
35
+ }
36
+ export {
37
+ generateStaticParamsFor,
38
+ importPage
39
+ };
@@ -0,0 +1,6 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+
3
+ type TOCElement = ReactElement | string;
4
+ declare function removeLinks(node: ReactNode): TOCElement[] | string;
5
+
6
+ export { removeLinks };
@@ -0,0 +1,35 @@
1
+ "use no memo";
2
+ import { Children, cloneElement } from "react";
3
+ function hasProps(node) {
4
+ return !!node && typeof node === "object";
5
+ }
6
+ function removeLinks(node) {
7
+ if (typeof node === "string") {
8
+ return node;
9
+ }
10
+ return Children.map(node, (child) => {
11
+ if (hasProps(child) && // @ts-expect-error -- fixme
12
+ child.props.href) {
13
+ if (child.props["data-footnote-ref"]) {
14
+ return;
15
+ }
16
+ child = child.props.children;
17
+ }
18
+ if (typeof child === "string") {
19
+ return child;
20
+ }
21
+ if (Array.isArray(child)) {
22
+ return removeLinks(child);
23
+ }
24
+ if (!hasProps(child)) {
25
+ return child;
26
+ }
27
+ const children = removeLinks(child.props.children);
28
+ return cloneElement(child, {
29
+ children
30
+ });
31
+ });
32
+ }
33
+ export {
34
+ removeLinks
35
+ };
@@ -0,0 +1,18 @@
1
+ import { ComponentProps, FC } from 'react';
2
+ import { MDXWrapper } from '../types.js';
3
+ import 'mdast';
4
+ import 'next';
5
+ import 'zod';
6
+ import '../server/schemas.js';
7
+ import './lib/index.js';
8
+ import 'rehype-katex/lib/index.js';
9
+ import 'better-react-mathjax';
10
+ import 'rehype-pretty-code';
11
+ import '../types.generated.js';
12
+ import '@mdx-js/mdx';
13
+ import 'rehype-katex';
14
+
15
+ type WrapperProps = ComponentProps<MDXWrapper>;
16
+ declare function HOC_MDXWrapper(MDXContent: MDXWrapper, hocProps: Omit<WrapperProps, 'children'>): FC<WrapperProps>;
17
+
18
+ export { HOC_MDXWrapper };
@@ -0,0 +1,14 @@
1
+ "use no memo";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useMDXComponents as getMDXComponents } from "next-mdx-import-source-file";
4
+ import { createElement } from "react";
5
+ const Wrapper = getMDXComponents().wrapper;
6
+ function HOC_MDXWrapper(MDXContent, hocProps) {
7
+ return function MDXWrapper(props) {
8
+ const children = createElement(MDXContent, props);
9
+ return Wrapper ? /* @__PURE__ */ jsx(Wrapper, { ...hocProps, children }) : children;
10
+ };
11
+ }
12
+ export {
13
+ HOC_MDXWrapper
14
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `nextra/dist/server/page-map/placeholder.js` imports all `metadata`s from `.md`/`.mdx` files to
3
+ * build `pageMap`.
4
+ * If a request includes the resource query `?metadata`, compiling MDX to JSX is unnecessary.
5
+ * This step can be skipped to improve performance in the development environment.
6
+ */
7
+ declare function compileMetadata(source: string, { filePath, lastCommitTime }: {
8
+ filePath: string;
9
+ lastCommitTime?: number;
10
+ }): Promise<string>;
11
+
12
+ export { compileMetadata };
@@ -0,0 +1,39 @@
1
+ import { createProcessor } from "@mdx-js/mdx";
2
+ import remarkFrontmatter from "remark-frontmatter";
3
+ import remarkMath from "remark-math";
4
+ import {
5
+ remarkAssignFrontMatter,
6
+ remarkExportOnlyMetadata,
7
+ remarkMdxFrontMatter,
8
+ remarkMdxTitle
9
+ } from "./remark-plugins/index.js";
10
+ async function compileMetadata(source, { filePath, lastCommitTime }) {
11
+ const format = filePath.endsWith(".mdx") ? "mdx" : "md";
12
+ const compiler = createProcessor({
13
+ format,
14
+ remarkPlugins: [
15
+ remarkFrontmatter,
16
+ // parse and attach yaml node
17
+ remarkMdxFrontMatter,
18
+ remarkMdxTitle,
19
+ [remarkAssignFrontMatter, { lastCommitTime }],
20
+ remarkExportOnlyMetadata,
21
+ remarkMath
22
+ // https://github.com/shuding/nextra/issues/4164
23
+ ],
24
+ recmaPlugins: [recmaExportOnlyMetadata]
25
+ });
26
+ const vFile = await compiler.process({ value: source, path: filePath });
27
+ return vFile.value;
28
+ }
29
+ const transformer = (ast) => {
30
+ const importReact = ast.body[0];
31
+ ast.body = ast.body.filter(
32
+ (node) => node.type === "ExportNamedDeclaration" && node.declaration.declarations[0].id.name === "metadata"
33
+ );
34
+ ast.body.unshift(importReact);
35
+ };
36
+ const recmaExportOnlyMetadata = () => transformer;
37
+ export {
38
+ compileMetadata
39
+ };
@@ -0,0 +1,39 @@
1
+ import { ProcessorOptions } from '@mdx-js/mdx';
2
+ import { LoaderOptions } from '../types.js';
3
+ import { NextraConfig } from '../types.generated.js';
4
+ import 'mdast';
5
+ import 'next';
6
+ import 'react';
7
+ import 'zod';
8
+ import './schemas.js';
9
+ import './lib/index.js';
10
+ import 'rehype-katex/lib/index.js';
11
+ import 'better-react-mathjax';
12
+ import 'rehype-pretty-code';
13
+ import 'rehype-katex';
14
+
15
+ type MdxOptions = NextraConfig['mdxOptions'] & Pick<ProcessorOptions, 'jsx' | 'outputFormat' | 'providerImportSource'>;
16
+ type CompileMdxOptions = Pick<LoaderOptions, 'staticImage' | 'search' | 'defaultShowCopyCode' | 'readingTime' | 'latex' | 'codeHighlight' | 'whiteListTagsStyling'> & {
17
+ /** @default {} */
18
+ mdxOptions: MdxOptions;
19
+ /** @default '' */
20
+ filePath: string;
21
+ useCachedCompiler: boolean;
22
+ /** @default false */
23
+ isPageImport: boolean;
24
+ lastCommitTime: number;
25
+ };
26
+ /**
27
+ * @example
28
+ * ```ts
29
+ * // Usage with MDXRemote
30
+ * import { compileMdx } from 'nextra/compile'
31
+ * import { MDXRemote } from 'nextra/mdx-remote'
32
+ *
33
+ * const rawJs = await compileMdx(rawMdx)
34
+ * const content = <MDXRemote compiledSource={rawJs} components={...} scope={...} />
35
+ * ```
36
+ */
37
+ declare function compileMdx(rawMdx: string, { staticImage, search, readingTime, latex, codeHighlight, defaultShowCopyCode, mdxOptions, filePath, useCachedCompiler, isPageImport, whiteListTagsStyling, lastCommitTime }?: Partial<CompileMdxOptions>): Promise<string>;
38
+
39
+ export { compileMdx };
@@ -0,0 +1,158 @@
1
+ import { createProcessor } from "@mdx-js/mdx";
2
+ import { remarkMermaid } from "@theguild/remark-mermaid";
3
+ import { remarkNpm2Yarn } from "@theguild/remark-npm2yarn";
4
+ import rehypeKatex from "rehype-katex";
5
+ import rehypePrettyCode from "rehype-pretty-code";
6
+ import rehypeRaw from "rehype-raw";
7
+ import remarkFrontmatter from "remark-frontmatter";
8
+ import remarkGfm from "remark-gfm";
9
+ import remarkMath from "remark-math";
10
+ import remarkReadingTime from "remark-reading-time";
11
+ import remarkSmartypants from "remark-smartypants";
12
+ import { MARKDOWN_URL_EXTENSION_RE } from "./constants.js";
13
+ import { recmaRewrite } from "./recma-plugins/index.js";
14
+ import {
15
+ DEFAULT_REHYPE_PRETTY_CODE_OPTIONS,
16
+ rehypeAttachCodeMeta,
17
+ rehypeBetterReactMathjax,
18
+ rehypeExtractTocContent,
19
+ rehypeParseCodeMeta,
20
+ rehypeTwoslashPopup
21
+ } from "./rehype-plugins/index.js";
22
+ import {
23
+ remarkAssignFrontMatter,
24
+ remarkCustomHeadingId,
25
+ remarkExportSourceCode,
26
+ remarkHeadings,
27
+ remarkLinkRewrite,
28
+ remarkMdxDisableExplicitJsx,
29
+ remarkMdxFrontMatter,
30
+ remarkMdxTitle,
31
+ remarkRemoveImports,
32
+ remarkStaticImage
33
+ } from "./remark-plugins/index.js";
34
+ const cachedCompilerForFormat = /* @__PURE__ */ Object.create(null);
35
+ async function compileMdx(rawMdx, {
36
+ staticImage,
37
+ search,
38
+ readingTime,
39
+ latex,
40
+ codeHighlight,
41
+ defaultShowCopyCode,
42
+ mdxOptions = {},
43
+ filePath = "",
44
+ useCachedCompiler,
45
+ isPageImport = false,
46
+ whiteListTagsStyling = [],
47
+ lastCommitTime
48
+ } = {}) {
49
+ const {
50
+ jsx = false,
51
+ format: _format = "mdx",
52
+ outputFormat = "function-body",
53
+ remarkPlugins,
54
+ rehypePlugins,
55
+ recmaPlugins,
56
+ rehypePrettyCodeOptions,
57
+ providerImportSource = "next-mdx-import-source-file"
58
+ } = mdxOptions;
59
+ const format = _format === "detect" ? filePath.endsWith(".mdx") ? "mdx" : "md" : _format;
60
+ const fileCompatible = filePath ? { value: rawMdx, path: filePath } : rawMdx;
61
+ const isRemoteContent = outputFormat === "function-body";
62
+ const compiler = !useCachedCompiler || isRemoteContent ? createCompiler() : cachedCompilerForFormat[`${format}:${isPageImport}`] ||= createCompiler();
63
+ const processor = compiler();
64
+ try {
65
+ const vFile = await processor.process(fileCompatible);
66
+ const rawJs = vFile.value.replaceAll("__esModule", String.raw`_\_esModule`);
67
+ return rawJs;
68
+ } catch (error) {
69
+ console.error(`[nextra] Error compiling ${filePath}.`);
70
+ throw error;
71
+ }
72
+ function createCompiler() {
73
+ return createProcessor({
74
+ jsx,
75
+ format,
76
+ outputFormat,
77
+ providerImportSource,
78
+ // Fix TypeError: _jsx is not a function for remote content
79
+ development: process.env.NODE_ENV === "development",
80
+ remarkPlugins: [
81
+ ...remarkPlugins || [],
82
+ remarkMermaid,
83
+ // should be before remarkRemoveImports because contains `import { Mermaid } from ...`
84
+ [
85
+ remarkNpm2Yarn,
86
+ // should be before remarkRemoveImports because contains `import { Tabs as $Tabs, Tab as $Tab } from ...`
87
+ {
88
+ packageName: "nextra/components",
89
+ tabNamesProp: "items",
90
+ storageKey: "selectedPackageManager"
91
+ }
92
+ ],
93
+ isRemoteContent && remarkRemoveImports,
94
+ remarkFrontmatter,
95
+ // parse and attach yaml node
96
+ remarkMdxFrontMatter,
97
+ readingTime && remarkReadingTime,
98
+ // before mdx title
99
+ remarkCustomHeadingId,
100
+ remarkMdxTitle,
101
+ [remarkAssignFrontMatter, { lastCommitTime }],
102
+ remarkGfm,
103
+ format !== "md" && [
104
+ remarkMdxDisableExplicitJsx,
105
+ // Replace the <summary> and <details> with customized components
106
+ { whiteList: ["details", "summary", ...whiteListTagsStyling] }
107
+ ],
108
+ [remarkHeadings, { isRemoteContent }],
109
+ staticImage && remarkStaticImage,
110
+ latex && remarkMath,
111
+ // Remove the markdown file extension from links
112
+ [
113
+ remarkLinkRewrite,
114
+ {
115
+ pattern: MARKDOWN_URL_EXTENSION_RE,
116
+ replace: "",
117
+ excludeExternalLinks: true
118
+ }
119
+ ],
120
+ remarkSmartypants,
121
+ remarkExportSourceCode
122
+ ].filter((v) => !!v),
123
+ rehypePlugins: [
124
+ ...rehypePlugins || [],
125
+ format === "md" && [
126
+ // To render `<details>` and `<summary>` correctly
127
+ rehypeRaw,
128
+ // fix Error: Cannot compile `mdxjsEsm` node for npm2yarn and mermaid
129
+ {
130
+ passThrough: ["mdxjsEsm", "mdxJsxFlowElement", "mdxTextExpression"]
131
+ }
132
+ ],
133
+ [rehypeParseCodeMeta, { defaultShowCopyCode }],
134
+ // Should be before `rehypePrettyCode`
135
+ latex && (typeof latex === "object" ? latex.renderer === "mathjax" ? [rehypeBetterReactMathjax, latex.options, isRemoteContent] : [rehypeKatex, latex.options] : rehypeKatex),
136
+ ...codeHighlight === false ? [] : [
137
+ [
138
+ rehypePrettyCode,
139
+ {
140
+ ...DEFAULT_REHYPE_PRETTY_CODE_OPTIONS,
141
+ ...rehypePrettyCodeOptions
142
+ }
143
+ ],
144
+ rehypeTwoslashPopup,
145
+ [rehypeAttachCodeMeta, { search }]
146
+ ],
147
+ rehypeExtractTocContent
148
+ ].filter((v) => !!v),
149
+ recmaPlugins: [
150
+ ...recmaPlugins || [],
151
+ [recmaRewrite, { isPageImport, isRemoteContent }]
152
+ ]
153
+ });
154
+ }
155
+ }
156
+ export {
157
+ compileMdx
158
+ };
@@ -0,0 +1,15 @@
1
+ declare const MARKDOWN_EXTENSION_RE: RegExp;
2
+ declare const CWD: string;
3
+ declare const MARKDOWN_URL_EXTENSION_RE: RegExp;
4
+ declare const IS_PRODUCTION: boolean;
5
+ declare const EXTERNAL_URL_RE: RegExp;
6
+ declare const DEFAULT_PROPERTY_PROPS: {
7
+ type: "Property";
8
+ kind: "init";
9
+ method: false;
10
+ shorthand: false;
11
+ computed: false;
12
+ };
13
+ declare const METADATA_ONLY_RQ = "?metadata";
14
+
15
+ export { CWD, DEFAULT_PROPERTY_PROPS, EXTERNAL_URL_RE, IS_PRODUCTION, MARKDOWN_EXTENSION_RE, MARKDOWN_URL_EXTENSION_RE, METADATA_ONLY_RQ };
@@ -0,0 +1,22 @@
1
+ const MARKDOWN_EXTENSION_RE = /\.mdx?$/;
2
+ const CWD = process.cwd();
3
+ const MARKDOWN_URL_EXTENSION_RE = /\.mdx?(?:(?=[#?])|$)/;
4
+ const IS_PRODUCTION = process.env.NODE_ENV === "production";
5
+ const EXTERNAL_URL_RE = /^https?:\/\//;
6
+ const DEFAULT_PROPERTY_PROPS = {
7
+ type: "Property",
8
+ kind: "init",
9
+ method: false,
10
+ shorthand: false,
11
+ computed: false
12
+ };
13
+ const METADATA_ONLY_RQ = "?metadata";
14
+ export {
15
+ CWD,
16
+ DEFAULT_PROPERTY_PROPS,
17
+ EXTERNAL_URL_RE,
18
+ IS_PRODUCTION,
19
+ MARKDOWN_EXTENSION_RE,
20
+ MARKDOWN_URL_EXTENSION_RE,
21
+ METADATA_ONLY_RQ
22
+ };
@@ -0,0 +1,10 @@
1
+ type Params = {
2
+ user: string;
3
+ repo: string;
4
+ branch: string;
5
+ docsPath: string;
6
+ outputPath: string;
7
+ };
8
+ declare function fetchFilePathsFromGitHub({ user, repo, branch, docsPath, outputPath }: Params): Promise<void>;
9
+
10
+ export { fetchFilePathsFromGitHub };
@@ -0,0 +1,36 @@
1
+ import fs from "fs/promises";
2
+ import { MARKDOWN_EXTENSION_RE } from "./constants.js";
3
+ async function fetchFilePathsFromGitHub({
4
+ user,
5
+ repo,
6
+ branch,
7
+ docsPath,
8
+ outputPath
9
+ }) {
10
+ const url = `https://api.github.com/repos/${user}/${repo}/git/trees/${branch}?recursive=1`;
11
+ const response = await fetch(url);
12
+ const data = await response.json();
13
+ if (data.message) {
14
+ console.error(
15
+ "\u274C GitHub API rate limit exceeded, skipping\u2026",
16
+ JSON.stringify(data, null, 2)
17
+ );
18
+ process.exit(0);
19
+ }
20
+ const filePaths = data.tree.filter((item) => item.path.startsWith(docsPath)).map((item) => item.path.replace(docsPath, ""));
21
+ const result = {
22
+ user,
23
+ repo,
24
+ branch,
25
+ docsPath,
26
+ filePaths: filePaths.filter(
27
+ (filePath) => MARKDOWN_EXTENSION_RE.test(filePath)
28
+ )
29
+ };
30
+ const json = JSON.stringify(result, null, 2);
31
+ await fs.writeFile(outputPath, json);
32
+ console.log(`\u2705 Remote files from "${url}" saved!`);
33
+ }
34
+ export {
35
+ fetchFilePathsFromGitHub
36
+ };
@@ -0,0 +1,39 @@
1
+ import { NextConfig } from 'next';
2
+ export { $NextraMetadata, DynamicFolder, DynamicMeta, DynamicMetaItem, EvaluateResult, Folder, FrontMatter, Heading, Import, LoaderOptions, MDXWrapper, MathJaxOptions, MdxFile, MenuItem, Meta, MetaJsonFile, MetaRecord, NextraMetadata, Page, PageMapItem, PagefindSearchOptions, ReadingTime, SeparatorItem, TItem } from '../types.js';
3
+ import { NextraConfig } from '../types.generated.js';
4
+ import 'mdast';
5
+ import 'react';
6
+ import 'zod';
7
+ import './schemas.js';
8
+ import './lib/index.js';
9
+ import 'rehype-katex/lib/index.js';
10
+ import 'better-react-mathjax';
11
+ import 'rehype-pretty-code';
12
+ import '@mdx-js/mdx';
13
+ import 'rehype-katex';
14
+
15
+ /**
16
+ * Nextra is a Next.js plugin that allows you to create Markdown-based content with ease.
17
+ *
18
+ * @example
19
+ * ```js filename="next.config.mjs"
20
+ * import nextra from 'nextra'
21
+ *
22
+ * // Set up Nextra with its configuration
23
+ * const withNextra = nextra({
24
+ * // ... Add Nextra-specific options here
25
+ * })
26
+ *
27
+ * // Export the final Next.js config with Nextra included
28
+ * export default withNextra({
29
+ * // ... Add regular Next.js options here
30
+ * })
31
+ * ```
32
+ * @see
33
+ * - [`NextraConfig` options](https://nextra.site/api/nextra)
34
+ * - [Nextra documentation](https://nextra.site)
35
+ * - [`NextConfig` options](https://nextjs.org/docs/pages/api-reference/config/next-config-js)
36
+ */
37
+ declare const nextra: (nextraConfig: NextraConfig) => (nextConfig?: NextConfig) => NextConfig;
38
+
39
+ export { NextraConfig, nextra as default };