@vercel/geistdocs 1.3.0-canary.41d37f1 → 1.3.0-canary.5af98bc

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 (51) hide show
  1. package/dist/cli/index.js +2 -2
  2. package/dist/components/code-block.d.ts.map +1 -1
  3. package/dist/components/code-block.js +5 -1
  4. package/dist/components/copy-prompt.d.ts +11 -0
  5. package/dist/components/copy-prompt.d.ts.map +1 -0
  6. package/dist/components/copy-prompt.js +58 -0
  7. package/dist/internal/page-actions-client.d.ts +1 -2
  8. package/dist/internal/page-actions-client.d.ts.map +1 -1
  9. package/dist/internal/page-actions-client.js +12 -6
  10. package/dist/internal/provider-client.d.ts +9 -0
  11. package/dist/internal/provider-client.d.ts.map +1 -0
  12. package/dist/internal/provider-client.js +23 -0
  13. package/dist/internal/sidebar.d.ts.map +1 -1
  14. package/dist/internal/sidebar.js +4 -3
  15. package/dist/internal/table-of-contents.d.ts +9 -0
  16. package/dist/internal/table-of-contents.d.ts.map +1 -0
  17. package/dist/internal/table-of-contents.js +5 -0
  18. package/dist/layout.d.ts +2 -7
  19. package/dist/layout.d.ts.map +1 -1
  20. package/dist/layout.js +25 -43
  21. package/dist/mdx.d.ts.map +1 -1
  22. package/dist/mdx.js +2 -0
  23. package/dist/pages/docs.d.ts.map +1 -1
  24. package/dist/pages/docs.js +15 -9
  25. package/dist/sidebar.d.ts +11 -0
  26. package/dist/sidebar.d.ts.map +1 -0
  27. package/dist/sidebar.js +16 -0
  28. package/package.json +9 -1
  29. package/template/_gitignore +28 -0
  30. package/template/app/styles/geistdocs.css +1 -0
  31. package/template/components/geistdocs/mobile-docs-bar.tsx +2 -6
  32. package/template/content/docs/ask-ai.mdx +4 -0
  33. package/template/content/docs/configuration.mdx +75 -72
  34. package/template/content/docs/deployment.mdx +6 -0
  35. package/template/content/docs/edit-on-github.mdx +4 -0
  36. package/template/content/docs/env.mdx +4 -0
  37. package/template/content/docs/feedback.mdx +4 -0
  38. package/template/content/docs/getting-started.mdx +64 -43
  39. package/template/content/docs/index.mdx +57 -59
  40. package/template/content/docs/internationalization.cn.mdx +7 -9
  41. package/template/content/docs/internationalization.mdx +9 -4
  42. package/template/content/docs/llms-txt.mdx +4 -0
  43. package/template/content/docs/md.mdx +4 -0
  44. package/template/content/docs/meta.json +2 -2
  45. package/template/content/docs/open-in-chat.mdx +4 -0
  46. package/template/content/docs/provider.mdx +4 -0
  47. package/template/content/docs/rss.mdx +4 -0
  48. package/template/content/docs/syntax.cn.mdx +2 -2
  49. package/template/content/docs/syntax.mdx +5 -1
  50. package/template/content/docs/theme-aware-image.mdx +4 -0
  51. package/template/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{program as T}from"commander";import{access as pe,copyFile as ge,rm as de}from"fs/promises";import{join as G}from"path";import{cancel as ue,intro as fe,isCancel as me,log as he,outro as we,spinner as ye,text as Pe}from"@clack/prompts";import{exec as se}from"child_process";import{readFileSync as ne}from"fs";import{cp as re,readFile as ae,rename as ie,writeFile as oe}from"fs/promises";import{join as x}from"path";import{fileURLToPath as ce}from"url";import{promisify as le}from"util";var f="@vercel/geistdocs",m=(e,t)=>le(se)(e,t),_=["dependencies","devDependencies","optionalDependencies","peerDependencies"],b=()=>JSON.parse(ne(new URL("../../package.json",import.meta.url),"utf8")).version,P=async e=>{let t=x(e,"package.json"),s=await ae(t,"utf8");return JSON.parse(s)},F=async(e,t)=>{let s=x(e,"package.json");await oe(s,`${JSON.stringify(t,null,2)}
3
- `,"utf8")},E=(e,t)=>{for(let s of _){let n=e[s];if(n&&t in n)return n[t]}},V=(e,t)=>!!E(e,t),$=(e,t,s)=>{let n=!1;for(let r of _){let a=e[r];a&&t in a&&(a[t]=s,n=!0)}return n},j=()=>ce(new URL("../../template",import.meta.url)),D=async e=>{await re(j(),e,{recursive:!0});let t=x(e,".gitignore"),s=x(e,"_gitignore");try{await ie(s,t)}catch{}};var ve=async e=>{await D(e)},Te=async e=>{try{return await pe(e),!0}catch{return!1}},ke=async()=>{await Te(".env.example")&&await ge(".env.example",".env.local")},xe=async()=>{await de(G("content","docs"),{recursive:!0,force:!0})},be=async e=>{let t=await P(e),s=b();return $(t,f,s)?(await F(e,t),!0):!1},Fe=async e=>{await m("pnpm install",{cwd:e,env:process.env,stdio:"inherit"})},$e=async e=>{await m("git init",{cwd:e,env:process.env,stdio:"inherit"}),await m("git add .",{cwd:e,env:process.env,stdio:"inherit"}),await m('git commit -m "\u2728 Initial commit"',{cwd:e,env:process.env,stdio:"inherit"})},De=async()=>{let e=await Pe({message:"What is your project named?",placeholder:"my-app",validate(t){if(t.length===0)return"Please enter a project name."}});return me(e)&&(ue("Operation cancelled."),process.exit(0)),e.toString()},B=async e=>{try{fe("Let's start a Geistdocs project!");let t=process.cwd(),s=e.name||await De(),n=ye(),r=G(t,s);n.start("Copying bundled template..."),await ve(s),n.message("Setting up environment variables..."),process.chdir(r),await ke(),n.message("Deleting demo content..."),await xe(),n.message("Rewriting package dependency versions..."),await be(r),n.message("Installing dependencies..."),await Fe(r),e.disableGit||(n.message("Initializing Git repository..."),await $e(r)),n.stop("Project initialized successfully!"),we("Run `pnpm dev` to start the development server.")}catch(t){let s=t instanceof Error?t.message:`Failed to initialize project: ${t}`;he.error(s),process.exit(1)}};import{readFileSync as Se,writeFileSync as Ce}from"fs";import{mkdir as Re,readFile as J,writeFile as Ee}from"fs/promises";import{dirname as je,extname as Ne,relative as K,resolve as C}from"path";import{intro as Je,isCancel as Ue,log as h,multiselect as Ie,outro as S,spinner as Oe}from"@clack/prompts";import{glob as Le}from"glob";import{Node as v,Project as Ae,SyntaxKind as _e}from"ts-morph";var Ve="geistdocs.tsx",Ge="content/docs/**/*.mdx",U=".translation-cache.json",N=8,z=()=>({version:1,entries:{}}),Be=async e=>{let t=await J(e),{createHash:s}=await import("crypto");return s("sha256").update(t).digest("hex")},ze=e=>{let t=C(process.cwd(),e);return Se(t,"utf8")},H=e=>v.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(v.isPropertyAssignment(t)){let s=t.getNameNode();if(v.isIdentifier(s)||v.isStringLiteral(s))return[s.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],He=e=>{try{let t=new Ae({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),s=ze(e),a=t.createSourceFile(e,s,{overwrite:!0}).getVariableDeclarations().find(l=>l.getName()==="translations")?.getInitializer();if(!a)return[];if(v.isObjectLiteralExpression(a))return H(a);let o=a.getFirstDescendantByKind(_e.ObjectLiteralExpression);return o?H(o):[]}catch(t){let s=t instanceof Error?t.message:`${t}`;return h.warn(`Failed to read locales from ${e}: ${s}`),[]}},Me=async()=>{let e=await Ie({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ue(e)&&(S("Translation cancelled"),process.exit(0)),e},Ke=async e=>(await Le(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),qe=async()=>{let e=C(process.cwd(),U);try{let t=await J(e,"utf8"),s=JSON.parse(t);return s.version!==1||!s.entries?z():{version:1,entries:s.entries}}catch{return z()}},M=e=>{let t=C(process.cwd(),U),s=JSON.stringify(e,null,2);Ce(t,s,"utf8")},Xe=async e=>{let t=await Promise.all(e.map(async s=>[s,await Be(s)]));return Object.fromEntries(t)},We=(e,t)=>{let s=Ne(e);return`${e.slice(0,-s.length)}.${t}${s}`},q=(e,t)=>`${K(process.cwd(),e)}::${t}`,Ye=(e,t,s,n,r=!1)=>{let a=[],o=0;for(let l of t){let c=s[l];for(let i of e){let g=We(l,i),d=q(l,i),u=n.entries[d];if(!r&&u?.hash===c){o+=1;continue}a.push({locale:i,sourceFile:l,sourceHash:c,targetFile:g})}}return{tasks:a,skippedCount:o}},Ze=async e=>{await Re(je(e),{recursive:!0})},Qe=async(e,t,s)=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:s})});if(!n.ok){let a=await n.text();throw new Error(`API request failed (${n.status}): ${a}`)}let r=await n.json();if(!r.translation)throw new Error("API response did not include a translation");return r.translation},et=async(e,t,s)=>{let n=await J(e.sourceFile,"utf8"),r=await Qe(t,n,e.locale);await Ze(e.targetFile),await Ee(e.targetFile,r,"utf8"),s.entries[q(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},X=async(e,t)=>{Je("Translate MDX content");let s=e??Ge,n=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",r=He(t.config??Ve),a=await Ke(s);a.length===0&&(h.error(`No MDX files found matching pattern: ${s}`),S("Translation cancelled"),process.exit(1)),h.info(`Found ${a.length} MDX file(s) matching pattern`),r.length===0&&(r=await Me());let o=C(process.cwd(),U),l=await qe();await M(l),h.info(`Using cache: ${o}`);let c=await Xe(a),{tasks:i,skippedCount:g}=Ye(r,a,c,l,t.force);if(i.length===0){h.success("All translations are up to date!"),S(`Skipped ${g} file(s) (unchanged)`);return}let d=[];for(let y=0;y<i.length;y+=N)d.push(i.slice(y,y+N));h.info(`Processing ${i.length} translation(s) in ${d.length} batch(es) of up to ${N}`),g>0&&h.info(`Skipped ${g} translation(s) (unchanged)`);let u=Oe();u.start("Translating content...");let k=0;for(let y of d)await Promise.all(y.map(async A=>{await et(A,n,l),k+=1,u.message(`Translated ${k}/${i.length}: ${K(process.cwd(),A.targetFile)}`)})),await M(l);u.stop("Translation complete!"),S(`Created/updated ${i.length} file(s)`)};import{access as tt,copyFile as st,mkdir as Q,rm as L}from"fs/promises";import{dirname as nt,join as w}from"path";import{intro as rt,log as p,outro as R,spinner as ee}from"@clack/prompts";import{glob as at}from"glob";var it=["**/*"],ot=["content/docs/**"],I=".geistdocs-tmp",ct=async(e,t)=>{let s=w(e,t);await L(s,{recursive:!0,force:!0}),await Q(s,{recursive:!0})},O=async e=>await L(e,{recursive:!0,force:!0}),W=async(e,t,s)=>(await at(e,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),lt=async e=>{try{return await tt(e),!0}catch{return!1}},pt=async(e,t,s)=>{let n=w(t,e),r=w(s,e);return await lt(n)?(await st(n,r),{success:!0}):{success:!1,error:`Source file not found: ${n}`}},gt=async(e,t)=>{let s=w(t,e);return await L(s,{force:!0}),{success:!0}},Y=20,Z=async(e,t,s)=>{let n=[];for(let r=0;r<e.length;r+=s){let a=e.slice(r,r+s),o=await Promise.all(a.map(t));n.push(...o)}return n},dt=async(e,t,s,n,r)=>{let a={success:[],deleted:[],failed:[]},o=[...new Set(e.map(c=>nt(w(n,c))))];r.message(`Creating ${o.length} directories...`),await Promise.all(o.map(c=>Q(c,{recursive:!0}))),r.message(`Updating ${e.length} files...`);let l=await Z(e,async c=>{let i=await pt(c,s,n);return{file:c,...i}},Y);for(let{file:c,success:i,error:g}of l)i?a.success.push(c):a.failed.push({file:c,error:g??"Unknown error"});if(t.length>0){r.message(`Deleting ${t.length} files...`);let c=await Z(t,async i=>{try{return await gt(i,n),{file:i,success:!0}}catch(g){let d=g instanceof Error?g.message:`${g}`;return{file:i,success:!1,error:d}}},Y);for(let i of c)i.success?a.deleted.push(i.file):a.failed.push({file:i.file,error:i.error})}return a},ut=e=>{if(e.success.length>0){p.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)p.info(` \u2713 ${t}`)}if(e.deleted.length>0){p.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)p.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){p.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:s}of e.failed)p.error(` \u2717 ${t}: ${s}`)}},ft=async e=>{let t=await P(e),s=E(t,f),n=b();return s?s===n?{currentVersion:s,nextVersion:n,updated:!1}:($(t,f,n),await F(e,t),{currentVersion:s,nextVersion:n,updated:!0}):{currentVersion:s,nextVersion:n,updated:!1}},mt=async(e,t,s)=>{let n=await P(e);if(!V(n,f))return!1;t&&t.length>0&&p.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),s?.sync&&p.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:r,nextVersion:a,updated:o}=await ft(e);if(!o)return p.success(r?`@vercel/geistdocs is already at ${a}.`:"No package version update was needed."),R("Package-based site is already up to date."),!0;p.info(`Bumping ${f} from ${r} to ${a}`);let l=ee();return l.start("Installing updated package version..."),await m("pnpm install",{cwd:e}),l.stop("Package update complete!"),R("Please review and test the upgraded package version."),!0},ht=async(e,t,s,n,r)=>{let a=w(e,I),o=ee(),l=r?.sync?a:t;o.start("Preparing template snapshot..."),r?.sync&&(await ct(e,I),await D(a)),o.message("Scanning for files...");let c=await W(s,n,l),i=[];if(r?.sync){o.message("Comparing with local files...");let d=await W(s,n,e),u=new Set(c);i=d.filter(k=>!u.has(k))}if(o.stop(`Found ${c.length} files to update`),c.length===0&&i.length===0){p.warn("No files matched the patterns. Nothing to update."),r?.sync&&await O(a),R("Update cancelled.");return}p.info(`Patterns: ${s.length}`),p.info(`Files to update: ${c.length}`),r?.sync&&p.info(`Files to delete: ${i.length}`),o.start("Updating files...");let g=await dt(c,i,l,e,o);r?.sync&&(o.message("Cleaning up..."),await O(a)),o.stop("Update complete!"),ut(g),R("Please review and test the changes carefully.")},te=async(e,t)=>{let s=process.cwd(),n=j(),r=e&&e.length>0?e:it,a=e&&e.length>0?[]:ot;try{if(rt("Let's update your Geistdocs project!"),await mt(s,e,t))return;p.info("Template source: bundled package snapshot"),e&&e.length>0&&p.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&p.info("Sync mode enabled: will delete files removed from template"),await ht(s,n,r,a,t)}catch(o){let l=o instanceof Error?o.message:`${o}`;try{await O(w(s,I))}catch{}p.error(`Failed to update project: ${l}`),process.exit(1)}};T.name("geistdocs").description("CLI for Geistdocs projects").version("1.3.0-canary.41d37f1","-v, --version","Output the current version");T.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(B);T.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(te);T.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(X);T.parse(process.argv);
2
+ import{program as T}from"commander";import{access as ce,copyFile as le}from"fs/promises";import{join as pe}from"path";import{cancel as de,intro as ge,isCancel as ue,log as fe,outro as me,spinner as he,text as we}from"@clack/prompts";import{spawn as te}from"child_process";import{readFileSync as se}from"fs";import{cp as ne,readFile as ae,rename as re,writeFile as ie}from"fs/promises";import{join as $}from"path";import{fileURLToPath as oe}from"url";var g="@vercel/geistdocs",m=(e,t=[],s={})=>new Promise((n,a)=>{let r=te(e,t,{stdio:"inherit",...s});r.on("error",a),r.on("close",i=>{if(i===0){n();return}a(new Error(`Command failed with exit code ${i}: ${[e,...t].join(" ")}`))})}),A=["dependencies","devDependencies","optionalDependencies","peerDependencies"],_=()=>JSON.parse(se(new URL("../../package.json",import.meta.url),"utf8")).version,P=async e=>{let t=$(e,"package.json"),s=await ae(t,"utf8");return JSON.parse(s)},x=async(e,t)=>{let s=$(e,"package.json");await ie(s,`${JSON.stringify(t,null,2)}
3
+ `,"utf8")},R=(e,t)=>{for(let s of A){let n=e[s];if(n&&t in n)return n[t]}},V=(e,t)=>!!R(e,t),b=(e,t,s)=>{let n=!1;for(let a of A){let r=e[a];r&&t in r&&(r[t]=s,n=!0)}return n},j=()=>oe(new URL("../../template",import.meta.url)),F=async e=>{await ne(j(),e,{recursive:!0});let t=$(e,".gitignore"),s=$(e,"_gitignore");try{await re(s,t)}catch{}};var ye=async e=>{await F(e)},Pe=async e=>{try{return await ce(e),!0}catch{return!1}},ve=async()=>{await Pe(".env.example")&&await le(".env.example",".env.local")},Te=async e=>{let t=await P(e),s=_();return b(t,g,s)?(await x(e,t),!0):!1},ke=async e=>{await m("pnpm",["install"],{cwd:e,env:process.env,stdio:"inherit"})},$e=async e=>{await m("git",["init"],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["add","."],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["commit","-m","\u2728 Initial commit"],{cwd:e,env:process.env,stdio:"inherit"})},xe=async()=>{let e=await we({message:"What is your project named?",placeholder:"my-app",validate(t){if(t.length===0)return"Please enter a project name."}});return ue(e)&&(de("Operation cancelled."),process.exit(0)),e.toString()},G=async e=>{try{ge("Let's start a Geistdocs project!");let t=process.cwd(),s=e.name||await xe(),n=he(),a=pe(t,s);n.start("Copying bundled template..."),await ye(s),n.message("Setting up environment variables..."),process.chdir(a),await ve(),n.message("Rewriting package dependency versions..."),await Te(a),n.message("Installing dependencies..."),await ke(a),e.disableGit||(n.message("Initializing Git repository..."),await $e(a)),n.stop("Project initialized successfully!"),me("Run `pnpm dev` to start the development server.")}catch(t){let s=t instanceof Error?t.message:`Failed to initialize project: ${t}`;fe.error(s),process.exit(1)}};import{readFileSync as be,writeFileSync as Fe}from"fs";import{mkdir as De,readFile as N,writeFile as Se}from"fs/promises";import{dirname as Ce,extname as Re,relative as M,resolve as S}from"path";import{intro as je,isCancel as Ee,log as h,multiselect as Ne,outro as D,spinner as Ue}from"@clack/prompts";import{glob as Oe}from"glob";import{Node as v,Project as Ie,SyntaxKind as Je}from"ts-morph";var Le="geistdocs.tsx",Ae="content/docs/**/*.mdx",U=".translation-cache.json",E=8,B=()=>({version:1,entries:{}}),_e=async e=>{let t=await N(e),{createHash:s}=await import("crypto");return s("sha256").update(t).digest("hex")},Ve=e=>{let t=S(process.cwd(),e);return be(t,"utf8")},z=e=>v.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(v.isPropertyAssignment(t)){let s=t.getNameNode();if(v.isIdentifier(s)||v.isStringLiteral(s))return[s.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Ge=e=>{try{let t=new Ie({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),s=Ve(e),r=t.createSourceFile(e,s,{overwrite:!0}).getVariableDeclarations().find(l=>l.getName()==="translations")?.getInitializer();if(!r)return[];if(v.isObjectLiteralExpression(r))return z(r);let i=r.getFirstDescendantByKind(Je.ObjectLiteralExpression);return i?z(i):[]}catch(t){let s=t instanceof Error?t.message:`${t}`;return h.warn(`Failed to read locales from ${e}: ${s}`),[]}},Be=async()=>{let e=await Ne({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ee(e)&&(D("Translation cancelled"),process.exit(0)),e},ze=async e=>(await Oe(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),He=async()=>{let e=S(process.cwd(),U);try{let t=await N(e,"utf8"),s=JSON.parse(t);return s.version!==1||!s.entries?B():{version:1,entries:s.entries}}catch{return B()}},H=e=>{let t=S(process.cwd(),U),s=JSON.stringify(e,null,2);Fe(t,s,"utf8")},Me=async e=>{let t=await Promise.all(e.map(async s=>[s,await _e(s)]));return Object.fromEntries(t)},Ke=(e,t)=>{let s=Re(e);return`${e.slice(0,-s.length)}.${t}${s}`},K=(e,t)=>`${M(process.cwd(),e)}::${t}`,qe=(e,t,s,n,a=!1)=>{let r=[],i=0;for(let l of t){let c=s[l];for(let o of e){let d=Ke(l,o),u=K(l,o),f=n.entries[u];if(!a&&f?.hash===c){i+=1;continue}r.push({locale:o,sourceFile:l,sourceHash:c,targetFile:d})}}return{tasks:r,skippedCount:i}},Xe=async e=>{await De(Ce(e),{recursive:!0})},We=async(e,t,s)=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:s})});if(!n.ok){let r=await n.text();throw new Error(`API request failed (${n.status}): ${r}`)}let a=await n.json();if(!a.translation)throw new Error("API response did not include a translation");return a.translation},Ye=async(e,t,s)=>{let n=await N(e.sourceFile,"utf8"),a=await We(t,n,e.locale);await Xe(e.targetFile),await Se(e.targetFile,a,"utf8"),s.entries[K(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},q=async(e,t)=>{je("Translate MDX content");let s=e??Ae,n=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",a=Ge(t.config??Le),r=await ze(s);r.length===0&&(h.error(`No MDX files found matching pattern: ${s}`),D("Translation cancelled"),process.exit(1)),h.info(`Found ${r.length} MDX file(s) matching pattern`),a.length===0&&(a=await Be());let i=S(process.cwd(),U),l=await He();await H(l),h.info(`Using cache: ${i}`);let c=await Me(r),{tasks:o,skippedCount:d}=qe(a,r,c,l,t.force);if(o.length===0){h.success("All translations are up to date!"),D(`Skipped ${d} file(s) (unchanged)`);return}let u=[];for(let y=0;y<o.length;y+=E)u.push(o.slice(y,y+E));h.info(`Processing ${o.length} translation(s) in ${u.length} batch(es) of up to ${E}`),d>0&&h.info(`Skipped ${d} translation(s) (unchanged)`);let f=Ue();f.start("Translating content...");let k=0;for(let y of u)await Promise.all(y.map(async L=>{await Ye(L,n,l),k+=1,f.message(`Translated ${k}/${o.length}: ${M(process.cwd(),L.targetFile)}`)})),await H(l);f.stop("Translation complete!"),D(`Created/updated ${o.length} file(s)`)};import{access as Ze,copyFile as Qe,mkdir as Z,rm as J}from"fs/promises";import{dirname as et,join as w}from"path";import{intro as tt,log as p,outro as C,spinner as Q}from"@clack/prompts";import{glob as st}from"glob";var nt=["**/*"],at=["content/docs/**"],O=".geistdocs-tmp",rt=async(e,t)=>{let s=w(e,t);await J(s,{recursive:!0,force:!0}),await Z(s,{recursive:!0})},I=async e=>await J(e,{recursive:!0,force:!0}),X=async(e,t,s)=>(await st(e,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),it=async e=>{try{return await Ze(e),!0}catch{return!1}},ot=async(e,t,s)=>{let n=w(t,e),a=w(s,e);return await it(n)?(await Qe(n,a),{success:!0}):{success:!1,error:`Source file not found: ${n}`}},ct=async(e,t)=>{let s=w(t,e);return await J(s,{force:!0}),{success:!0}},W=20,Y=async(e,t,s)=>{let n=[];for(let a=0;a<e.length;a+=s){let r=e.slice(a,a+s),i=await Promise.all(r.map(t));n.push(...i)}return n},lt=async(e,t,s,n,a)=>{let r={success:[],deleted:[],failed:[]},i=[...new Set(e.map(c=>et(w(n,c))))];a.message(`Creating ${i.length} directories...`),await Promise.all(i.map(c=>Z(c,{recursive:!0}))),a.message(`Updating ${e.length} files...`);let l=await Y(e,async c=>{let o=await ot(c,s,n);return{file:c,...o}},W);for(let{file:c,success:o,error:d}of l)o?r.success.push(c):r.failed.push({file:c,error:d??"Unknown error"});if(t.length>0){a.message(`Deleting ${t.length} files...`);let c=await Y(t,async o=>{try{return await ct(o,n),{file:o,success:!0}}catch(d){let u=d instanceof Error?d.message:`${d}`;return{file:o,success:!1,error:u}}},W);for(let o of c)o.success?r.deleted.push(o.file):r.failed.push({file:o.file,error:o.error})}return r},pt=e=>{if(e.success.length>0){p.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)p.info(` \u2713 ${t}`)}if(e.deleted.length>0){p.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)p.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){p.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:s}of e.failed)p.error(` \u2717 ${t}: ${s}`)}},dt=e=>e.includes("canary")?"canary":"latest",gt=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(g)}`);if(!t.ok)throw new Error(`Failed to resolve ${g}@${e}`);let n=(await t.json())["dist-tags"]?.[e];if(!n)throw new Error(`Could not find dist-tag ${e} for ${g}`);return n},ut=async e=>{let t=await P(e),s=R(t,g);if(!s)return{currentVersion:s,nextVersion:void 0,updated:!1};let n=dt(s),a=await gt(n);return s===a?{currentVersion:s,nextVersion:a,updateTag:n,updated:!1}:(b(t,g,a),await x(e,t),{currentVersion:s,nextVersion:a,updateTag:n,updated:!0})},ft=async(e,t,s)=>{let n=await P(e);if(!V(n,g))return!1;t&&t.length>0&&p.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),s?.sync&&p.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:a,nextVersion:r,updateTag:i,updated:l}=await ut(e);if(!l)return p.success(a?`@vercel/geistdocs is already at ${r} (${i}).`:"No package version update was needed."),C("Package-based site is already up to date."),!0;p.info(`Bumping ${g} from ${a} to ${r} (${i})`);let c=Q();return c.start("Installing updated package version..."),await m("pnpm",["install"],{cwd:e}),c.stop("Package update complete!"),C("Please review and test the upgraded package version."),!0},mt=async(e,t,s,n,a)=>{let r=w(e,O),i=Q(),l=a?.sync?r:t;i.start("Preparing template snapshot..."),a?.sync&&(await rt(e,O),await F(r)),i.message("Scanning for files...");let c=await X(s,n,l),o=[];if(a?.sync){i.message("Comparing with local files...");let u=await X(s,n,e),f=new Set(c);o=u.filter(k=>!f.has(k))}if(i.stop(`Found ${c.length} files to update`),c.length===0&&o.length===0){p.warn("No files matched the patterns. Nothing to update."),a?.sync&&await I(r),C("Update cancelled.");return}p.info(`Patterns: ${s.length}`),p.info(`Files to update: ${c.length}`),a?.sync&&p.info(`Files to delete: ${o.length}`),i.start("Updating files...");let d=await lt(c,o,l,e,i);a?.sync&&(i.message("Cleaning up..."),await I(r)),i.stop("Update complete!"),pt(d),C("Please review and test the changes carefully.")},ee=async(e,t)=>{let s=process.cwd(),n=j(),a=e&&e.length>0?e:nt,r=e&&e.length>0?[]:at;try{if(tt("Let's update your Geistdocs project!"),await ft(s,e,t))return;p.info("Template source: bundled package snapshot"),e&&e.length>0&&p.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&p.info("Sync mode enabled: will delete files removed from template"),await mt(s,n,a,r,t)}catch(i){let l=i instanceof Error?i.message:`${i}`;try{await I(w(s,O))}catch{}p.error(`Failed to update project: ${l}`),process.exit(1)}};T.name("geistdocs").description("CLI for Geistdocs projects").version("1.3.0-canary.5af98bc","-v, --version","Output the current version");T.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(G);T.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(ee);T.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(q);T.parse(process.argv);
@@ -1 +1 @@
1
- {"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAMf,UAAU,cAAc;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,SAAS,GAAI,gEAQvB,cAAc,4CAmGhB,CAAC"}
1
+ {"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAMf,UAAU,cAAc;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,SAAS,GAAI,gEAQvB,cAAc,4CAuGhB,CAAC"}
@@ -31,7 +31,11 @@ export const CodeBlock = ({ children, className, icon, style, tabIndex, title, .
31
31
  }
32
32
  }, []);
33
33
  const Icon = isCopied ? CheckIcon : CopyIcon;
34
- const CodeBlockComponent = useCallback((props) => (_jsx("pre", { className: cn("not-prose flex-1 overflow-x-auto rounded-sm border bg-background py-3 text-sm outline-none", "[&>code]:grid [&>code]:min-w-max", className, props.className), ref: ref, style: style, tabIndex: tabIndex, children: children })), [children, style, tabIndex, className]);
34
+ const CodeBlockComponent = useCallback((props) => (_jsx("pre", { className: cn("not-prose flex-1 overflow-x-auto rounded-sm border bg-background py-3 text-sm outline-none", "[&>code]:grid [&>code]:min-w-max", className, props.className), ref: ref, style: {
35
+ fontFeatureSettings: '"liga" 0, "calt" 0',
36
+ fontVariantLigatures: "none",
37
+ ...style,
38
+ }, tabIndex: tabIndex, children: children })), [children, style, tabIndex, className]);
35
39
  if (!title) {
36
40
  return (_jsxs("div", { className: "relative mb-6", children: [_jsx(CodeBlockComponent, { className: cn(lineNumbers ? "line-numbers" : "", className) }), _jsx(Button, { className: "absolute top-[5px] right-[5px] bg-background/80 backdrop-blur-sm", onClick: copyToClipboard, size: "icon", variant: "ghost", children: _jsx(Icon, { size: 14 }) })] }));
37
41
  }
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ interface CopyPromptProps {
3
+ children?: ReactNode;
4
+ className?: string;
5
+ projectOnly?: boolean;
6
+ text: string;
7
+ title?: string;
8
+ }
9
+ export declare const CopyPrompt: ({ children, className, projectOnly, text, title, }: CopyPromptProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=copy-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-prompt.d.ts","sourceRoot":"","sources":["../../src/components/copy-prompt.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAWjD,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqBD,eAAO,MAAM,UAAU,GAAI,oDAMxB,eAAe,4CAoIjB,CAAC"}
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CheckIcon, ChevronDownIcon, ChevronUpIcon, ExternalLinkIcon, } from "lucide-react";
4
+ import { useState } from "react";
5
+ import { cn } from "../internal/cn";
6
+ import { Button } from "../internal/ui/button";
7
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "../internal/ui/dropdown-menu";
8
+ const getPlatformUrl = (platform, prompt) => {
9
+ const encoded = encodeURIComponent(prompt);
10
+ switch (platform) {
11
+ case "v0":
12
+ return `https://v0.app/chat?q=${encoded}`;
13
+ case "Claude":
14
+ return `https://claude.ai/new?q=${encoded}`;
15
+ case "ChatGPT":
16
+ return `https://chatgpt.com/?q=${encoded}`;
17
+ case "Cursor":
18
+ return `cursor://anysphere.cursor-deeplink/prompt?text=${encoded}`;
19
+ default:
20
+ return encoded;
21
+ }
22
+ };
23
+ export const CopyPrompt = ({ children, className, projectOnly = false, text, title = "Prompt for coding agents", }) => {
24
+ const [isCopied, setIsCopied] = useState(false);
25
+ const [isExpanded, setIsExpanded] = useState(false);
26
+ const copy = async () => {
27
+ await navigator.clipboard.writeText(text);
28
+ setIsCopied(true);
29
+ setTimeout(() => setIsCopied(false), 2000);
30
+ };
31
+ const openPlatform = (platform) => {
32
+ window.open(getPlatformUrl(platform, text), "_blank", "noopener");
33
+ };
34
+ const menuItems = [
35
+ { icon: _jsx(V0Logo, {}), label: "Open in v0", platform: "v0" },
36
+ ...(projectOnly
37
+ ? []
38
+ : [
39
+ {
40
+ icon: _jsx(ClaudeLogo, {}),
41
+ label: "Open in Claude",
42
+ platform: "Claude",
43
+ },
44
+ {
45
+ icon: _jsx(OpenAILogo, {}),
46
+ label: "Open in ChatGPT",
47
+ platform: "ChatGPT",
48
+ },
49
+ ]),
50
+ { icon: _jsx(CursorLogo, {}), label: "Open in Cursor", platform: "Cursor" },
51
+ ];
52
+ return (_jsx("div", { className: cn("not-prose my-4 mb-10 hidden w-full md:block", className), children: _jsxs("div", { className: "rounded-md border border-gray-400 bg-background-100", children: [_jsx("div", { className: "min-h-12 rounded-t-md border-gray-400 border-b bg-background-200 py-2 pr-2 pl-4", children: _jsxs("div", { className: "flex items-center justify-between gap-4", children: [_jsx("div", { className: "flex items-center gap-2 text-gray-900 text-label-13", children: title }), _jsxs("div", { className: "inline-flex shrink-0 overflow-hidden rounded-md border bg-background shadow-xs", children: [_jsxs("button", { className: "inline-flex h-8 items-center gap-1.5 px-3 font-medium text-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50", onClick: copy, type: "button", children: [_jsxs("span", { className: "relative size-4", children: [_jsx(CopyPromptIcon, { className: cn("absolute inset-0 transition-all duration-200", isCopied ? "scale-75 opacity-0" : "scale-100 opacity-100") }), _jsx(CheckIcon, { className: cn("absolute inset-0 size-4 transition-all duration-200", isCopied ? "scale-100 opacity-100" : "scale-75 opacity-0") })] }), _jsx("span", { children: "Copy" })] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { "aria-label": "Copy prompt actions", className: "inline-flex h-8 w-8 items-center justify-center border-l transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50", type: "button", children: _jsx(ChevronDownIcon, { className: "size-4" }) }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-60", children: menuItems.map((item, index) => (_jsxs("div", { children: [index === 1 ? _jsx(DropdownMenuSeparator, {}) : null, _jsxs(DropdownMenuItem, { onClick: () => openPlatform(item.platform), children: [item.icon, _jsx("span", { className: "flex-1", children: item.label }), _jsx(ExternalLinkIcon, { className: "size-4" })] })] }, item.platform))) })] })] })] }) }), _jsxs("div", { className: "relative isolate rounded-b-md bg-background-100 p-4 pb-5", children: [_jsxs("div", { className: "relative overflow-hidden", children: [_jsx("div", { className: cn("break-words text-gray-900 text-sm leading-relaxed [&_a]:font-normal [&_a]:text-primary [&_a]:no-underline hover:[&_a]:underline [&_code]:rounded [&_code]:bg-gray-100 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em]", isExpanded ? "" : "line-clamp-2", isExpanded ? "whitespace-pre-wrap" : ""), children: children ?? text }), isExpanded ? null : (_jsx("div", { className: "pointer-events-none absolute inset-0 bg-linear-to-b from-transparent via-transparent to-background-100" }))] }), _jsx("div", { className: "absolute left-1/2 -translate-x-1/2 translate-y-1/5", children: _jsxs(Button, { className: "mt-0 h-7 rounded-full border bg-background px-2 text-muted-foreground text-xs shadow-sm hover:text-foreground", onClick: () => setIsExpanded((current) => !current), size: "sm", type: "button", variant: "secondary", children: [isExpanded ? (_jsx(ChevronUpIcon, { className: "size-3.5" })) : (_jsx(ChevronDownIcon, { className: "size-3.5" })), isExpanded ? "Show less" : "Show more"] }) })] })] }) }));
53
+ };
54
+ const CopyPromptIcon = ({ className }) => (_jsxs("svg", { "aria-hidden": true, className: className, fill: "none", height: "16", viewBox: "0 0 16 16", width: "16", children: [_jsx("title", { children: "Copy prompt" }), _jsx("path", { d: "M6.75 14a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-7.5-3.25a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m7.5 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5M8.25.5C9.22.5 10 1.28 10 2.25V3H8.5v-.75A.25.25 0 0 0 8.25 2h-5.5a.25.25 0 0 0-.25.25v7.5c0 .14.11.25.25.25H4.5v1.5H2.75C1.78 11.5 1 10.72 1 9.75v-7.5C1 1.28 1.78.5 2.75.5zm-1.5 7.25a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m7.5 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5M6.75 4.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5", fill: "currentColor" })] }));
55
+ const V0Logo = () => _jsx("span", { className: "font-semibold text-xs", children: "v0" });
56
+ const OpenAILogo = () => _jsx("span", { className: "font-semibold text-xs", children: "AI" });
57
+ const ClaudeLogo = () => (_jsxs("svg", { "aria-hidden": true, className: "size-4", fill: "none", viewBox: "0 0 12 12", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("title", { children: "Claude" }), _jsx("path", { clipRule: "evenodd", d: "M2.3545 7.9775L4.7145 6.654L4.7545 6.539L4.7145 6.475H4.6L4.205 6.451L2.856 6.4145L1.6865 6.366L0.5535 6.305L0.268 6.2445L0 5.892L0.0275 5.716L0.2675 5.5555L0.6105 5.5855L1.3705 5.637L2.5095 5.716L3.3355 5.7645L4.56 5.892H4.7545L4.782 5.8135L4.715 5.7645L4.6635 5.716L3.4845 4.918L2.2085 4.074L1.5405 3.588L1.1785 3.3425L0.9965 3.1115L0.9175 2.6075L1.2455 2.2465L1.686 2.2765L1.7985 2.307L2.245 2.65L3.199 3.388L4.4445 4.3045L4.627 4.4565L4.6995 4.405L4.709 4.3685L4.627 4.2315L3.9495 3.0085L3.2265 1.7635L2.9045 1.2475L2.8195 0.938C2.78711 0.819128 2.76965 0.696687 2.7675 0.5735L3.1415 0.067L3.348 0L3.846 0.067L4.056 0.249L4.366 0.956L4.867 2.0705L5.6445 3.5855L5.8725 4.0345L5.994 4.4505L6.0395 4.578H6.1185V4.505L6.1825 3.652L6.301 2.6045L6.416 1.257L6.456 0.877L6.644 0.422L7.0175 0.176L7.3095 0.316L7.5495 0.6585L7.516 0.8805L7.373 1.806L7.0935 3.2575L6.9115 4.2285H7.0175L7.139 4.1075L7.6315 3.4545L8.4575 2.4225L8.8225 2.0125L9.2475 1.5605L9.521 1.345H10.0375L10.4175 1.9095L10.2475 2.4925L9.7155 3.166L9.275 3.737L8.643 4.587L8.248 5.267L8.2845 5.322L8.3785 5.312L9.8065 5.009L10.578 4.869L11.4985 4.7115L11.915 4.9055L11.9605 5.103L11.7965 5.5065L10.812 5.7495L9.6575 5.9805L7.938 6.387L7.917 6.402L7.9415 6.4325L8.716 6.5055L9.047 6.5235H9.858L11.368 6.636L11.763 6.897L12 7.216L11.9605 7.4585L11.353 7.7685L10.533 7.574L8.6185 7.119L7.9625 6.9545H7.8715V7.0095L8.418 7.5435L9.421 8.4485L10.6755 9.6135L10.739 9.9025L10.578 10.13L10.408 10.1055L9.3055 9.277L8.88 8.9035L7.917 8.0935H7.853V8.1785L8.075 8.503L9.2475 10.2635L9.3085 10.8035L9.2235 10.98L8.9195 11.0865L8.5855 11.0255L7.8985 10.063L7.191 8.9795L6.6195 8.008L6.5495 8.048L6.2125 11.675L6.0545 11.86L5.69 12L5.3865 11.7695L5.2255 11.396L5.3865 10.658L5.581 9.696L5.7385 8.931L5.8815 7.981L5.9665 7.665L5.9605 7.644L5.8905 7.653L5.1735 8.6365L4.0835 10.109L3.2205 11.0315L3.0135 11.1135L2.655 10.9285L2.6885 10.5975L2.889 10.303L4.083 8.785L4.803 7.844L5.268 7.301L5.265 7.222H5.2375L2.066 9.28L1.501 9.353L1.2575 9.1105L1.288 8.737L1.4105 8.6095L2.3545 7.9775Z", fill: "currentColor", fillRule: "evenodd" })] }));
58
+ const CursorLogo = () => (_jsxs("svg", { "aria-hidden": true, className: "size-4", fill: "none", viewBox: "0 0 21 22", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("title", { children: "Cursor" }), _jsx("path", { d: "M19.162 5.452 10.698.565a.88.88 0 0 0-.879 0L1.356 5.452a.74.74 0 0 0-.37.64v9.853a.74.74 0 0 0 .37.64l8.464 4.887a.879.879 0 0 0 .879 0l8.464-4.886a.74.74 0 0 0 .37-.64V6.091a.74.74 0 0 0-.37-.64Zm-.531 1.035L10.46 20.639c-.055.095-.201.056-.201-.055v-9.266a.52.52 0 0 0-.26-.45L1.975 6.237c-.096-.056-.057-.202.054-.202h16.34c.233 0 .378.252.262.453Z", fill: "currentColor" })] }));
@@ -3,12 +3,11 @@ import type { GeistdocsConfig } from "../config";
3
3
  interface GeistdocsPageActionsProps {
4
4
  config: Pick<GeistdocsConfig, "ai" | "feedback" | "github" | "pageActions" | "siteId">;
5
5
  extraActions: ReactNode[];
6
- markdown: string;
7
6
  page: {
8
7
  path?: string;
9
8
  url: string;
10
9
  };
11
10
  }
12
- export declare const GeistdocsPageActions: ({ config, extraActions, markdown, page, }: GeistdocsPageActionsProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const GeistdocsPageActions: ({ config, extraActions, page, }: GeistdocsPageActionsProps) => import("react/jsx-runtime").JSX.Element;
13
12
  export {};
14
13
  //# sourceMappingURL=page-actions-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAcjD,UAAU,yBAAyB;IACjC,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAiSD,eAAO,MAAM,oBAAoB,GAAI,2CAKlC,yBAAyB,4CAuC3B,CAAC"}
1
+ {"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAcjD,UAAU,yBAAyB;IACjC,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AA2SD,eAAO,MAAM,oBAAoB,GAAI,iCAIlC,yBAAyB,4CAuC3B,CAAC"}
@@ -11,7 +11,7 @@ import { Button } from "./ui/button";
11
11
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "./ui/dropdown-menu";
12
12
  import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
13
13
  import { Textarea } from "./ui/textarea";
14
- const actionClassName = "flex items-center gap-1.5 text-muted-foreground text-sm transition-colors hover:text-foreground";
14
+ const actionClassName = "group flex min-h-7 w-full min-w-0 items-center gap-2 rounded-md text-left text-muted-foreground text-sm leading-5 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background [&_svg]:size-3.5 [&_svg]:shrink-0 [&_span]:min-w-0 [&_span]:truncate";
15
15
  const feedbackEmotions = [
16
16
  { name: "cry", emoji: "😭" },
17
17
  { name: "sad", emoji: "😕" },
@@ -64,9 +64,15 @@ const EditSourceAction = ({ github, path, }) => {
64
64
  }
65
65
  return (_jsxs("a", { className: actionClassName, href: url, rel: "noopener noreferrer", target: "_blank", children: [_jsx(SiGithub, { className: "size-3.5" }), _jsx("span", { children: "Edit this page on GitHub" })] }));
66
66
  };
67
- const CopyPageAction = ({ text }) => {
67
+ const getMarkdownUrl = (url) => url === "/docs" ? "/docs.md" : `${url}.md`;
68
+ const CopyPageAction = ({ url }) => {
69
+ const pathname = usePathname();
68
70
  const [checked, handleCopy] = useCopyButton(async () => {
69
- await navigator.clipboard.writeText(text);
71
+ const response = await fetch(getMarkdownUrl(pathname || url));
72
+ if (!response.ok) {
73
+ throw new Error(`Failed to fetch markdown for ${url}`);
74
+ }
75
+ await navigator.clipboard.writeText(await response.text());
70
76
  });
71
77
  const Icon = checked ? CheckIcon : CopyIcon;
72
78
  return (_jsxs("button", { className: actionClassName, onClick: handleCopy, type: "button", children: [_jsx(Icon, { className: "size-3.5" }), _jsx("span", { children: "Copy page" })] }));
@@ -75,7 +81,7 @@ const OpenInChatAction = ({ href }) => {
75
81
  const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
76
82
  const url = new URL(href, `${protocol}://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`).toString();
77
83
  const query = `Read this page, I want to ask questions about it. ${url}`;
78
- return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { className: actionClassName, type: "button", children: [_jsx(ExternalLinkIcon, { className: "size-4" }), "Open in chat"] }) }), _jsx(DropdownMenuContent, { align: "start", side: "top", children: openInProviders.map((provider, index) => (_jsxs("div", { children: [index === 1 ? _jsx(DropdownMenuSeparator, {}) : null, _jsx(DropdownMenuItem, { asChild: true, children: _jsxs("a", { className: "flex items-center gap-2", href: provider.getHref(query), rel: "noopener", target: "_blank", children: [_jsx("span", { className: "flex-1", children: provider.label }), _jsx(ExternalLinkIcon, { className: "size-4 shrink-0" })] }) })] }, provider.id))) })] }));
84
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { className: actionClassName, type: "button", children: [_jsx(ExternalLinkIcon, {}), _jsx("span", { children: "Open in chat" })] }) }), _jsx(DropdownMenuContent, { align: "start", side: "top", children: openInProviders.map((provider, index) => (_jsxs("div", { children: [index === 1 ? _jsx(DropdownMenuSeparator, {}) : null, _jsx(DropdownMenuItem, { asChild: true, children: _jsxs("a", { className: "flex items-center gap-2", href: provider.getHref(query), rel: "noopener", target: "_blank", children: [_jsx("span", { className: "flex-1", children: provider.label }), _jsx(ExternalLinkIcon, { className: "size-4 shrink-0" })] }) })] }, provider.id))) })] }));
79
85
  };
80
86
  const ScrollTopAction = () => (_jsxs("button", { className: actionClassName, onClick: () => window.scrollTo({ top: 0, behavior: "smooth" }), type: "button", children: [_jsx(ArrowUpCircleIcon, { className: "size-3.5" }), _jsx("span", { children: "Scroll to top" })] }));
81
87
  const AskAIAction = ({ href }) => {
@@ -130,7 +136,7 @@ const FeedbackAction = ({ siteId }) => {
130
136
  ? "bg-accent text-foreground"
131
137
  : "text-muted-foreground hover:text-foreground", onClick: () => setEmotion(entry.name), size: "sm", type: "button", variant: "ghost", children: [entry.emoji, _jsx("span", { className: "sr-only", children: entry.name })] }, entry.name))) }), _jsx(Button, { disabled: isPending || !emotion || !message, size: "sm", type: "submit", variant: "default", children: "Send" })] })] })) }) })] }));
