@vercel/geistdocs 1.2.2 → 1.2.3-canary.48fea3c

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 (339) hide show
  1. package/dist/cli/index.js +3 -0
  2. package/dist/components/callout.d.ts +12 -0
  3. package/dist/components/callout.d.ts.map +1 -0
  4. package/dist/components/callout.js +7 -0
  5. package/dist/components/code-block-tabs.d.ts +7 -0
  6. package/dist/components/code-block-tabs.d.ts.map +1 -0
  7. package/dist/components/code-block-tabs.js +7 -0
  8. package/dist/components/code-block.d.ts +14 -0
  9. package/dist/components/code-block.d.ts.map +1 -0
  10. package/dist/components/code-block.js +45 -0
  11. package/dist/components/copy-prompt.d.ts +11 -0
  12. package/dist/components/copy-prompt.d.ts.map +1 -0
  13. package/dist/components/copy-prompt.js +58 -0
  14. package/dist/components/mermaid.d.ts +4 -0
  15. package/dist/components/mermaid.d.ts.map +1 -0
  16. package/dist/components/mermaid.js +44 -0
  17. package/dist/components/theme-aware-image.d.ts +12 -0
  18. package/dist/components/theme-aware-image.d.ts.map +1 -0
  19. package/dist/components/theme-aware-image.js +8 -0
  20. package/dist/components/video.d.ts +6 -0
  21. package/dist/components/video.d.ts.map +1 -0
  22. package/dist/components/video.js +3 -0
  23. package/dist/config.d.ts +71 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +1 -0
  26. package/dist/controls.d.ts +15 -0
  27. package/dist/controls.d.ts.map +1 -0
  28. package/dist/controls.js +52 -0
  29. package/dist/internal/chat/context.d.ts +19 -0
  30. package/dist/internal/chat/context.d.ts.map +1 -0
  31. package/dist/internal/chat/context.js +36 -0
  32. package/dist/internal/chat/conversation.d.ts +10 -0
  33. package/dist/internal/chat/conversation.d.ts.map +1 -0
  34. package/dist/internal/chat/conversation.js +16 -0
  35. package/dist/internal/chat/copy-chat.d.ts +5 -0
  36. package/dist/internal/chat/copy-chat.d.ts.map +1 -0
  37. package/dist/internal/chat/copy-chat.js +35 -0
  38. package/dist/internal/chat/db.d.ts +13 -0
  39. package/dist/internal/chat/db.d.ts.map +1 -0
  40. package/dist/internal/chat/db.js +19 -0
  41. package/dist/internal/chat/message-metadata.d.ts +8 -0
  42. package/dist/internal/chat/message-metadata.d.ts.map +1 -0
  43. package/dist/internal/chat/message-metadata.js +29 -0
  44. package/dist/internal/chat/message.d.ts +11 -0
  45. package/dist/internal/chat/message.d.ts.map +1 -0
  46. package/dist/internal/chat/message.js +11 -0
  47. package/dist/internal/chat/prompt-input.d.ts +13 -0
  48. package/dist/internal/chat/prompt-input.d.ts.map +1 -0
  49. package/dist/internal/chat/prompt-input.js +39 -0
  50. package/dist/internal/chat/shell.d.ts +2 -0
  51. package/dist/internal/chat/shell.d.ts.map +1 -0
  52. package/dist/internal/chat/shell.js +194 -0
  53. package/dist/internal/chat/shimmer.d.ts +11 -0
  54. package/dist/internal/chat/shimmer.d.ts.map +1 -0
  55. package/dist/internal/chat/shimmer.js +18 -0
  56. package/dist/internal/chat/sources.d.ts +13 -0
  57. package/dist/internal/chat/sources.d.ts.map +1 -0
  58. package/dist/internal/chat/sources.js +9 -0
  59. package/dist/internal/chat/suggestion.d.ts +11 -0
  60. package/dist/internal/chat/suggestion.d.ts.map +1 -0
  61. package/dist/internal/chat/suggestion.js +12 -0
  62. package/dist/internal/cn.d.ts +3 -0
  63. package/dist/internal/cn.d.ts.map +1 -0
  64. package/dist/internal/cn.js +3 -0
  65. package/dist/internal/feedback-action.d.ts +14 -0
  66. package/dist/internal/feedback-action.d.ts.map +1 -0
  67. package/dist/internal/feedback-action.js +34 -0
  68. package/dist/internal/i18n.d.ts +6 -0
  69. package/dist/internal/i18n.d.ts.map +1 -0
  70. package/dist/internal/i18n.js +18 -0
  71. package/dist/internal/languages.d.ts +7 -0
  72. package/dist/internal/languages.d.ts.map +1 -0
  73. package/dist/internal/languages.js +18 -0
  74. package/dist/internal/not-implemented.d.ts +2 -0
  75. package/dist/internal/not-implemented.d.ts.map +1 -0
  76. package/dist/internal/not-implemented.js +4 -0
  77. package/dist/internal/page-actions-client.d.ts +13 -0
  78. package/dist/internal/page-actions-client.d.ts.map +1 -0
  79. package/dist/internal/page-actions-client.js +160 -0
  80. package/dist/internal/page-actions.d.ts +18 -0
  81. package/dist/internal/page-actions.d.ts.map +1 -0
  82. package/dist/internal/page-actions.js +4 -0
  83. package/dist/internal/provider-client.d.ts +9 -0
  84. package/dist/internal/provider-client.d.ts.map +1 -0
  85. package/dist/internal/provider-client.js +23 -0
  86. package/dist/internal/search.d.ts +5 -0
  87. package/dist/internal/search.d.ts.map +1 -0
  88. package/dist/internal/search.js +14 -0
  89. package/dist/internal/sidebar.d.ts +9 -0
  90. package/dist/internal/sidebar.d.ts.map +1 -0
  91. package/dist/internal/sidebar.js +38 -0
  92. package/dist/internal/table-of-contents.d.ts +9 -0
  93. package/dist/internal/table-of-contents.d.ts.map +1 -0
  94. package/dist/internal/table-of-contents.js +5 -0
  95. package/dist/internal/ui/button-group.d.ts +13 -0
  96. package/dist/internal/ui/button-group.d.ts.map +1 -0
  97. package/dist/internal/ui/button-group.js +26 -0
  98. package/dist/internal/ui/button.d.ts +12 -0
  99. package/dist/internal/ui/button.d.ts.map +1 -0
  100. package/dist/internal/ui/button.js +33 -0
  101. package/dist/internal/ui/card.d.ts +6 -0
  102. package/dist/internal/ui/card.d.ts.map +1 -0
  103. package/dist/internal/ui/card.js +14 -0
  104. package/dist/internal/ui/collapsible.d.ts +6 -0
  105. package/dist/internal/ui/collapsible.d.ts.map +1 -0
  106. package/dist/internal/ui/collapsible.js +12 -0
  107. package/dist/internal/ui/drawer.d.ts +6 -0
  108. package/dist/internal/ui/drawer.d.ts.map +1 -0
  109. package/dist/internal/ui/drawer.js +13 -0
  110. package/dist/internal/ui/dropdown-menu.d.ts +22 -0
  111. package/dist/internal/ui/dropdown-menu.d.ts.map +1 -0
  112. package/dist/internal/ui/dropdown-menu.js +41 -0
  113. package/dist/internal/ui/input-group.d.ts +15 -0
  114. package/dist/internal/ui/input-group.d.ts.map +1 -0
  115. package/dist/internal/ui/input-group.js +44 -0
  116. package/dist/internal/ui/input.d.ts +3 -0
  117. package/dist/internal/ui/input.d.ts.map +1 -0
  118. package/dist/internal/ui/input.js +5 -0
  119. package/dist/internal/ui/kbd.d.ts +4 -0
  120. package/dist/internal/ui/kbd.d.ts.map +1 -0
  121. package/dist/internal/ui/kbd.js +8 -0
  122. package/dist/internal/ui/popover.d.ts +6 -0
  123. package/dist/internal/ui/popover.d.ts.map +1 -0
  124. package/dist/internal/ui/popover.js +13 -0
  125. package/dist/internal/ui/scroll-area.d.ts +5 -0
  126. package/dist/internal/ui/scroll-area.d.ts.map +1 -0
  127. package/dist/internal/ui/scroll-area.js +12 -0
  128. package/dist/internal/ui/separator.d.ts +4 -0
  129. package/dist/internal/ui/separator.d.ts.map +1 -0
  130. package/dist/internal/ui/separator.js +7 -0
  131. package/dist/internal/ui/sheet.d.ts +10 -0
  132. package/dist/internal/ui/sheet.d.ts.map +1 -0
  133. package/dist/internal/ui/sheet.js +24 -0
  134. package/dist/internal/ui/sonner.d.ts +3 -0
  135. package/dist/internal/ui/sonner.d.ts.map +1 -0
  136. package/dist/internal/ui/sonner.js +20 -0
  137. package/dist/internal/ui/spinner.d.ts +3 -0
  138. package/dist/internal/ui/spinner.d.ts.map +1 -0
  139. package/dist/internal/ui/spinner.js +6 -0
  140. package/dist/internal/ui/textarea.d.ts +3 -0
  141. package/dist/internal/ui/textarea.d.ts.map +1 -0
  142. package/dist/internal/ui/textarea.js +5 -0
  143. package/dist/internal/ui/tooltip.d.ts +7 -0
  144. package/dist/internal/ui/tooltip.d.ts.map +1 -0
  145. package/dist/internal/ui/tooltip.js +16 -0
  146. package/dist/internal/use-mobile.d.ts +2 -0
  147. package/dist/internal/use-mobile.d.ts.map +1 -0
  148. package/dist/internal/use-mobile.js +16 -0
  149. package/dist/layout.d.ts +14 -0
  150. package/dist/layout.d.ts.map +1 -0
  151. package/dist/layout.js +31 -0
  152. package/dist/mdx.d.ts +36 -0
  153. package/dist/mdx.d.ts.map +1 -0
  154. package/dist/mdx.js +74 -0
  155. package/dist/pages/docs.d.ts +77 -0
  156. package/dist/pages/docs.d.ts.map +1 -0
  157. package/dist/pages/docs.js +92 -0
  158. package/dist/proxy.d.ts +37 -0
  159. package/dist/proxy.d.ts.map +1 -0
  160. package/dist/proxy.js +162 -0
  161. package/dist/routes/chat.d.ts +14 -0
  162. package/dist/routes/chat.d.ts.map +1 -0
  163. package/dist/routes/chat.js +242 -0
  164. package/dist/routes/llms.d.ts +51 -0
  165. package/dist/routes/llms.d.ts.map +1 -0
  166. package/dist/routes/llms.js +59 -0
  167. package/dist/routes/search.d.ts +11 -0
  168. package/dist/routes/search.d.ts.map +1 -0
  169. package/dist/routes/search.js +74 -0
  170. package/dist/routes/sitemap.d.ts +44 -0
  171. package/dist/routes/sitemap.d.ts.map +1 -0
  172. package/dist/routes/sitemap.js +168 -0
  173. package/dist/sidebar.d.ts +11 -0
  174. package/dist/sidebar.d.ts.map +1 -0
  175. package/dist/sidebar.js +16 -0
  176. package/dist/source.d.ts +174 -0
  177. package/dist/source.d.ts.map +1 -0
  178. package/dist/source.js +129 -0
  179. package/dist/versions.d.ts +15 -0
  180. package/dist/versions.d.ts.map +1 -0
  181. package/dist/versions.js +52 -0
  182. package/package.json +141 -9
  183. package/styles.css +193 -0
  184. package/template/_gitignore +29 -0
  185. package/template/app/[lang]/(home)/components/centered-section.tsx +26 -0
  186. package/template/app/[lang]/(home)/components/cta.tsx +19 -0
  187. package/template/app/[lang]/(home)/components/hero.tsx +27 -0
  188. package/template/app/[lang]/(home)/components/one-two-section.tsx +25 -0
  189. package/template/app/[lang]/(home)/components/templates.tsx +50 -0
  190. package/template/app/[lang]/(home)/components/text-grid-section.tsx +20 -0
  191. package/template/app/[lang]/(home)/layout.tsx +14 -0
  192. package/template/app/[lang]/(home)/page.tsx +126 -0
  193. package/template/app/[lang]/docs/[[...slug]]/page.tsx +19 -0
  194. package/template/app/[lang]/docs/layout.tsx +14 -0
  195. package/template/app/[lang]/layout.tsx +29 -0
  196. package/template/app/[lang]/llms.mdx/[[...slug]]/route.ts +7 -0
  197. package/template/app/[lang]/llms.txt/route.ts +6 -0
  198. package/template/app/[lang]/og/[...slug]/background.png +0 -0
  199. package/template/app/[lang]/og/[...slug]/geist-sans-regular.ttf +0 -0
  200. package/template/app/[lang]/og/[...slug]/geist-sans-semibold.ttf +0 -0
  201. package/template/app/[lang]/og/[...slug]/route.tsx +95 -0
  202. package/template/app/[lang]/rss.xml/route.ts +52 -0
  203. package/template/app/[lang]/sitemap.md/route.ts +9 -0
  204. package/template/app/actions/feedback/emotions.ts +18 -0
  205. package/template/app/actions/feedback/index.ts +45 -0
  206. package/template/app/api/chat/route.ts +8 -0
  207. package/template/app/api/search/route.ts +5 -0
  208. package/template/app/favicon.ico +0 -0
  209. package/template/app/global.css +2 -0
  210. package/template/app/robots.ts +14 -0
  211. package/template/app/sitemap.ts +36 -0
  212. package/template/app/styles/geistdocs.css +554 -0
  213. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right-small.tsx +35 -0
  214. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right.tsx +27 -0
  215. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-check.tsx +27 -0
  216. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-down-small.tsx +30 -0
  217. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-right.tsx +27 -0
  218. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-copy.tsx +27 -0
  219. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-file-text.tsx +25 -0
  220. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-menu-alt.tsx +27 -0
  221. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-slash-forward.tsx +36 -0
  222. package/template/components/geistcn-fallbacks/geistcn-assets/icons/index.tsx +11 -0
  223. package/template/components/geistcn-fallbacks/geistcn-assets/logos/index.tsx +14 -0
  224. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-elements.tsx +29 -0
  225. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-sdk.tsx +38 -0
  226. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-chat-sdk.tsx +42 -0
  227. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-flags-sdk.tsx +42 -0
  228. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-icon-vercel.tsx +31 -0
  229. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-streamdown.tsx +29 -0
  230. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-vercel-oss.tsx +24 -0
  231. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-workflow-sdk.tsx +73 -0
  232. package/template/components/geistdocs/callout.tsx +40 -0
  233. package/template/components/geistdocs/chat.tsx +24 -0
  234. package/template/components/geistdocs/code-block-tabs.tsx +61 -0
  235. package/template/components/geistdocs/code-block.tsx +134 -0
  236. package/template/components/geistdocs/copy-page.tsx +27 -0
  237. package/template/components/geistdocs/desktop-menu.tsx +52 -0
  238. package/template/components/geistdocs/docs-layout.tsx +20 -0
  239. package/template/components/geistdocs/docs-page.tsx +35 -0
  240. package/template/components/geistdocs/edit-source.tsx +30 -0
  241. package/template/components/geistdocs/feedback.tsx +139 -0
  242. package/template/components/geistdocs/footer.tsx +30 -0
  243. package/template/components/geistdocs/github-button.tsx +19 -0
  244. package/template/components/geistdocs/home-layout.tsx +46 -0
  245. package/template/components/geistdocs/icons.tsx +13 -0
  246. package/template/components/geistdocs/installer.tsx +58 -0
  247. package/template/components/geistdocs/language-selector.tsx +3 -0
  248. package/template/components/geistdocs/mdx-components.tsx +5 -0
  249. package/template/components/geistdocs/mermaid.tsx +68 -0
  250. package/template/components/geistdocs/mobile-docs-bar.tsx +77 -0
  251. package/template/components/geistdocs/mobile-menu.tsx +150 -0
  252. package/template/components/geistdocs/navbar-logo.tsx +124 -0
  253. package/template/components/geistdocs/navbar.tsx +22 -0
  254. package/template/components/geistdocs/provider.tsx +31 -0
  255. package/template/components/geistdocs/rss-button.tsx +10 -0
  256. package/template/components/geistdocs/scroll-top.tsx +21 -0
  257. package/template/components/geistdocs/search.tsx +17 -0
  258. package/template/components/geistdocs/sidebar.tsx +128 -0
  259. package/template/components/geistdocs/theme-aware-image.tsx +22 -0
  260. package/template/components/geistdocs/theme-toggle.tsx +3 -0
  261. package/template/components/geistdocs/video.tsx +16 -0
  262. package/template/components/ui/badge.tsx +46 -0
  263. package/template/components/ui/button-group.tsx +83 -0
  264. package/template/components/ui/button.tsx +60 -0
  265. package/template/components/ui/card.tsx +92 -0
  266. package/template/components/ui/collapsible.tsx +33 -0
  267. package/template/components/ui/command-prompt.tsx +488 -0
  268. package/template/components/ui/command.tsx +184 -0
  269. package/template/components/ui/dialog.tsx +143 -0
  270. package/template/components/ui/drawer.tsx +135 -0
  271. package/template/components/ui/dropdown-menu.tsx +257 -0
  272. package/template/components/ui/hover-card.tsx +44 -0
  273. package/template/components/ui/input-group.tsx +170 -0
  274. package/template/components/ui/input.tsx +21 -0
  275. package/template/components/ui/kbd.tsx +28 -0
  276. package/template/components/ui/navigation-menu.tsx +192 -0
  277. package/template/components/ui/popover.tsx +48 -0
  278. package/template/components/ui/scroll-area.tsx +58 -0
  279. package/template/components/ui/select.tsx +187 -0
  280. package/template/components/ui/separator.tsx +28 -0
  281. package/template/components/ui/sheet.tsx +139 -0
  282. package/template/components/ui/sonner.tsx +40 -0
  283. package/template/components/ui/spinner.tsx +16 -0
  284. package/template/components/ui/textarea.tsx +18 -0
  285. package/template/components/ui/tooltip.tsx +61 -0
  286. package/template/components.json +22 -0
  287. package/template/content/docs/ask-ai.cn.mdx +85 -0
  288. package/template/content/docs/ask-ai.mdx +89 -0
  289. package/template/content/docs/configuration.cn.mdx +155 -0
  290. package/template/content/docs/configuration.mdx +200 -0
  291. package/template/content/docs/deployment.cn.mdx +34 -0
  292. package/template/content/docs/deployment.mdx +40 -0
  293. package/template/content/docs/edit-on-github.cn.mdx +47 -0
  294. package/template/content/docs/edit-on-github.mdx +51 -0
  295. package/template/content/docs/env.cn.mdx +25 -0
  296. package/template/content/docs/env.mdx +29 -0
  297. package/template/content/docs/feedback.cn.mdx +85 -0
  298. package/template/content/docs/feedback.mdx +89 -0
  299. package/template/content/docs/getting-started.cn.mdx +86 -0
  300. package/template/content/docs/getting-started.mdx +107 -0
  301. package/template/content/docs/index.cn.mdx +57 -0
  302. package/template/content/docs/index.mdx +92 -0
  303. package/template/content/docs/internationalization.cn.mdx +111 -0
  304. package/template/content/docs/internationalization.mdx +122 -0
  305. package/template/content/docs/llms-txt.cn.mdx +72 -0
  306. package/template/content/docs/llms-txt.mdx +85 -0
  307. package/template/content/docs/md.cn.mdx +65 -0
  308. package/template/content/docs/md.mdx +81 -0
  309. package/template/content/docs/meta.json +23 -0
  310. package/template/content/docs/open-in-chat.cn.mdx +78 -0
  311. package/template/content/docs/open-in-chat.mdx +80 -0
  312. package/template/content/docs/provider.cn.mdx +70 -0
  313. package/template/content/docs/provider.mdx +74 -0
  314. package/template/content/docs/proxy.cn.mdx +96 -0
  315. package/template/content/docs/proxy.mdx +124 -0
  316. package/template/content/docs/rss.cn.mdx +104 -0
  317. package/template/content/docs/rss.mdx +108 -0
  318. package/template/content/docs/syntax.cn.mdx +416 -0
  319. package/template/content/docs/syntax.mdx +411 -0
  320. package/template/content/docs/theme-aware-image.mdx +57 -0
  321. package/template/content/docs/versioned-docs.cn.mdx +117 -0
  322. package/template/content/docs/versioned-docs.mdx +181 -0
  323. package/template/geistdocs.tsx +51 -0
  324. package/template/hooks/geistdocs/use-sidebar.ts +13 -0
  325. package/template/hooks/use-mobile.ts +19 -0
  326. package/template/lib/geistdocs/config.tsx +27 -0
  327. package/template/lib/geistdocs/fonts.ts +18 -0
  328. package/template/lib/geistdocs/i18n.ts +13 -0
  329. package/template/lib/geistdocs/md-tracking.ts +56 -0
  330. package/template/lib/geistdocs/source.ts +12 -0
  331. package/template/lib/utils.ts +6 -0
  332. package/template/next.config.ts +22 -0
  333. package/template/package.json +63 -0
  334. package/template/postcss.config.mjs +5 -0
  335. package/template/proxy.ts +18 -0
  336. package/template/source.config.ts +62 -0
  337. package/template/tsconfig.json +37 -0
  338. package/dist/index.js +0 -2
  339. /package/dist/{index.d.ts → cli/index.d.ts} +0 -0
@@ -0,0 +1,181 @@
1
+ ---
2
+ title: Versioned docs
3
+ description: Configure multiple documentation versions with package-backed source helpers
4
+ type: guide
5
+ summary: Use createVersionedSources to configure stable, pre-release, or host-based documentation versions.
6
+ prerequisites:
7
+ - /docs/configuration
8
+ related:
9
+ - /docs/proxy
10
+ - /docs/llms-txt
11
+ ---
12
+
13
+ Versioned docs let you serve multiple documentation sets from one Geistdocs project. Use them for stable and pre-release docs, previous major versions, or host-based version switching.
14
+
15
+ <CopyPrompt text="Help me add versioned docs to this Geistdocs site. Inspect source.config.ts, lib/geistdocs/source.ts, app route files, and the docs layout, then propose a versioned source setup using createVersionedSources.">
16
+ Help me add versioned docs to this Geistdocs site. Inspect `source.config.ts`, `lib/geistdocs/source.ts`, app route files, and the docs layout, then propose a versioned source setup using `createVersionedSources`.
17
+ </CopyPrompt>
18
+
19
+ ## Configure source collections
20
+
21
+ Create one Fumadocs collection for each version in `source.config.ts`:
22
+
23
+ ```ts title="source.config.ts"
24
+ import { defineConfig, defineDocs } from "fumadocs-mdx/config";
25
+
26
+ export const v4docs = defineDocs({
27
+ dir: "content/docs/v4",
28
+ docs: {
29
+ postprocess: {
30
+ includeProcessedMarkdown: true,
31
+ },
32
+ },
33
+ });
34
+
35
+ export const v5docs = defineDocs({
36
+ dir: "content/docs/v5",
37
+ docs: {
38
+ postprocess: {
39
+ includeProcessedMarkdown: true,
40
+ },
41
+ },
42
+ });
43
+
44
+ export default defineConfig({});
45
+ ```
46
+
47
+ ## Create versioned sources
48
+
49
+ Use `createVersionedSources` in `lib/geistdocs/source.ts`:
50
+
51
+ ```ts title="lib/geistdocs/source.ts"
52
+ import { createVersionedSources } from "@vercel/geistdocs/source";
53
+ import { v4docs, v5docs } from "@/.source/server";
54
+ import { config } from "./config";
55
+
56
+ export const versions = createVersionedSources({
57
+ config,
58
+ current: "v4",
59
+ versions: [
60
+ {
61
+ id: "v4",
62
+ label: "v4",
63
+ docs: v4docs,
64
+ baseUrl: "/docs",
65
+ },
66
+ {
67
+ id: "v5",
68
+ label: "v5 pre-release",
69
+ docs: v5docs,
70
+ baseUrl: "/docs",
71
+ routePrefix: "/v5",
72
+ },
73
+ ],
74
+ });
75
+
76
+ export const geistdocsSource = versions.current;
77
+ export const source = geistdocsSource.source;
78
+ ```
79
+
80
+ The returned object includes:
81
+
82
+ | Property | Type | Description |
83
+ | --- | --- | --- |
84
+ | `current` | `GeistdocsSourceBundle` | The source matching the `current` version ID. |
85
+ | `byId` | `Record<string, GeistdocsSourceBundle>` | A map of version IDs to source bundles. |
86
+ | `all` | `Array` | Version metadata and source bundles for rendering UI. |
87
+ | `currentVersion` | `string` | The active version ID. |
88
+
89
+ ## Render versioned pages
90
+
91
+ Use the current version for `/docs` and a specific version for version-prefixed routes:
92
+
93
+ ```tsx title="app/[lang]/docs/[[...slug]]/page.tsx"
94
+ import { createDocsPage } from "@vercel/geistdocs/pages/docs";
95
+ import { config } from "@/lib/geistdocs/config";
96
+ import { versions } from "@/lib/geistdocs/source";
97
+
98
+ const docsPage = createDocsPage({
99
+ config,
100
+ source: versions.current,
101
+ });
102
+
103
+ export default docsPage.Page;
104
+ export const generateStaticParams = docsPage.generateStaticParams;
105
+ export const generateMetadata = docsPage.generateMetadata;
106
+ ```
107
+
108
+ ```tsx title="app/[lang]/v5/docs/[[...slug]]/page.tsx"
109
+ import { createDocsPage } from "@vercel/geistdocs/pages/docs";
110
+ import { config } from "@/lib/geistdocs/config";
111
+ import { versions } from "@/lib/geistdocs/source";
112
+
113
+ const docsPage = createDocsPage({
114
+ config,
115
+ source: versions.byId.v5,
116
+ getPageUrl: ({ page }) => `/v5${page.url}`,
117
+ metadata: ({ metadata }) => ({
118
+ ...metadata,
119
+ robots: {
120
+ index: false,
121
+ follow: true,
122
+ },
123
+ }),
124
+ });
125
+
126
+ export default docsPage.Page;
127
+ export const generateStaticParams = docsPage.generateStaticParams;
128
+ export const generateMetadata = docsPage.generateMetadata;
129
+ ```
130
+
131
+ Use `getPageUrl` when the route path differs from the source `baseUrl`. This keeps page actions and markdown links pointed at the public URL.
132
+
133
+ ## Add a version selector
134
+
135
+ Use `GeistdocsVersionSelect` when readers need to move between versions:
136
+
137
+ ```tsx title="components/geistdocs/docs-layout.tsx"
138
+ import { GeistdocsDocsLayout } from "@vercel/geistdocs/layout";
139
+ import { GeistdocsVersionSelect } from "@vercel/geistdocs/versions";
140
+ import { config } from "@/lib/geistdocs/config";
141
+
142
+ export const DocsLayout = ({ tree, children }: DocsLayoutProps) => (
143
+ <GeistdocsDocsLayout
144
+ config={config}
145
+ sidebarTop={
146
+ <GeistdocsVersionSelect
147
+ current="v4"
148
+ versions={[
149
+ { id: "v4", label: "v4" },
150
+ { id: "v5", label: "v5 pre-release", routePrefix: "/v5" },
151
+ ]}
152
+ />
153
+ }
154
+ tree={tree}
155
+ >
156
+ {children}
157
+ </GeistdocsDocsLayout>
158
+ );
159
+ ```
160
+
161
+ For host-based versions, use `href` instead of `routePrefix`:
162
+
163
+ ```tsx
164
+ <GeistdocsVersionSelect
165
+ current="v6"
166
+ versions={[
167
+ { id: "v6", label: "v6 latest" },
168
+ { id: "v5", label: "v5", href: "https://v5.example.com/:path*" },
169
+ { id: "v4", label: "v4", href: "https://v4.example.com/:path*" },
170
+ ]}
171
+ />
172
+ ```
173
+
174
+ ## Configure markdown routes
175
+
176
+ Each public route family needs a matching markdown route in `proxy.ts`. Read [Proxy and markdown routes](/docs/proxy) for the proxy configuration.
177
+
178
+ ## Next steps
179
+
180
+ - Read [Proxy and markdown routes](/docs/proxy) to connect versioned pages to `.md`, `.mdx`, and AI-agent rewrites.
181
+ - Read [llms.txt](/docs/llms-txt) to configure all-docs markdown output for multiple sources.
@@ -0,0 +1,51 @@
1
+ export const Logo = () => (
2
+ <span className="font-semibold text-gray-1000 text-lg leading-none tracking-[-3%]">
3
+ Geistdocs
4
+ </span>
5
+ );
6
+
7
+ export const github = {
8
+ owner: "vercel",
9
+ repo: "geistdocs",
10
+ };
11
+
12
+ export const nav = [
13
+ {
14
+ label: "Docs",
15
+ href: "/docs",
16
+ },
17
+ {
18
+ label: "Source",
19
+ href: `https://github.com/${github.owner}/${github.repo}/`,
20
+ },
21
+ ];
22
+
23
+ export const suggestions = [
24
+ "What is Geistdocs?",
25
+ "What can I make with Geistdocs?",
26
+ "What syntax does Geistdocs support?",
27
+ "How do I deploy my Geistdocs site?",
28
+ ];
29
+
30
+ export const title = "Geistdocs Documentation";
31
+
32
+ export const prompt =
33
+ "You are a helpful assistant specializing in answering questions about Geistdocs, a modern documentation template built with Next.js and Fumadocs.";
34
+
35
+ export const translations = {
36
+ en: {
37
+ displayName: "English",
38
+ },
39
+ cn: {
40
+ displayName: "Chinese",
41
+ search: "搜尋文檔",
42
+ },
43
+ };
44
+
45
+ export const basePath: string | undefined = undefined;
46
+
47
+ /**
48
+ * Unique identifier for this site, used in markdown request tracking analytics.
49
+ * Each site using geistdocs should set this to a unique value (e.g. "ai-sdk-docs", "next-docs").
50
+ */
51
+ export const siteId: string | undefined = undefined;
@@ -0,0 +1,13 @@
1
+ import { atom, useAtom } from "jotai";
2
+
3
+ // Export the sidebar open state atom so it can be used from other parts of the app
4
+ export const sidebarOpenAtom = atom<boolean>(false);
5
+
6
+ export const useSidebarContext = () => {
7
+ const [isOpen, setIsOpen] = useAtom(sidebarOpenAtom);
8
+
9
+ return {
10
+ isOpen,
11
+ setIsOpen,
12
+ };
13
+ };
@@ -0,0 +1,19 @@
1
+ import * as React from "react"
2
+
3
+ const MOBILE_BREAKPOINT = 768
4
+
5
+ export function useIsMobile() {
6
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
7
+
8
+ React.useEffect(() => {
9
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
10
+ const onChange = () => {
11
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
12
+ }
13
+ mql.addEventListener("change", onChange)
14
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
15
+ return () => mql.removeEventListener("change", onChange)
16
+ }, [])
17
+
18
+ return !!isMobile
19
+ }
@@ -0,0 +1,27 @@
1
+ import { defineConfig } from "@vercel/geistdocs/config";
2
+ import {
3
+ basePath,
4
+ github,
5
+ Logo,
6
+ nav,
7
+ prompt,
8
+ siteId,
9
+ suggestions,
10
+ title,
11
+ translations,
12
+ } from "@/geistdocs";
13
+
14
+ export const config = defineConfig({
15
+ title,
16
+ defaultLanguage: "en",
17
+ logo: <Logo />,
18
+ github,
19
+ nav,
20
+ basePath,
21
+ siteId,
22
+ translations,
23
+ ai: {
24
+ prompt,
25
+ suggestions,
26
+ },
27
+ });
@@ -0,0 +1,18 @@
1
+ import {
2
+ Geist_Mono as createMono,
3
+ Geist as createSans,
4
+ } from "next/font/google";
5
+
6
+ export const sans = createSans({
7
+ variable: "--font-sans",
8
+ subsets: ["latin"],
9
+ weight: "variable",
10
+ display: "swap",
11
+ });
12
+
13
+ export const mono = createMono({
14
+ variable: "--font-mono",
15
+ subsets: ["latin"],
16
+ weight: "variable",
17
+ display: "swap",
18
+ });
@@ -0,0 +1,13 @@
1
+ import { defineI18n } from "fumadocs-core/i18n";
2
+ import { defineI18nUI } from "fumadocs-ui/i18n";
3
+ import { translations } from "@/geistdocs";
4
+
5
+ export const i18n = defineI18n({
6
+ defaultLanguage: "en",
7
+ languages: Object.keys(translations),
8
+ hideLocale: "default-locale",
9
+ });
10
+
11
+ export const { provider: i18nProvider } = defineI18nUI(i18n, {
12
+ translations,
13
+ });
@@ -0,0 +1,56 @@
1
+ import type { DetectionMethod } from "@vercel/agent-readability";
2
+ import { siteId } from "@/geistdocs";
3
+
4
+ const PLATFORM_URL = "https://geistdocs.com/md-tracking";
5
+
6
+ interface TrackMdRequestParams {
7
+ acceptHeader: string | null;
8
+ /** Detection method used to identify the agent (only for agent-rewrite requests) */
9
+ detectionMethod?: DetectionMethod | null;
10
+ path: string;
11
+ referer: string | null;
12
+ /** How the markdown was requested: 'md-url' for direct .md URLs, 'header-negotiated' for Accept header, 'agent-rewrite' for detected AI agents */
13
+ requestType?: "md-url" | "header-negotiated" | "agent-rewrite";
14
+ userAgent: string | null;
15
+ }
16
+
17
+ /**
18
+ * Track a markdown page request via the geistdocs platform.
19
+ * Fire-and-forget: errors are logged but don't affect the response.
20
+ */
21
+ export async function trackMdRequest({
22
+ path,
23
+ userAgent,
24
+ referer,
25
+ acceptHeader,
26
+ requestType,
27
+ detectionMethod,
28
+ }: TrackMdRequestParams): Promise<void> {
29
+ try {
30
+ const response = await fetch(PLATFORM_URL, {
31
+ method: "POST",
32
+ headers: {
33
+ "Content-Type": "application/json",
34
+ },
35
+ body: JSON.stringify({
36
+ path,
37
+ siteId: siteId ?? "geistdocs-unknown",
38
+ userAgent,
39
+ referer,
40
+ acceptHeader,
41
+ requestType,
42
+ detectionMethod,
43
+ }),
44
+ });
45
+
46
+ if (!response.ok) {
47
+ console.error(
48
+ "MD tracking failed:",
49
+ response.status,
50
+ await response.text()
51
+ );
52
+ }
53
+ } catch (error) {
54
+ console.error("MD tracking error:", error);
55
+ }
56
+ }
@@ -0,0 +1,12 @@
1
+ import { createSource } from "@vercel/geistdocs/source";
2
+ import { docs } from "@/.source/server";
3
+ import { config } from "./config";
4
+
5
+ export const geistdocsSource = createSource({
6
+ docs,
7
+ config,
8
+ });
9
+
10
+ export const source = geistdocsSource.source;
11
+ export const getPageImage = geistdocsSource.getPageImage;
12
+ export const getLLMText = geistdocsSource.getPageMarkdown;
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,22 @@
1
+ import { createMDX } from "fumadocs-mdx/next";
2
+ import type { NextConfig } from "next";
3
+
4
+ const withMDX = createMDX();
5
+
6
+ const config: NextConfig = {
7
+ experimental: {
8
+ turbopackFileSystemCacheForDev: true,
9
+ },
10
+
11
+ images: {
12
+ formats: ["image/avif", "image/webp"],
13
+ remotePatterns: [
14
+ {
15
+ protocol: "https",
16
+ hostname: "placehold.co",
17
+ },
18
+ ],
19
+ },
20
+ };
21
+
22
+ export default withMDX(config);
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "template",
3
+ "description": "Template for Geistdocs projects.",
4
+ "version": "0.0.0",
5
+ "private": true,
6
+ "scripts": {
7
+ "build": "next build",
8
+ "dev": "next dev",
9
+ "start": "next start",
10
+ "postinstall": "fumadocs-mdx",
11
+ "translate": "npx @vercel/geistdocs translate"
12
+ },
13
+ "dependencies": {
14
+ "@ai-sdk/react": "^2.0.115",
15
+ "@icons-pack/react-simple-icons": "^13.8.0",
16
+ "@orama/tokenizers": "^3.1.16",
17
+ "@vercel/geistdocs": "1.2.3-canary.48fea3c",
18
+ "@streamdown/cjk": "^1.0.1",
19
+ "@streamdown/code": "^1.0.1",
20
+ "@vercel/agent-readability": "^0.2.1",
21
+ "@vercel/analytics": "^1.6.1",
22
+ "@vercel/speed-insights": "^1.3.1",
23
+ "ai": "^5.0.106",
24
+ "class-variance-authority": "^0.7.1",
25
+ "clsx": "^2.1.1",
26
+ "cmdk": "^1.1.1",
27
+ "dexie": "^4.2.1",
28
+ "dexie-react-hooks": "^4.2.0",
29
+ "feed": "^5.1.0",
30
+ "fumadocs-core": "16.2.2",
31
+ "fumadocs-mdx": "14.0.4",
32
+ "fumadocs-ui": "16.2.2",
33
+ "jotai": "^2.15.2",
34
+ "lucide-react": "^0.555.0",
35
+ "mermaid": "^11.12.2",
36
+ "motion": "^12.23.25",
37
+ "nanoid": "^5.1.6",
38
+ "next": "16.0.10",
39
+ "next-themes": "^0.4.6",
40
+ "radix-ui": "latest",
41
+ "react": "^19.2.3",
42
+ "react-dom": "^19.2.3",
43
+ "react-player": "^3.4.0",
44
+ "shiki": "^3.22.0",
45
+ "sonner": "^2.0.7",
46
+ "streamdown": "^2.1.0",
47
+ "tailwind-merge": "^3.4.0",
48
+ "use-stick-to-bottom": "^1.1.1",
49
+ "vaul": "^1.1.2",
50
+ "zod": "^4.1.13"
51
+ },
52
+ "devDependencies": {
53
+ "@tailwindcss/postcss": "^4.1.17",
54
+ "@types/mdx": "^2.0.13",
55
+ "@types/node": "^24.10.1",
56
+ "@types/react": "^19.2.7",
57
+ "@types/react-dom": "^19.2.3",
58
+ "postcss": "^8.5.6",
59
+ "tailwindcss": "^4.1.17",
60
+ "tw-animate-css": "^1.4.0",
61
+ "typescript": "^5.9.3"
62
+ }
63
+ }
@@ -0,0 +1,5 @@
1
+ export default {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ },
5
+ };
@@ -0,0 +1,18 @@
1
+ import { createProxy } from "@vercel/geistdocs/proxy";
2
+ import { config as geistdocsConfig } from "@/lib/geistdocs/config";
3
+ import { trackMdRequest } from "@/lib/geistdocs/md-tracking";
4
+
5
+ const proxy = createProxy({
6
+ config: geistdocsConfig,
7
+ trackMarkdownRequest: trackMdRequest,
8
+ markdownRoutes: [{ from: "/docs/*path", to: "/[lang]/llms.mdx/*path" }],
9
+ before: () => null,
10
+ });
11
+
12
+ export const config = {
13
+ matcher: [
14
+ "/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
15
+ ],
16
+ };
17
+
18
+ export default proxy;
@@ -0,0 +1,62 @@
1
+ import { remarkMdxMermaid } from "fumadocs-core/mdx-plugins";
2
+ import {
3
+ defineConfig,
4
+ defineDocs,
5
+ frontmatterSchema,
6
+ metaSchema,
7
+ } from "fumadocs-mdx/config";
8
+ import lastModified from "fumadocs-mdx/plugins/last-modified";
9
+ import { z } from "zod";
10
+
11
+ // You can customise Zod schemas for frontmatter and `meta.json` here
12
+ // see https://fumadocs.dev/docs/mdx/collections
13
+ export const docs = defineDocs({
14
+ dir: "content/docs",
15
+ docs: {
16
+ schema: frontmatterSchema.extend({
17
+ product: z.string().optional(),
18
+ url: z
19
+ .string()
20
+ .regex(/^\/.*/, { message: "url must start with a slash" })
21
+ .optional(),
22
+ type: z
23
+ .enum([
24
+ "conceptual", // Explains what something is and why it exists. Architecture, mental models, design decisions.
25
+ "guide", // Walks through how to accomplish a goal. Tutorials, getting started, workflows.
26
+ "reference", // Lookup-oriented, exhaustive details. API docs, config options, function signatures.
27
+ "troubleshooting", // Diagnoses problems and solutions. FAQs, errors, known issues, debugging guides.
28
+ "integration", // Connects multiple systems. 3rd-party setup, plugins, webhooks, migrations.
29
+ "overview", // High-level introductions. Landing pages, changelogs, release notes.
30
+ ])
31
+ .optional(),
32
+ prerequisites: z
33
+ .array(
34
+ z.string().regex(/^\/.*/, {
35
+ message: "prerequisites must start with a slash",
36
+ })
37
+ )
38
+ .optional(),
39
+ related: z
40
+ .array(
41
+ z
42
+ .string()
43
+ .regex(/^\/.*/, { message: "related must start with a slash" })
44
+ )
45
+ .optional(),
46
+ summary: z.string().optional(),
47
+ }),
48
+ postprocess: {
49
+ includeProcessedMarkdown: true,
50
+ },
51
+ },
52
+ meta: {
53
+ schema: metaSchema,
54
+ },
55
+ });
56
+
57
+ export default defineConfig({
58
+ mdxOptions: {
59
+ remarkPlugins: [remarkMdxMermaid],
60
+ },
61
+ plugins: [lastModified()],
62
+ });
@@ -0,0 +1,37 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "target": "ESNext",
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
+ "allowJs": true,
7
+ "skipLibCheck": true,
8
+ "strict": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "noEmit": true,
11
+ "esModuleInterop": true,
12
+ "module": "esnext",
13
+ "moduleResolution": "bundler",
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "jsx": "react-jsx",
17
+ "incremental": true,
18
+ "paths": {
19
+ "@/*": ["./*"],
20
+ "@/.source": [".source"]
21
+ },
22
+ "plugins": [
23
+ {
24
+ "name": "next"
25
+ }
26
+ ],
27
+ "strictNullChecks": true
28
+ },
29
+ "include": [
30
+ "next-env.d.ts",
31
+ "**/*.ts",
32
+ "**/*.tsx",
33
+ ".next/types/**/*.ts",
34
+ ".next/dev/types/**/*.ts"
35
+ ],
36
+ "exclude": ["node_modules"]
37
+ }
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{program as P}from"commander";import{copyFile as V,rm as q}from"fs/promises";import{join as R}from"path";import{cancel as W,intro as Y,isCancel as Z,log as Q,outro as tt,spinner as et,text as st}from"@clack/prompts";import{spawn as X}from"child_process";var v="https://github.com/vercel/geistdocs";var h={stdio:"ignore"};var x="geistdocs-update",f=(t,e)=>new Promise((s,r)=>{let[a,...i]=t.split(" "),n=X(a,i,{stdio:["ignore","pipe","pipe"],shell:e?.shell??!0,cwd:e?.cwd}),l="",c="";n.stdout?.on("data",p=>{l+=p.toString()}),n.stderr?.on("data",p=>{c+=p.toString()});let o=()=>{n.kill("SIGTERM"),setTimeout(()=>{n.killed||n.kill("SIGKILL")},1e3)};process.on("SIGINT",o),process.on("SIGTERM",o),n.on("close",p=>{process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o),p===0?s({stdout:l,stderr:c}):r(new Error(`Command failed with code ${p}: ${c}`))}),n.on("error",p=>{process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o),r(p)})});var nt="https://github.com/vercel/geistdocs.git",rt=async t=>{await f(`git clone --depth 1 --filter=blob:none --sparse ${nt} ${t}`,h),await f("git sparse-checkout set apps/template",{...h,cwd:t}),await f("mv apps/template/* apps/template/.[!.]* . 2>/dev/null || true",{...h,cwd:t,shell:"/bin/bash"}),await f("rm -rf apps .git",{...h,cwd:t})},ot=async()=>{await V(".env.example",".env.local")},at=async()=>{await q(R("content","docs"),{recursive:!0,force:!0})},it=async()=>{await f("pnpm install",h)},ct=async()=>{await f("git init",h),await f("git add .",h),await f('git commit -m "\u2728 Initial commit"',h)},lt=async()=>{let t=await st({message:"What is your project named?",placeholder:"my-app",validate(e){if(e.length===0)return"Please enter a project name."}});return Z(t)&&(W("Operation cancelled."),process.exit(0)),t.toString()},j=async t=>{try{Y("Let's start a Geistdocs project!");let e=process.cwd(),s=t.name||await lt(),r=et(),a=R(e,s);r.start("Cloning template..."),await rt(s),r.message("Moving into project..."),process.chdir(a),r.message("Setting up environment variables..."),await ot(),r.message("Deleting demo content..."),await at(),r.message("Installing dependencies..."),await it(),t.disableGit||(r.message("Initializing Git repository..."),await ct()),r.stop("Project initialized successfully!"),tt("Run `pnpm dev` to start the development server.")}catch(e){let s=e instanceof Error?e.message:`Failed to initialize project: ${e}`;Q.error(s),process.exit(1)}};import{createHash as pt}from"crypto";import{existsSync as L}from"fs";import{readFile as F,writeFile as U}from"fs/promises";import{dirname as gt,parse as D,resolve as $}from"path";import{intro as dt,isCancel as ft,log as m,outro as T,spinner as mt,text as ut}from"@clack/prompts";import{glob as ht}from"glob";import{Project as wt,SyntaxKind as S}from"ts-morph";var b=10,yt="content/docs/**/*.mdx",C=".translation-cache.json",Tt=/\.[a-z]{2}\.mdx$/,$t=async t=>(await ht(t,{cwd:process.cwd(),absolute:!0,nodir:!0})).filter(s=>s.endsWith(".mdx")).filter(s=>!Tt.test(s)),Pt=t=>{let e=$(process.cwd(),t),a=new wt({skipAddingFilesFromTsConfig:!0}).addSourceFileAtPath(e).getVariableDeclaration("translations");if(!a)throw new Error("Could not find translations export in config file");let i=a.getInitializer();if(!i||i.getKind()!==S.ObjectLiteralExpression)throw new Error("translations must be an object literal");let n=i.asKind(S.ObjectLiteralExpression);if(!n)throw new Error("Could not parse translations object");let l=n.getProperties().filter(p=>p.getKind()===S.PropertyAssignment).map(p=>p.asKind(S.PropertyAssignment)?.getName()).filter(p=>p!==void 0);if(l.length===0)throw new Error("No locales found in translations object");let[c,...o]=l;return o},xt=t=>pt("sha256").update(t).digest("hex"),St=async()=>{let t=$(process.cwd(),C);if(!L(t))return{};try{let e=await F(t,"utf-8");return JSON.parse(e)}catch{return m.warn("Failed to load translation cache, starting fresh"),{}}},N=async t=>{let e=$(process.cwd(),C);await U(e,JSON.stringify(t,null,2),"utf-8")},vt=(t,e,s,r)=>{let a=t[e];if(!a)return!0;let i=a[s];return i?i.hash!==r:!0},bt=async(t,e,s)=>{let r=await F(t,"utf-8"),a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r,locale:e})}),i=await a.text();if(!a.ok){let n=`Translation failed with status ${a.status}`;try{let l=JSON.parse(i);n=l.error||l.message||n}catch{n=i||n}throw new Error(n)}try{return JSON.parse(i).translation}catch{throw new Error(`Failed to parse response: ${i.slice(0,200)}`)}},Ft=async(t,e,s,r,a)=>{let i=gt(t),{name:n,ext:l}=D(t),c=$(i,`${n}.${e}${l}`);await U(c,s,"utf-8"),r[t]||(r[t]={}),r[t][e]={hash:a,translatedAt:new Date().toISOString()},await N(r)},Ct=t=>{try{let e=Pt(t);return m.info(`Loaded ${e.length} locale(s) from config: ${e.join(", ")}`),e}catch(e){m.error(`Failed to load config: ${e instanceof Error?e.message:String(e)}`),T("Translation cancelled"),process.exit(1)}},Et=async()=>{let t=await ut({message:"Enter target locales (comma-separated):",placeholder:"cn,fr,es",validate:e=>{if(!e)return"At least one locale is required"}});return ft(t)&&(T("Translation cancelled"),process.exit(0)),t.split(",").map(e=>e.trim())},It=async t=>{let e=new Map;for(let s of t){let r=await F(s,"utf-8");e.set(s,xt(r))}return e},Rt=(t,e,s,r,a)=>{let i=[],n=0;for(let l of t)for(let c of e){let o=s.get(c);if(!o)throw new Error(`Hash not found for file: ${c}`);a||vt(r,c,l,o)?i.push({filePath:c,locale:l,hash:o}):n+=1}return{tasks:i,skippedCount:n}},jt=async(t,e,s,r)=>{let a=mt(),i=[];a.start("Starting translation...");let n=0;for(let l=0;l<t.length;l++){let c=t[l];a.message(`Processing batch ${l+1}/${t.length} (${c.length} translations) - ${n}/${e} complete`),await Promise.all(c.map(async o=>{let{name:p,ext:u}=D(o.filePath),g=await bt(o.filePath,o.locale,s);await Ft(o.filePath,o.locale,g,r,o.hash),i.push({name:p,locale:o.locale,ext:u}),n+=1})),l<t.length-1&&(a.message(`Batch ${l+1}/${t.length} complete. Pausing...`),await new Promise(o=>setTimeout(o,1e3)))}return a.stop("Translation complete!"),i},O=async(t,e)=>{dt("Translate MDX content");let s=t??yt,r=e.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",a=Ct(e.config??"geistdocs.tsx"),i=await $t(s);i.length===0&&(m.error(`No MDX files found matching pattern: ${s}`),T("Translation cancelled"),process.exit(1)),m.info(`Found ${i.length} MDX file(s) matching pattern`),a.length===0&&(a=await Et());let n=$(process.cwd(),C),l=await St();L(n)||await N(l),m.info(`Using cache: ${n}`);let c=await It(i),{tasks:o,skippedCount:p}=Rt(a,i,c,l,e.force);if(o.length===0){m.success("All translations are up to date!"),T(`Skipped ${p} file(s) (unchanged)`);return}let u=[];for(let g=0;g<o.length;g+=b)u.push(o.slice(g,g+b));m.info(`Processing ${o.length} translation(s) in ${u.length} batch(es) of up to ${b}`),p>0&&m.info(`Skipped ${p} translation(s) (unchanged)`);try{let g=await jt(u,o.length,r,l);for(let{name:B,locale:K,ext:J}of g)m.success(`Saved: ${B}.${K}${J}`);let y=[`Translated ${g.length} file(s)`];p>0&&y.push(`Skipped ${p} unchanged`),T(y.join(" \u2022 "))}catch(g){let y=g instanceof Error?g.message:String(g);m.error(`Translation failed: ${y}`),T("Exiting"),process.exit(1)}};import{access as Lt,copyFile as Ut,mkdir as z,rm as I}from"fs/promises";import{dirname as Dt,join as w}from"path";import{intro as Nt,log as d,outro as A,spinner as Ot}from"@clack/prompts";import{glob as At}from"glob";var _="apps/template",kt=["**/*"],Gt=["content/docs/**"],Mt=async(t,e)=>{let s=w(t,e);await I(s,{recursive:!0,force:!0}),await z(s,{recursive:!0})},zt=async(t,e)=>{await f(`git clone --depth 1 --filter=blob:none --sparse ${v} ${e}`,{cwd:t}),await f("git sparse-checkout set apps/template",{cwd:w(t,e)})},E=async t=>await I(t,{recursive:!0,force:!0}),k=async(t,e,s)=>(await At(t,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...e]})).sort(),_t=async t=>{try{return await Lt(t),!0}catch{return!1}},Ht=async(t,e,s)=>{let r=w(e,_,t),a=w(s,t);return await _t(r)?(await Ut(r,a),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},Bt=async(t,e)=>{let s=w(e,t);return await I(s,{force:!0}),{success:!0}},G=20,M=async(t,e,s)=>{let r=[];for(let a=0;a<t.length;a+=s){let i=t.slice(a,a+s),n=await Promise.all(i.map(e));r.push(...n)}return r},Kt=async(t,e,s,r,a)=>{let i={success:[],deleted:[],failed:[]},n=[...new Set(t.map(c=>Dt(w(r,c))))];a.message(`Creating ${n.length} directories...`),await Promise.all(n.map(c=>z(c,{recursive:!0}))),a.message(`Updating ${t.length} files...`);let l=await M(t,async c=>{let o=await Ht(c,s,r);return{file:c,...o}},G);for(let{file:c,success:o,error:p}of l)o?i.success.push(c):i.failed.push({file:c,error:p??"Unknown error"});if(e.length>0){a.message(`Deleting ${e.length} files...`);let c=await M(e,async o=>{try{return await Bt(o,r),{file:o,success:!0}}catch(p){let u=p instanceof Error?p.message:`${p}`;return{file:o,success:!1,error:u}}},G);for(let o of c)o.success?i.deleted.push(o.file):i.failed.push({file:o.file,error:o.error})}return i},Jt=t=>{if(t.success.length>0){d.success(`Successfully updated ${t.success.length} files:`);for(let e of t.success)d.info(` \u2713 ${e}`)}if(t.deleted.length>0){d.success(`Deleted ${t.deleted.length} files:`);for(let e of t.deleted)d.info(` \u{1F5D1} ${e}`)}if(t.failed.length>0){d.warn(`Failed to update ${t.failed.length} files:`);for(let{file:e,error:s}of t.failed)d.error(` \u2717 ${e}: ${s}`)}},H=async(t,e)=>{let s=process.cwd(),r=w(s,x),a=t&&t.length>0?t:kt,i=t&&t.length>0?[]:Gt;try{Nt("Let's update your Geistdocs project!"),d.info(`Repository: ${v}`),t&&t.length>0&&d.info(`Updating specific files: ${t.join(", ")}`),e?.sync&&d.info("Sync mode enabled: will delete files removed from template");let n=Ot();n.start("Creating temporary directory..."),await Mt(s,x),n.message("Cloning repository..."),await zt(s,x),n.message("Scanning for files...");let l=w(r,_),c=await k(a,i,l),o=[];if(e?.sync){n.message("Comparing with local files...");let u=await k(a,i,s),g=new Set(c);o=u.filter(y=>!g.has(y))}if(n.stop(`Found ${c.length} files to update`),c.length===0&&o.length===0){d.warn("No files matched the patterns. Nothing to update."),await E(r),A("Update cancelled.");return}d.info(`Patterns: ${a.length}`),d.info(`Files to update: ${c.length}`),e?.sync&&d.info(`Files to delete: ${o.length}`),n.start("Updating files...");let p=await Kt(c,o,r,s,n);n.message("Cleaning up..."),await E(r),n.stop("Update complete!"),Jt(p),A("Please review and test the changes carefully.")}catch(n){let l=n instanceof Error?n.message:`${n}`;try{await E(r)}catch{}d.error(`Failed to update project: ${l}`),process.exit(1)}};P.name("geistdocs").description("CLI for Geistdocs projects").version("1.1.1","-v, --version","Output the current version");P.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(j);P.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(H);P.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(O);P.parse(process.argv);
File without changes