132
138
  };
133
- export const GeistdocsPageActions = ({ config, extraActions, markdown, page, }) => {
139
+ export const GeistdocsPageActions = ({ config, extraActions, page, }) => {
134
140
  const actions = [];
135
141
  if (config.pageActions?.editSource !== false) {
136
142
  actions.push(_jsx(EditSourceAction, { github: config.github, path: page.path }, "edit-source"));
@@ -142,7 +148,7 @@ export const GeistdocsPageActions = ({ config, extraActions, markdown, page, })
142
148
  actions.push(_jsx(FeedbackAction, { siteId: config.siteId }, "feedback"));
143
149
  }
144
150
  if (config.pageActions?.copyPage !== false) {
145
- actions.push(_jsx(CopyPageAction, { text: markdown }, "copy-page"));
151
+ actions.push(_jsx(CopyPageAction, { url: page.url }, "copy-page"));
146
152
  }
147
153
  if (config.ai?.enabled !== false && config.pageActions?.askAI !== false) {
148
154
  actions.push(_jsx(AskAIAction, { href: page.url }, "ask-ai"));
@@ -0,0 +1,9 @@
1
+ import { RootProvider } from "fumadocs-ui/provider/next";
2
+ import { type ComponentProps } from "react";
3
+ import type { GeistdocsConfig } from "../config";
4
+ export interface GeistdocsProviderProps extends ComponentProps<typeof RootProvider> {
5
+ config: Pick<GeistdocsConfig, "ai" | "basePath" | "defaultLanguage" | "title" | "translations">;
6
+ lang?: string;
7
+ }
8
+ export declare const GeistdocsProvider: (props: GeistdocsProviderProps) => import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=provider-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAUjD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,iBAAiB,GAAG,OAAO,GAAG,cAAc,CACjE,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA0CD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAI9D,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { RootProvider } from "fumadocs-ui/provider/next";
4
+ import { useCallback } from "react";
5
+ import { GeistdocsChatProvider, useGeistdocsChat } from "./chat/context";
6
+ import { GeistdocsChatShell } from "./chat/shell";
7
+ import { cn } from "./cn";
8
+ import { createGeistdocsI18n } from "./i18n";
9
+ import { GeistdocsSearchDialog } from "./search";
10
+ import { Toaster } from "./ui/sonner";
11
+ import { TooltipProvider } from "./ui/tooltip";
12
+ import { useIsMobile } from "./use-mobile";
13
+ const GeistdocsProviderInner = ({ config, search, lang, ...props }) => {
14
+ const { i18n, i18nProvider } = createGeistdocsI18n(config);
15
+ const { enabled, isOpen } = useGeistdocsChat();
16
+ const isMobile = useIsMobile();
17
+ const SearchDialogComponent = useCallback((searchProps) => (_jsx(GeistdocsSearchDialog, { basePath: config.basePath, ...searchProps })), [config.basePath]);
18
+ return (_jsx("div", { className: cn("transition-all", enabled && isOpen && !isMobile ? "pr-96!" : null), children: _jsxs(TooltipProvider, { children: [_jsx(RootProvider, { i18n: i18nProvider(lang ?? i18n.defaultLanguage), search: {
19
+ SearchDialog: SearchDialogComponent,
20
+ ...search,
21
+ }, ...props }), _jsx(Toaster, {}), _jsx(GeistdocsChatShell, {})] }) }));
22
+ };
23
+ export const GeistdocsProvider = (props) => (_jsx(GeistdocsChatProvider, { config: props.config, children: _jsx(GeistdocsProviderInner, { ...props }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAa1F,eAAO,MAAM,gBAAgB,+CAsD5B,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,yBAAyB,CAAC,QAAQ,CA2BtE,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,CAAC,MAAM,CAWlE,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,yBAAyB,CAAC,WAAW,CAM1E,CAAC"}
1
+ {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAc1F,eAAO,MAAM,gBAAgB,+CAsD5B,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,yBAAyB,CAAC,QAAQ,CA2BtE,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,CAAC,MAAM,CAWlE,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,yBAAyB,CAAC,WAAW,CAM1E,CAAC"}
@@ -3,12 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem, SidebarSeparator, } from "fumadocs-ui/components/sidebar/base";
4
4
  import { useTreeContext, useTreePath } from "fumadocs-ui/contexts/tree";
5
5
  import { usePathname } from "next/navigation";
6
- import { Fragment, useEffect, useRef, useState } from "react";
6
+ import { Fragment, useEffect, useRef } from "react";
7
7
  import { SearchButton } from "../controls";
8
+ import { useGeistdocsSidebar } from "../sidebar";
8
9
  import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./ui/sheet";
9
10
  export const GeistdocsSidebar = () => {
10
11
  const { root } = useTreeContext();
11
- const [isOpen, setIsOpen] = useState(false);
12
+ const { isOpen, setIsOpen } = useGeistdocsSidebar();
12
13
  const pathname = usePathname();
13
14
  const previousPathname = useRef(pathname);
14
15
  useEffect(() => {
@@ -16,7 +17,7 @@ export const GeistdocsSidebar = () => {
16
17
  setIsOpen(false);
17
18
  previousPathname.current = pathname;
18
19
  }
19
- }, [pathname]);
20
+ }, [pathname, setIsOpen]);
20
21
  const renderSidebarList = (items) => items.map((item) => {
21
22
  if (item.type === "separator") {
22
23
  return _jsx(GeistdocsSidebarSeparator, { item: item }, item.$id);
@@ -0,0 +1,9 @@
1
+ import type { TableOfContents } from "fumadocs-core/toc";
2
+ import type { ReactNode } from "react";
3
+ interface GeistdocsTableOfContentsProps {
4
+ footer?: ReactNode;
5
+ toc: TableOfContents;
6
+ }
7
+ export declare const GeistdocsTableOfContents: ({ footer, toc, }: GeistdocsTableOfContentsProps) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=table-of-contents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-of-contents.d.ts","sourceRoot":"","sources":["../../src/internal/table-of-contents.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,6BAA6B;IACrC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,GAAG,EAAE,eAAe,CAAC;CACtB;AAED,eAAO,MAAM,wBAAwB,GAAI,kBAGtC,6BAA6B,4CAe/B,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { TOCItems } from "fumadocs-ui/components/toc/clerk";
4
+ import { TOCScrollArea } from "fumadocs-ui/components/toc/index";
5
+ export const GeistdocsTableOfContents = ({ footer, toc, }) => (_jsx("aside", { "aria-label": "Page navigation", className: "sticky top-(--fd-docs-row-1) hidden h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] w-(--fd-toc-width) flex-col pt-12 pr-4 pb-2 [grid-area:toc] xl:flex", id: "nd-toc", children: _jsxs("nav", { "aria-label": "On this page", className: "flex min-h-0 flex-1 flex-col", children: [toc.length > 0 ? (_jsx(TOCScrollArea, { children: _jsx(TOCItems, {}) })) : null, footer] }) }));
package/dist/layout.d.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  import { DocsLayout as FumadocsDocsLayout } from "fumadocs-ui/layouts/docs";
2
- import { RootProvider } from "fumadocs-ui/provider/next";
3
- import { type ComponentProps, type ReactNode } from "react";
2
+ import type { ComponentProps, ReactNode } from "react";
4
3
  import type { GeistdocsConfig } from "./config";
5
- interface GeistdocsProviderProps extends ComponentProps<typeof RootProvider> {
6
- config: Pick<GeistdocsConfig, "ai" | "basePath" | "defaultLanguage" | "title" | "translations">;
7
- lang?: string;
8
- }
9
- export declare const GeistdocsProvider: (props: GeistdocsProviderProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const GeistdocsProvider: (props: import("./internal/provider-client").GeistdocsProviderProps) => import("react/jsx-runtime").JSX.Element;
10
5
  interface GeistdocsDocsLayoutProps {
11
6
  children: ReactNode;
12
7
  config: Pick<GeistdocsConfig, "defaultLanguage" | "translations">;
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAmBhD,UAAU,sBAAuB,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC1E,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,iBAAiB,GAAG,OAAO,GAAG,cAAc,CACjE,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA0CD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAI9D,CAAC;AAEF,UAAU,wBAAwB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7E,IAAI,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,GAAI,6CAKjC,wBAAwB,4CAqC1B,CAAC"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAWhD,eAAO,MAAM,iBAAiB,iHAA0B,CAAC;AAEzD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7E,IAAI,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,GAAI,6CAKjC,wBAAwB,4CAuC1B,CAAC"}
package/dist/layout.js CHANGED
@@ -1,49 +1,31 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import { DocsLayout as FumadocsDocsLayout } from "fumadocs-ui/layouts/docs";
4
- import { RootProvider } from "fumadocs-ui/provider/next";
5
- import { useCallback, } from "react";
6
- import { GeistdocsChatProvider, useGeistdocsChat, } from "./internal/chat/context";
7
- import { GeistdocsChatShell } from "./internal/chat/shell";
8
- import { cn } from "./internal/cn";
9
3
  import { createGeistdocsI18n } from "./internal/i18n";
10
- import { GeistdocsSearchDialog } from "./internal/search";
4
+ import { GeistdocsProvider as GeistdocsProviderClient } from "./internal/provider-client";
11
5
  import { GeistdocsSidebar, GeistdocsSidebarFolder, GeistdocsSidebarItem, GeistdocsSidebarSeparator, } from "./internal/sidebar";
12
- import { Toaster } from "./internal/ui/sonner";
13
- import { TooltipProvider } from "./internal/ui/tooltip";
14
- import { useIsMobile } from "./internal/use-mobile";
15
- const GeistdocsProviderInner = ({ config, search, lang, ...props }) => {
16
- const { i18n, i18nProvider } = createGeistdocsI18n(config);
17
- const { enabled, isOpen } = useGeistdocsChat();
18
- const isMobile = useIsMobile();
19
- const SearchDialogComponent = useCallback((searchProps) => (_jsx(GeistdocsSearchDialog, { basePath: config.basePath, ...searchProps })), [config.basePath]);
20
- return (_jsx("div", { className: cn("transition-all", enabled && isOpen && !isMobile ? "pr-96!" : null), children: _jsxs(TooltipProvider, { children: [_jsx(RootProvider, { i18n: i18nProvider(lang ?? i18n.defaultLanguage), search: {
21
- SearchDialog: SearchDialogComponent,
22
- ...search,
23
- }, ...props }), _jsx(Toaster, {}), _jsx(GeistdocsChatShell, {})] }) }));
24
- };
25
- export const GeistdocsProvider = (props) => (_jsx(GeistdocsChatProvider, { config: props.config, children: _jsx(GeistdocsProviderInner, { ...props }) }));
6
+ import { GeistdocsSidebarProvider } from "./sidebar";
7
+ export const GeistdocsProvider = GeistdocsProviderClient;
26
8
  export const GeistdocsDocsLayout = ({ config, containerProps, tree, children, }) => {
27
9
  const { i18n } = createGeistdocsI18n(config);
28
- return (_jsx(FumadocsDocsLayout, { containerProps: {
29
- ...containerProps,
30
- style: {
31
- ...(containerProps?.style ?? {}),
32
- "--fd-docs-row-1": "4rem",
33
- },
34
- }, i18n: i18n, nav: {
35
- enabled: false,
36
- }, searchToggle: {
37
- enabled: false,
38
- }, sidebar: {
39
- collapsible: false,
40
- component: _jsx(GeistdocsSidebar, {}),
41
- components: {
42
- Folder: GeistdocsSidebarFolder,
43
- Item: GeistdocsSidebarItem,
44
- Separator: GeistdocsSidebarSeparator,
45
- },
46
- }, tabMode: "auto", themeSwitch: {
47
- enabled: false,
48
- }, tree: tree, children: children }));
10
+ return (_jsx(GeistdocsSidebarProvider, { children: _jsx(FumadocsDocsLayout, { containerProps: {
11
+ ...containerProps,
12
+ style: {
13
+ ...(containerProps?.style ?? {}),
14
+ "--fd-docs-row-1": "4rem",
15
+ },
16
+ }, i18n: i18n, nav: {
17
+ enabled: false,
18
+ }, searchToggle: {
19
+ enabled: false,
20
+ }, sidebar: {
21
+ collapsible: false,
22
+ component: _jsx(GeistdocsSidebar, {}),
23
+ components: {
24
+ Folder: GeistdocsSidebarFolder,
25
+ Item: GeistdocsSidebarItem,
26
+ Separator: GeistdocsSidebarSeparator,
27
+ },
28
+ }, tabMode: "auto", themeSwitch: {
29
+ enabled: false,
30
+ }, tree: tree, children: children }) }));
49
31
  };
package/dist/mdx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,IAAI,oBAAoB,EAErC,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AACF,KAAK,kBAAkB,GAAG,OAAO,CAC/B,WAAW,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,EAC9C,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAC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A0B;;;;;;;;;;;;;;;;;;;iBA6BrC,CAAC;AAEH,eAAO,MAAM,yBAAyB,GACpC,aAAa,sBAAsB,KAClC,sBA8BD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,sBAAsB,KAClC,sBAA+D,CAAC;AAEnE,eAAO,MAAM,2BAA2B,GACtC,GAAG,eAAe,KAAK,CAAC,sBAAsB,GAAG,SAAS,CAAC,KAC1D,sBACkD,CAAC;AAEtD,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CAe1C,CAAC"}
package/dist/mdx.js CHANGED
@@ -9,6 +9,7 @@ import { z } from "zod";
9
9
  import { Callout, CalloutContainer, CalloutDescription, CalloutTitle, } from "./components/callout";
10
10
  import { CodeBlock } from "./components/code-block";
11
11
  import { CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, } from "./components/code-block-tabs";
12
+ import { CopyPrompt } from "./components/copy-prompt";
12
13
  import { Mermaid } from "./components/mermaid";
13
14
  import { Video } from "./components/video";
14
15
  export const geistdocsFrontmatterSchema = frontmatterSchema.extend({
@@ -50,6 +51,7 @@ export const getGeistdocsMDXComponents = (components) => ({
50
51
  CalloutContainer,
51
52
  CalloutTitle,
52
53
  CalloutDescription,
54
+ CopyPrompt,
53
55
  Mermaid,
54
56
  Video,
55
57
  ...components,
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/pages/docs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,IAAI,gBAAgB,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CA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/navigation";
5
5
  import { cn } from "../internal/cn";
6
6
  import { createPageActions as createInternalPageActions } from "../internal/page-actions";
7
7
  import { GeistdocsPageActions } from "../internal/page-actions-client";
8
- import { Separator } from "../internal/ui/separator";
8
+ import { GeistdocsTableOfContents } from "../internal/table-of-contents";
9
9
  import { createMdxComponents } from "../mdx";
10
10
  const DocsTitle = ({ className, ...props }) => (_jsx(FumadocsDocsTitle, { className: cn("mb-4 text-4xl tracking-tight", className), ...props }));
11
11
  const DocsDescription = (props) => _jsx(FumadocsDocsDescription, { ...props });
@@ -17,19 +17,25 @@ export const createDocsPage = ({ config, source, mdx, pageActions = createIntern
17
17
  if (!page) {
18
18
  notFound();
19
19
  }
20
- const markdown = await source.getPageMarkdown(page);
21
20
  const data = page.data;
22
21
  const MDX = data.body;
23
22
  const link = createRelativeLink(source.source, page);
24
23
  const resolvedMdx = typeof mdx === "function" ? mdx({ link }) : mdx;
25
- const footerActions = pageActions.getExtraActions?.({ page, markdown }) ?? [];
24
+ const markdown = pageActions.getExtraActions || renderTop
25
+ ? await source.getPageMarkdown(page)
26
+ : undefined;
27
+ const footerActions = markdown
28
+ ? (pageActions.getExtraActions?.({ page, markdown }) ?? [])
29
+ : [];
30
+ const tocFooter = (_jsx("div", { className: "mt-3 border-border border-t pt-3", children: _jsx("nav", { "aria-label": "Page actions", className: "flex min-w-0 flex-col gap-1", children: _jsx(GeistdocsPageActions, { config: pageActions.config, extraActions: footerActions, page: {
31
+ path: page.path,
32
+ url: page.url,
33
+ } }) }) }));
26
34
  return (_jsxs(FumadocsDocsPage, { full: data.full, tableOfContent: {
27
- style: "clerk",
28
- footer: (_jsxs("div", { className: "my-3 space-y-3", children: [_jsx(Separator, {}), _jsx(GeistdocsPageActions, { config: pageActions.config, extraActions: footerActions, markdown: markdown, page: {
29
- path: page.path,
30
- url: page.url,
31
- } })] })),
32
- }, tableOfContentPopover: tableOfContentPopover, toc: data.toc, children: [renderTop?.({ data, markdown, page }), _jsx(DocsTitle, { children: data.title }), _jsx(DocsDescription, { children: data.description }), _jsx(DocsBody, { children: _jsx(MDX, { components: {
35
+ enabled: true,
36
+ single: true,
37
+ component: (_jsx(GeistdocsTableOfContents, { footer: tocFooter, toc: data.toc ?? [] })),
38
+ }, tableOfContentPopover: tableOfContentPopover, toc: data.toc, children: [renderTop?.({ data, markdown: markdown ?? "", page }), _jsx(DocsTitle, { children: data.title }), _jsx(DocsDescription, { children: data.description }), _jsx(DocsBody, { children: _jsx(MDX, { components: {
33
39
  ...createMdxComponents({ a: link }),
34
40
  ...resolvedMdx,
35
41
  } }) })] }));
@@ -0,0 +1,11 @@
1
+ import { type Dispatch, type ReactNode, type SetStateAction } from "react";
2
+ interface GeistdocsSidebarContextValue {
3
+ isOpen: boolean;
4
+ setIsOpen: Dispatch<SetStateAction<boolean>>;
5
+ }
6
+ export declare const GeistdocsSidebarProvider: ({ children, }: {
7
+ children: ReactNode;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const useGeistdocsSidebar: () => GeistdocsSidebarContextValue;
10
+ export {};
11
+ //# sourceMappingURL=sidebar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../src/sidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,UAAU,4BAA4B;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CAC9C;AAKD,eAAO,MAAM,wBAAwB,GAAI,eAEtC;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,4CASA,CAAC;AAEF,eAAO,MAAM,mBAAmB,oCAU/B,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo, useState, } from "react";
4
+ const GeistdocsSidebarContext = createContext(null);
5
+ export const GeistdocsSidebarProvider = ({ children, }) => {
6
+ const [isOpen, setIsOpen] = useState(false);
7
+ const value = useMemo(() => ({ isOpen, setIsOpen }), [isOpen]);
8
+ return (_jsx(GeistdocsSidebarContext.Provider, { value: value, children: children }));
9
+ };
10
+ export const useGeistdocsSidebar = () => {
11
+ const context = useContext(GeistdocsSidebarContext);
12
+ if (!context) {
13
+ throw new Error("useGeistdocsSidebar must be used within GeistdocsDocsLayout.");
14
+ }
15
+ return context;
16
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vercel/geistdocs",
3
3
  "description": "Runtime and CLI for Geistdocs projects.",
4
- "version": "1.3.0-canary.41d37f1",
4
+ "version": "1.3.0-canary.5af98bc",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/vercel/geistdocs",
@@ -36,6 +36,10 @@
36
36
  "types": "./dist/source.d.ts",
37
37
  "default": "./dist/source.js"
38
38
  },
39
+ "./sidebar": {
40
+ "types": "./dist/sidebar.d.ts",
41
+ "default": "./dist/sidebar.js"
42
+ },
39
43
  "./pages/docs": {
40
44
  "types": "./dist/pages/docs.d.ts",
41
45
  "default": "./dist/pages/docs.js"
@@ -76,6 +80,10 @@
76
80
  "types": "./dist/components/code-block-tabs.d.ts",
77
81
  "default": "./dist/components/code-block-tabs.js"
78
82
  },
83
+ "./components/copy-prompt": {
84
+ "types": "./dist/components/copy-prompt.d.ts",
85
+ "default": "./dist/components/copy-prompt.js"
86
+ },
79
87
  "./components/theme-aware-image": {
80
88
  "types": "./dist/components/theme-aware-image.d.ts",
81
89
  "default": "./dist/components/theme-aware-image.js"