@vercel/geistdocs 2.3.0 → 2.3.2

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.
package/dist/cli/index.js CHANGED
@@ -4,4 +4,4 @@ import{program as A}from"commander";import{access as Xe,copyFile as Ke,readdir a
4
4
  `);throw new AggregateError(s,`Mixedbread search sync did not complete:
5
5
  ${a}`)}return r},Mt=async({client:e,file:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:s})=>{let i=t,o=Date.now()+r;for(;i.status==="pending"||i.status==="in_progress";){if(Date.now()>=o)throw new Error(`Mixedbread timed out while indexing file ${t.id}.`);await s(n),i=await e.retrieveStoreFile(t.id)}if(i.status!=="completed")throw new Error(`Mixedbread failed to index file ${t.id} (${i.status}).`);return i},Rt=async({client:e,desired:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:s})=>{let i=await e.uploadFile({content:t.document.content,filename:`${L(t.document.id).slice(0,32)}.md`}),o;try{o=await e.createStoreFile({externalId:t.externalId,fileId:i,metadata:{...t.metadata,[g.rawFileId]:i}})}catch(a){try{await e.deleteFile(i)}catch(d){throw new AggregateError([a,d],`Mixedbread failed to attach and clean up raw file ${i}.`)}throw a}return Mt({client:e,file:o,pollIntervalMs:n,pollTimeoutMs:r,sleep:s})},Te=async({client:e,concurrency:t=Et,manifest:n,pollIntervalMs:r=St,pollTimeoutMs:s=bt,revision:i,revisionAncestors:o=[],revisionTimestamp:a,sleep:d=At})=>{let c=be(n);if(c.provider!=="mixedbread")return{deleted:0,skipped:c.documents.length,uploaded:0};let u=c.siteId?.trim();if(!u)throw new Error("Mixedbread retrieval requires a non-empty siteId in geistdocs.tsx.");if(c.documents.length===0)throw new Error("The Geistdocs search export is empty. Refusing to remove indexed documents.");let l=c.documents.map(p=>Pt(p,u,i,o,a)),m=new Map(l.map(p=>[p.document.id,p])),h=(await xe(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),x=new Map,v=new Set;for(let p of h){W(p.metadata,i,a)&&v.add(p.metadata.documentId);let y=m.get(p.metadata.documentId);y&&p.metadata.contentHash===y.hash&&p.file.status==="completed"&&!x.has(p.metadata.documentId)&&x.set(p.metadata.documentId,p)}let _=l.filter(p=>!(x.has(p.document.id)||v.has(p.document.id)));await Ee(_,t,p=>Rt({client:e,desired:p,pollIntervalMs:r,pollTimeoutMs:s,sleep:d}));let E=(await xe(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),D=new Set(E.filter(({metadata:p})=>W(p,i,a)).map(({metadata:p})=>p.documentId)),ie=new Set;for(let p of l){if(D.has(p.document.id))continue;let ae=E.filter(({file:B,metadata:k})=>B.status==="completed"&&k.documentId===p.document.id&&k.contentHash===p.hash).sort((B,k)=>B.file.id.localeCompare(k.file.id))[0];ae&&ie.add(ae.file.id)}let oe=E.filter(({file:p,metadata:y})=>p.status!=="pending"&&p.status!=="in_progress"&&!W(y,i,a)&&vt({currentRevision:i,currentRevisionAncestors:o,currentRevisionTimestamp:a,desired:m.get(y.documentId),metadata:y})&&!ie.has(p.id));return await Ee(oe,t,async({file:p,metadata:y})=>{await e.deleteFile(y.rawFileId??p.id),await e.deleteStoreFile(p.id)}),{deleted:oe.length,skipped:l.length-_.length,uploaded:_.length}};var kt=50,Ct=e=>`vercel integration add mixedbread --name docs-${e||"your-site-id"} --environment production`,Ie=(e,t)=>Ft("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim(),Ot=e=>{let t=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),n=[];try{n=Ie(e,["rev-list",`--max-count=${kt+1}`,t||"HEAD"]).split(`
6
6
  `).filter(Boolean)}catch{n=[]}let r=t||n[0],s;for(let i of Array.from(new Set([r,"HEAD"].filter(Boolean))))try{let o=Number(Ie(e,["show","-s","--format=%ct",i]));if(Number.isFinite(o)){s=o;break}}catch{}return{revision:r,revisionAncestors:n.filter(i=>i!==r),revisionTimestamp:s}},Pe=async({allowNonProduction:e=!1,dir:t=".next"}={})=>{let n=process.cwd();Dt.loadEnvConfig(n,!1);let r=process.env.MXBAI_API_KEY?.trim(),s=process.env.MXBAI_STORE_ID?.trim();if(process.env.VERCEL_ENV!=="production"&&!e){console.log("Geistdocs search sync skipped: this is not a production Vercel build.");return}if(!!r!=!!s)throw new Error("Mixedbread is partially configured. Set both MXBAI_API_KEY and MXBAI_STORE_ID.");let i;try{i=await _e({cwd:n,outputDirectory:t})}catch(a){if(!(r||s)){console.log("Geistdocs search sync skipped: no Mixedbread credentials or static search export were found.");return}throw a}if(i.provider!=="mixedbread"){console.log("Geistdocs search sync skipped: Ask AI uses local retrieval.");return}if(!(r&&s))throw new Error(["Mixedbread retrieval is enabled, but MXBAI_API_KEY or MXBAI_STORE_ID is missing.","From the root of this site's repository, linked to the correct Vercel project, run:",Ct(i.siteId)].join(`
7
- `));let o=await Te({client:he({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:s}),manifest:i,...Ot(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as $t,writeFileSync as Nt}from"fs";import{mkdir as Ut,readFile as Z,writeFile as Lt}from"fs/promises";import{dirname as Gt,extname as jt,relative as Re,resolve as j}from"path";import{intro as Vt,isCancel as Bt,log as I,multiselect as Jt,outro as G,spinner as Ht}from"@clack/prompts";import{glob as Xt}from"glob";import{Node as F,Project as Kt,SyntaxKind as Yt}from"ts-morph";var qt="geistdocs.tsx",zt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,ve=()=>({version:1,entries:{}}),Wt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},Qt=e=>{let t=j(process.cwd(),e);return $t(t,"utf8")},Ae=e=>F.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(F.isPropertyAssignment(t)){let n=t.getNameNode();if(F.isIdentifier(n)||F.isStringLiteral(n))return[n.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Zt=e=>{try{let t=new Kt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=Qt(e),i=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!i)return[];if(F.isObjectLiteralExpression(i))return Ae(i);let o=i.getFirstDescendantByKind(Yt.ObjectLiteralExpression);return o?Ae(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},en=async()=>{let e=await Jt({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 Bt(e)&&(G("Translation cancelled"),process.exit(0)),e},tn=async e=>(await Xt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),nn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?ve():{version:1,entries:n.entries}}catch{return ve()}},Me=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Nt(t,n,"utf8")},rn=async e=>{let t=await Promise.all(e.map(async n=>[n,await Wt(n)]));return Object.fromEntries(t)},sn=(e,t)=>{let n=jt(e);return`${e.slice(0,-n.length)}.${t}${n}`},Fe=(e,t)=>`${Re(process.cwd(),e)}::${t}`,on=(e,t,n,r,s=!1)=>{let i=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=sn(a,c),l=Fe(a,c),m=r.entries[l];if(!s&&m?.hash===d){o+=1;continue}i.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:i,skippedCount:o}},an=async e=>{await Ut(Gt(e),{recursive:!0})},cn=async(e,t,n)=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:n})});if(!r.ok){let i=await r.text();throw new Error(`API request failed (${r.status}): ${i}`)}let s=await r.json();if(!s.translation)throw new Error("API response did not include a translation");return s.translation},dn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),s=await cn(t,r,e.locale);await an(e.targetFile),await Lt(e.targetFile,s,"utf8"),n.entries[Fe(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},De=async(e,t)=>{Vt("Translate MDX content");let n=e??zt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",s=Zt(t.config??qt),i=await tn(n);i.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),G("Translation cancelled"),process.exit(1)),I.info(`Found ${i.length} MDX file(s) matching pattern`),s.length===0&&(s=await en());let o=j(process.cwd(),ee),a=await nn();await Me(a),I.info(`Using cache: ${o}`);let d=await rn(i),{tasks:c,skippedCount:u}=on(s,i,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),G(`Skipped ${u} file(s) (unchanged)`);return}let l=[];for(let h=0;h<c.length;h+=Q)l.push(c.slice(h,h+Q));I.info(`Processing ${c.length} translation(s) in ${l.length} batch(es) of up to ${Q}`),u>0&&I.info(`Skipped ${u} translation(s) (unchanged)`);let m=Ht();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await dn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Re(process.cwd(),x.targetFile)}`)})),await Me(a);m.stop("Translation complete!"),G(`Created/updated ${c.length} file(s)`)};import{access as ln,copyFile as pn,mkdir as $e,rm as re}from"fs/promises";import{dirname as un,join as P}from"path";import{intro as gn,log as w,outro as V,spinner as Ne}from"@clack/prompts";import{glob as mn}from"glob";var fn=["**/*"],hn=["content/docs/**"],te=".geistdocs-tmp",wn=async(e,t)=>{let n=P(e,t);await re(n,{recursive:!0,force:!0}),await $e(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),ke=async(e,t,n)=>(await mn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),yn=async e=>{try{return await ln(e),!0}catch{return!1}},xn=async(e,t,n)=>{let r=P(t,e),s=P(n,e);return await yn(r)?(await pn(r,s),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},En=async(e,t)=>{let n=P(t,e);return await re(n,{force:!0}),{success:!0}},Ce=20,Oe=async(e,t,n)=>{let r=[];for(let s=0;s<e.length;s+=n){let i=e.slice(s,s+n),o=await Promise.all(i.map(t));r.push(...o)}return r},Sn=async(e,t,n,r,s)=>{let i={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>un(P(r,d))))];s.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>$e(d,{recursive:!0}))),s.message(`Updating ${e.length} files...`);let a=await Oe(e,async d=>{let c=await xn(d,n,r);return{file:d,...c}},Ce);for(let{file:d,success:c,error:u}of a)c?i.success.push(d):i.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){s.message(`Deleting ${t.length} files...`);let d=await Oe(t,async c=>{try{return await En(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Ce);for(let c of d)c.success?i.deleted.push(c.file):i.failed.push({file:c.file,error:c.error})}return i},bn=e=>{if(e.success.length>0){w.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)w.info(` \u2713 ${t}`)}if(e.deleted.length>0){w.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)w.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){w.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:n}of e.failed)w.error(` \u2717 ${t}: ${n}`)}},_n=e=>e.includes("canary")?"canary":"latest",Tn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(b)}`);if(!t.ok)throw new Error(`Failed to resolve ${b}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${b}`);return r},In=async e=>{let t=await M(e),n=J(t,b);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=_n(n),s=await Tn(r);return n===s?{currentVersion:n,nextVersion:s,updateTag:r,updated:!1}:($(t,b,s),await O(e,t),{currentVersion:n,nextVersion:s,updateTag:r,updated:!0})},Pn=async(e,t,n)=>{let r=await M(e);if(!le(r,b))return!1;t&&t.length>0&&w.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),n?.sync&&w.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:s,nextVersion:i,updateTag:o,updated:a}=await In(e);if(!a)return w.success(s?`@vercel/geistdocs is already at ${i} (${o}).`:"No package version update was needed."),V("Package-based site is already up to date."),!0;w.info(`Bumping ${b} from ${s} to ${i} (${o})`);let d=Ne();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),V("Please review and test the upgraded package version."),!0},vn=async(e,t,n,r,s)=>{let i=P(e,te),o=Ne(),a=s?.sync?i:t;o.start("Preparing template snapshot..."),s?.sync&&(await wn(e,te),await N(i)),o.message("Scanning for files...");let d=await ke(n,r,a),c=[];if(s?.sync){o.message("Comparing with local files...");let l=await ke(n,r,e),m=new Set(d);c=l.filter(f=>!m.has(f))}if(o.stop(`Found ${d.length} files to update`),d.length===0&&c.length===0){w.warn("No files matched the patterns. Nothing to update."),s?.sync&&await ne(i),V("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),s?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await Sn(d,c,a,e,o);s?.sync&&(o.message("Cleaning up..."),await ne(i)),o.stop("Update complete!"),bn(u),V("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),s=e&&e.length>0?e:fn,i=e&&e.length>0?[]:hn;try{if(gn("Let's update your Geistdocs project!"),await Pn(n,e,t))return;w.info("Template source: bundled package snapshot"),e&&e.length>0&&w.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&w.info("Sync mode enabled: will delete files removed from template"),await vn(n,r,s,i,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(P(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.3.0","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(fe);A.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(Ue);A.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(De);var An=A.command("search").description("Manage the external search index used by Ask AI");An.command("sync").description("Sync the latest static docs export to Mixedbread").option("--dir <path>","Next.js output directory",".next").option("--allow-non-production","Run outside a production Vercel build").action(Pe);await A.parseAsync(process.argv).catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
7
+ `));let o=await Te({client:he({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:s}),manifest:i,...Ot(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as $t,writeFileSync as Nt}from"fs";import{mkdir as Ut,readFile as Z,writeFile as Lt}from"fs/promises";import{dirname as Gt,extname as jt,relative as Re,resolve as j}from"path";import{intro as Vt,isCancel as Bt,log as I,multiselect as Jt,outro as G,spinner as Ht}from"@clack/prompts";import{glob as Xt}from"glob";import{Node as F,Project as Kt,SyntaxKind as Yt}from"ts-morph";var qt="geistdocs.tsx",zt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,ve=()=>({version:1,entries:{}}),Wt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},Qt=e=>{let t=j(process.cwd(),e);return $t(t,"utf8")},Ae=e=>F.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(F.isPropertyAssignment(t)){let n=t.getNameNode();if(F.isIdentifier(n)||F.isStringLiteral(n))return[n.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Zt=e=>{try{let t=new Kt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=Qt(e),i=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!i)return[];if(F.isObjectLiteralExpression(i))return Ae(i);let o=i.getFirstDescendantByKind(Yt.ObjectLiteralExpression);return o?Ae(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},en=async()=>{let e=await Jt({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 Bt(e)&&(G("Translation cancelled"),process.exit(0)),e},tn=async e=>(await Xt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),nn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?ve():{version:1,entries:n.entries}}catch{return ve()}},Me=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Nt(t,n,"utf8")},rn=async e=>{let t=await Promise.all(e.map(async n=>[n,await Wt(n)]));return Object.fromEntries(t)},sn=(e,t)=>{let n=jt(e);return`${e.slice(0,-n.length)}.${t}${n}`},Fe=(e,t)=>`${Re(process.cwd(),e)}::${t}`,on=(e,t,n,r,s=!1)=>{let i=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=sn(a,c),l=Fe(a,c),m=r.entries[l];if(!s&&m?.hash===d){o+=1;continue}i.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:i,skippedCount:o}},an=async e=>{await Ut(Gt(e),{recursive:!0})},cn=async(e,t,n)=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:n})});if(!r.ok){let i=await r.text();throw new Error(`API request failed (${r.status}): ${i}`)}let s=await r.json();if(!s.translation)throw new Error("API response did not include a translation");return s.translation},dn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),s=await cn(t,r,e.locale);await an(e.targetFile),await Lt(e.targetFile,s,"utf8"),n.entries[Fe(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},De=async(e,t)=>{Vt("Translate MDX content");let n=e??zt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",s=Zt(t.config??qt),i=await tn(n);i.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),G("Translation cancelled"),process.exit(1)),I.info(`Found ${i.length} MDX file(s) matching pattern`),s.length===0&&(s=await en());let o=j(process.cwd(),ee),a=await nn();await Me(a),I.info(`Using cache: ${o}`);let d=await rn(i),{tasks:c,skippedCount:u}=on(s,i,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),G(`Skipped ${u} file(s) (unchanged)`);return}let l=[];for(let h=0;h<c.length;h+=Q)l.push(c.slice(h,h+Q));I.info(`Processing ${c.length} translation(s) in ${l.length} batch(es) of up to ${Q}`),u>0&&I.info(`Skipped ${u} translation(s) (unchanged)`);let m=Ht();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await dn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Re(process.cwd(),x.targetFile)}`)})),await Me(a);m.stop("Translation complete!"),G(`Created/updated ${c.length} file(s)`)};import{access as ln,copyFile as pn,mkdir as $e,rm as re}from"fs/promises";import{dirname as un,join as P}from"path";import{intro as gn,log as w,outro as V,spinner as Ne}from"@clack/prompts";import{glob as mn}from"glob";var fn=["**/*"],hn=["content/docs/**"],te=".geistdocs-tmp",wn=async(e,t)=>{let n=P(e,t);await re(n,{recursive:!0,force:!0}),await $e(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),ke=async(e,t,n)=>(await mn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),yn=async e=>{try{return await ln(e),!0}catch{return!1}},xn=async(e,t,n)=>{let r=P(t,e),s=P(n,e);return await yn(r)?(await pn(r,s),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},En=async(e,t)=>{let n=P(t,e);return await re(n,{force:!0}),{success:!0}},Ce=20,Oe=async(e,t,n)=>{let r=[];for(let s=0;s<e.length;s+=n){let i=e.slice(s,s+n),o=await Promise.all(i.map(t));r.push(...o)}return r},Sn=async(e,t,n,r,s)=>{let i={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>un(P(r,d))))];s.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>$e(d,{recursive:!0}))),s.message(`Updating ${e.length} files...`);let a=await Oe(e,async d=>{let c=await xn(d,n,r);return{file:d,...c}},Ce);for(let{file:d,success:c,error:u}of a)c?i.success.push(d):i.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){s.message(`Deleting ${t.length} files...`);let d=await Oe(t,async c=>{try{return await En(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Ce);for(let c of d)c.success?i.deleted.push(c.file):i.failed.push({file:c.file,error:c.error})}return i},bn=e=>{if(e.success.length>0){w.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)w.info(` \u2713 ${t}`)}if(e.deleted.length>0){w.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)w.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){w.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:n}of e.failed)w.error(` \u2717 ${t}: ${n}`)}},_n=e=>e.includes("canary")?"canary":"latest",Tn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(b)}`);if(!t.ok)throw new Error(`Failed to resolve ${b}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${b}`);return r},In=async e=>{let t=await M(e),n=J(t,b);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=_n(n),s=await Tn(r);return n===s?{currentVersion:n,nextVersion:s,updateTag:r,updated:!1}:($(t,b,s),await O(e,t),{currentVersion:n,nextVersion:s,updateTag:r,updated:!0})},Pn=async(e,t,n)=>{let r=await M(e);if(!le(r,b))return!1;t&&t.length>0&&w.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),n?.sync&&w.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:s,nextVersion:i,updateTag:o,updated:a}=await In(e);if(!a)return w.success(s?`@vercel/geistdocs is already at ${i} (${o}).`:"No package version update was needed."),V("Package-based site is already up to date."),!0;w.info(`Bumping ${b} from ${s} to ${i} (${o})`);let d=Ne();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),V("Please review and test the upgraded package version."),!0},vn=async(e,t,n,r,s)=>{let i=P(e,te),o=Ne(),a=s?.sync?i:t;o.start("Preparing template snapshot..."),s?.sync&&(await wn(e,te),await N(i)),o.message("Scanning for files...");let d=await ke(n,r,a),c=[];if(s?.sync){o.message("Comparing with local files...");let l=await ke(n,r,e),m=new Set(d);c=l.filter(f=>!m.has(f))}if(o.stop(`Found ${d.length} files to update`),d.length===0&&c.length===0){w.warn("No files matched the patterns. Nothing to update."),s?.sync&&await ne(i),V("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),s?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await Sn(d,c,a,e,o);s?.sync&&(o.message("Cleaning up..."),await ne(i)),o.stop("Update complete!"),bn(u),V("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),s=e&&e.length>0?e:fn,i=e&&e.length>0?[]:hn;try{if(gn("Let's update your Geistdocs project!"),await Pn(n,e,t))return;w.info("Template source: bundled package snapshot"),e&&e.length>0&&w.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&w.info("Sync mode enabled: will delete files removed from template"),await vn(n,r,s,i,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(P(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.3.2","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(fe);A.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(Ue);A.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(De);var An=A.command("search").description("Manage the external search index used by Ask AI");An.command("sync").description("Sync the latest static docs export to Mixedbread").option("--dir <path>","Next.js output directory",".next").option("--allow-non-production","Run outside a production Vercel build").action(Pe);await A.parseAsync(process.argv).catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
@@ -0,0 +1,13 @@
1
+ import { Tabs as TabsPrimitive } from "radix-ui";
2
+ import { type ComponentProps } from "react";
3
+ interface TabsWithChildrenProps extends Omit<ComponentProps<typeof TabsPrimitive.Root>, "asChild" | "orientation"> {
4
+ ariaLabel?: string;
5
+ tabs: string[];
6
+ }
7
+ export declare function TabsWithChildren({ ariaLabel, children, className, defaultValue, tabs, ...props }: TabsWithChildrenProps): import("react/jsx-runtime").JSX.Element;
8
+ interface TabContentProps extends Omit<ComponentProps<typeof TabsPrimitive.Content>, "asChild" | "forceMount" | "value"> {
9
+ order: number;
10
+ }
11
+ export declare function TabContent({ className, order, ...props }: TabContentProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=tabs-with-children.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs-with-children.d.ts","sourceRoot":"","sources":["../../src/components/tabs-with-children.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AAOtD,UAAU,qBACR,SAAQ,IAAI,CACV,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,EACzC,SAAS,GAAG,aAAa,CAC1B;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,SAAkB,EAClB,QAAQ,EACR,SAAS,EACT,YAAqB,EACrB,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,qBAAqB,2CAqDvB;AAED,UAAU,eACR,SAAQ,IAAI,CACV,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,EAC5C,SAAS,GAAG,YAAY,GAAG,OAAO,CACnC;IACD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,UAAU,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,2CAYzE"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Tabs as TabsPrimitive } from "radix-ui";
4
+ import { useState } from "react";
5
+ import { contentTabsFocusClassName, tabsBorderClassName, } from "#geistdocs-ui/components/tabs-styles";
6
+ import { cn } from "#geistdocs-ui/utils";
7
+ export function TabsWithChildren({ ariaLabel = "Tabs", children, className, defaultValue = "tab1", tabs, ...props }) {
8
+ const [showFocusRing, setShowFocusRing] = useState(true);
9
+ return (_jsxs(TabsPrimitive.Root, { ...props, className: cn("my-6 min-w-0", className), defaultValue: defaultValue, orientation: "horizontal", children: [_jsx(TabsPrimitive.List, { "aria-label": ariaLabel, className: cn("not-prose no-scrollbar flex flex-nowrap items-center gap-6 overflow-x-auto pb-px has-[:focus-visible]:overflow-visible", tabsBorderClassName), onBlur: (event) => {
10
+ if (!event.currentTarget.contains(event.relatedTarget)) {
11
+ setShowFocusRing(true);
12
+ }
13
+ }, onKeyDownCapture: (event) => {
14
+ if (event.defaultPrevented ||
15
+ event.altKey ||
16
+ event.ctrlKey ||
17
+ event.metaKey ||
18
+ event.shiftKey) {
19
+ return;
20
+ }
21
+ if (["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
22
+ setShowFocusRing(false);
23
+ }
24
+ }, children: tabs.map((title, index) => (_jsx(TabsPrimitive.Trigger, { className: cn("-mb-px flex shrink-0 cursor-pointer items-center whitespace-nowrap border-0 border-transparent border-b-2 bg-transparent px-0.5 py-3.5 text-gray-900 text-label-14 outline-0 hover:text-gray-1000 data-[state=active]:border-gray-1000 data-[state=active]:text-gray-1000", contentTabsFocusClassName), "data-show-focus-ring": showFocusRing, value: `tab${index + 1}`, children: title }, title))) }), children] }));
25
+ }
26
+ export function TabContent({ className, order, ...props }) {
27
+ return (_jsx(TabsPrimitive.Content, { ...props, className: cn("min-w-0 outline-0 focus-visible:shadow-[var(--ds-focus-ring)] data-[state=inactive]:hidden", className), forceMount: true, value: `tab${order}` }));
28
+ }
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,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AA0B/C,OAAO,EAGL,KAAK,4BAA4B,IAAI,mBAAmB,EAGzD,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,2BAA2B,8EAAe,CAAC;AACxD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAoB,CAAC;AAC5D,eAAO,MAAM,mBAAmB;;;;;;;gCAAa,CAAC;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAAa,CAAC;AAC1C,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,eAAO,MAAM,yBAAyB,GACpC,aAAa,sBAAsB,KAClC,sBAsDD,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"}
1
+ {"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AA4B/C,OAAO,EAGL,KAAK,4BAA4B,IAAI,mBAAmB,EAGzD,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,2BAA2B,8EAAe,CAAC;AACxD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAoB,CAAC;AAC5D,eAAO,MAAM,mBAAmB;;;;;;;gCAAa,CAAC;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAAa,CAAC;AAC1C,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,eAAO,MAAM,yBAAyB,GACpC,aAAa,sBAAsB,KAClC,sBAyDD,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"}
package/dist/mdx.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { TypeTable } from "fumadocs-ui/components/type-table";
3
3
  import defaultMdxComponents from "fumadocs-ui/mdx";
4
+ import { Tabs } from "#geistdocs-ui/components/tabs";
4
5
  import { cn } from "#geistdocs-ui/utils";
5
6
  import { Blockquote } from "./components/blockquote";
6
7
  import { Callout, CalloutContainer, CalloutDescription, CalloutTitle, } from "./components/callout";
@@ -13,6 +14,7 @@ import { Image } from "./components/image";
13
14
  import { Mermaid } from "./components/mermaid";
14
15
  import { Step, Steps } from "./components/steps";
15
16
  import { Table } from "./components/table";
17
+ import { TabContent, TabsWithChildren } from "./components/tabs-with-children";
16
18
  import { Video } from "./components/video";
17
19
  import { LocalizedLink } from "./internal/localized-link";
18
20
  import { geistdocsFrontmatterSchema as frontmatterSchema, geistdocsMetaSchema as metaSchema, geistShikiTheme as shikiTheme, defineGeistdocsSourceConfig as sourceConfig, } from "./source-config";
@@ -49,6 +51,9 @@ export const getGeistdocsMDXComponents = (components) => ({
49
51
  Mermaid,
50
52
  Steps,
51
53
  Step,
54
+ Tabs,
55
+ TabsWithChildren,
56
+ TabContent,
52
57
  Video,
53
58
  ...components,
54
59
  });
@@ -0,0 +1,3 @@
1
+ export declare const tabsBorderClassName = "shadow-[0_-1px_0_var(--ds-gray-400)_inset]";
2
+ export declare const contentTabsFocusClassName = "focus-visible:data-[show-focus-ring=true]:shadow-[var(--ds-focus-ring)]";
3
+ //# sourceMappingURL=tabs-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs-styles.d.ts","sourceRoot":"","sources":["../../../../src/providers/public/components/tabs-styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,+CAA+C,CAAC;AAEhF,eAAO,MAAM,yBAAyB,4EACqC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const tabsBorderClassName = "shadow-[0_-1px_0_var(--ds-gray-400)_inset]";
2
+ export const contentTabsFocusClassName = "focus-visible:data-[show-focus-ring=true]:shadow-[var(--ds-focus-ring)]";
@@ -0,0 +1,23 @@
1
+ import { type CSSProperties, type HTMLProps, type JSX, type ReactNode } from "react";
2
+ interface Tab<T> {
3
+ disabled?: boolean;
4
+ icon?: ReactNode;
5
+ id?: string;
6
+ panelId?: string;
7
+ title: ReactNode;
8
+ tooltip?: ReactNode;
9
+ value: T;
10
+ }
11
+ interface TabsProps<T> extends Omit<HTMLProps<HTMLDivElement>, "selected"> {
12
+ border?: boolean;
13
+ disabled?: boolean;
14
+ selected?: T | null;
15
+ setSelected?: (value: T) => void;
16
+ style?: CSSProperties;
17
+ tabClassName?: string;
18
+ tabs: Tab<T>[];
19
+ variant?: "primary" | "secondary";
20
+ }
21
+ export declare function Tabs<T extends string | number>({ border, className, disabled, selected: controlledSelected, setSelected: controlledSetSelected, style, tabClassName, tabs, variant, ...props }: TabsProps<T>): JSX.Element;
22
+ export {};
23
+ //# sourceMappingURL=tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../../src/providers/public/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,GAAG,EAER,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAKf,UAAU,GAAG,CAAC,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,CAAC,CAAC;CACV;AAED,UAAU,SAAS,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;CACnC;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,EAC9C,MAAa,EACb,SAAS,EACT,QAAQ,EACR,QAAQ,EAAE,kBAAkB,EAC5B,WAAW,EAAE,qBAAqB,EAClC,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,OAAmB,EACnB,GAAG,KAAK,EACT,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CA2E5B"}
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useRef, useState, } from "react";
4
+ import { cn } from "../utils";
5
+ import { tabsBorderClassName } from "./tabs-styles";
6
+ import { Tooltip } from "./tooltip";
7
+ export function Tabs({ border = true, className, disabled, selected: controlledSelected, setSelected: controlledSetSelected, style, tabClassName, tabs, variant = "primary", ...props }) {
8
+ const [showFocusRing, setShowFocusRing] = useState(true);
9
+ const ref = useRef(null);
10
+ const [internalSelected, setInternalSelected] = useState(tabs[0]?.value);
11
+ const isControlled = controlledSelected !== undefined;
12
+ const selected = isControlled ? controlledSelected : internalSelected;
13
+ const selectTab = (tab) => {
14
+ if (!isControlled) {
15
+ setInternalSelected(tab.value);
16
+ }
17
+ controlledSetSelected?.(tab.value);
18
+ };
19
+ const handleKeyDown = (event) => {
20
+ if (disabled) {
21
+ return;
22
+ }
23
+ const activeIndex = tabs.findIndex((tab) => tab.value === selected);
24
+ let targetIndex = -1;
25
+ if (event.key === "ArrowLeft") {
26
+ targetIndex = activeIndex - 1;
27
+ }
28
+ else if (event.key === "ArrowRight") {
29
+ targetIndex = activeIndex + 1;
30
+ }
31
+ const targetTab = tabs[targetIndex];
32
+ if (targetIndex < 0 || targetIndex >= tabs.length || targetTab?.disabled) {
33
+ return;
34
+ }
35
+ event.preventDefault();
36
+ ref.current
37
+ ?.querySelector(`[data-index="${targetIndex}"]`)
38
+ ?.focus({ preventScroll: true });
39
+ setShowFocusRing(false);
40
+ };
41
+ return (_jsx("div", { "aria-orientation": "horizontal", className: cn("group no-scrollbar flex flex-nowrap items-center overflow-x-auto pb-px has-[:focus-visible]:overflow-visible", variant === "primary" && ["gap-6", tabsBorderClassName], variant === "secondary" && "mb-3 shadow-none", !border && "shadow-none", className), "data-geist-tabs": "", "data-variant": variant, "data-version": "v1", ref: ref, role: "tablist", style: style, ...props, children: tabs.map((tab, index) => (_jsx(TabButton, { disabled: tab.disabled || disabled, index: index, isActive: tab.value === selected, onKeyDown: handleKeyDown, onSelect: () => selectTab(tab), setShowFocusRing: setShowFocusRing, showFocusRing: showFocusRing, tab: tab, tabClassName: tabClassName }, tab.value))) }));
42
+ }
43
+ function TabButton({ disabled, index, isActive, onKeyDown, onSelect, setShowFocusRing, showFocusRing, tab, tabClassName, }) {
44
+ const generatedId = useId();
45
+ const button = (_jsxs("button", { "aria-controls": tab.panelId, "aria-selected": isActive, className: cn("-mb-px flex cursor-pointer items-center border-0 border-transparent border-b-2 bg-transparent px-0.5 py-3.5 text-gray-900 text-label-14 outline-0 not-disabled:hover:text-gray-1000 disabled:cursor-not-allowed aria-selected:text-gray-1000 focus-visible:data-[show-focus-ring=true]:shadow-[var(--ds-focus-ring)]", "group-data-[variant=primary]:aria-selected:border-gray-1000 group-data-[variant=primary]:aria-selected:border-b-2", "group-data-[variant=secondary]:h-8 group-data-[variant=secondary]:rounded-md group-data-[variant=secondary]:border-b-0 group-data-[variant=secondary]:px-3 group-data-[variant=secondary]:py-0 group-data-[variant=secondary]:text-label-13", "group-data-[variant=secondary]:aria-selected:bg-gray-200 group-data-[variant=secondary]:aria-selected:text-gray-1000", "group-data-[variant=secondary]:disabled:cursor-not-allowed group-data-[variant=secondary]:disabled:bg-gray-200 group-data-[variant=secondary]:disabled:text-gray-900", tabClassName), "data-index": index, "data-show-focus-ring": showFocusRing, disabled: disabled, id: tab.id ?? generatedId, onBlur: () => setShowFocusRing(true), onFocus: onSelect, onKeyDown: onKeyDown, role: "tab", tabIndex: isActive ? 0 : -1, type: "button", children: [tab.icon ? _jsx("span", { className: "mr-1.5", children: tab.icon }) : null, tab.title] }));
46
+ return tab.tooltip ? (_jsx(Tooltip, { position: "bottom", text: tab.tooltip, children: button })) : (button);
47
+ }
@@ -2,8 +2,8 @@ import { remarkHeading, remarkMdxMermaid, remarkSteps, remarkStructure, } from "
2
2
  import { defineConfig as defineFumadocsConfig, frontmatterSchema, metaSchema, } from "fumadocs-mdx/config";
3
3
  import lastModified from "fumadocs-mdx/plugins/last-modified";
4
4
  import { z } from "zod";
5
+ import { remarkDetails } from "../remark-details.js";
5
6
  import { getLastModified } from "./internal/last-modified.js";
6
- import { remarkDetails } from "./internal/remark-details.js";
7
7
  const pluginOf = (entry) => Array.isArray(entry) ? entry[0] : entry;
8
8
  const indexOfPlugin = (list, plugin) => list.findIndex((entry) => pluginOf(entry) === plugin);
9
9
  /**
package/docs/agents.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Geistdocs Package Docs
2
2
 
3
- These docs are bundled with `@vercel/geistdocs` 2.3.0 so agents can understand the installed package without web access.
3
+ These docs are bundled with `@vercel/geistdocs` 2.3.2 so agents can understand the installed package without web access.
4
4
  They are generated from `apps/template/content/docs` during the package build.
5
5
 
6
6
  ## How to use these files
@@ -29,7 +29,7 @@ They are generated from `apps/template/content/docs` during the package build.
29
29
  - [Migrate to Geistdocs](pages/migration.md): Move an existing documentation site to @vercel/geistdocs while keeping local content, routing, middleware behavior, and AI-readable surfaces intact.
30
30
  - [Choose a Geistdocs package](pages/packages.md): Use the public package by default and the private package only where restricted Vercel npm dependencies are already available.
31
31
  - [Configuration](pages/configuration.md): Configure site metadata, navigation, AI features, page actions, translations, and local adapters.
32
- - [Syntax](pages/syntax.md): Supported MDX syntax including text formatting, code blocks, line highlighting, and Mermaid diagrams.
32
+ - [Syntax](pages/syntax.md): Supported MDX components and syntax including tabs, text formatting, code blocks, line highlighting, and Mermaid diagrams.
33
33
  - [Geistdocs Provider](pages/provider.md): The root provider component that wraps your application to handle toast notifications, search, and analytics.
34
34
  - [Versioned docs](pages/versioned-docs.md): Use createVersionedSources to configure stable, pre-release, or host-based documentation versions.
35
35
  - [Proxy and markdown routes](pages/proxy.md): Configure createProxy with generated route discovery, request hooks, markdown mappings, and a static Next.js matcher.
package/docs/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Geistdocs Package Documentation
2
2
 
3
- These docs are bundled with `@vercel/geistdocs` 2.3.0.
3
+ These docs are bundled with `@vercel/geistdocs` 2.3.2.
4
4
  They describe how to build package-backed Geistdocs sites and how to use the package APIs from generated project adapters.
5
5
 
6
6
  ## Documentation Index
@@ -12,7 +12,7 @@ They describe how to build package-backed Geistdocs sites and how to use the pac
12
12
  - [Migrate to Geistdocs](pages/migration.md): Move an existing documentation site to @vercel/geistdocs while keeping local content, routing, middleware behavior, and AI-readable surfaces intact.
13
13
  - [Choose a Geistdocs package](pages/packages.md): Use the public package by default and the private package only where restricted Vercel npm dependencies are already available.
14
14
  - [Configuration](pages/configuration.md): Configure site metadata, navigation, AI features, page actions, translations, and local adapters.
15
- - [Syntax](pages/syntax.md): Supported MDX syntax including text formatting, code blocks, line highlighting, and Mermaid diagrams.
15
+ - [Syntax](pages/syntax.md): Supported MDX components and syntax including tabs, text formatting, code blocks, line highlighting, and Mermaid diagrams.
16
16
  - [Geistdocs Provider](pages/provider.md): The root provider component that wraps your application to handle toast notifications, search, and analytics.
17
17
  - [Versioned docs](pages/versioned-docs.md): Use createVersionedSources to configure stable, pre-release, or host-based documentation versions.
18
18
  - [Proxy and markdown routes](pages/proxy.md): Configure createProxy with generated route discovery, request hooks, markdown mappings, and a static Next.js matcher.
@@ -1511,7 +1511,7 @@ If a release adds an optional prop or config field, opt into it by editing the r
1511
1511
  title: Syntax
1512
1512
  description: Learn about the supported markdown syntax and formatting options
1513
1513
  type: reference
1514
- summary: Supported MDX syntax including text formatting, code blocks, line highlighting, and Mermaid diagrams.
1514
+ summary: Supported MDX components and syntax including tabs, text formatting, code blocks, line highlighting, and Mermaid diagrams.
1515
1515
  url: /docs/syntax
1516
1516
  source: apps/template/content/docs/syntax.mdx
1517
1517
  prerequisites:
@@ -1795,8 +1795,9 @@ This renders as:
1795
1795
  alt="Navigation Inspector showing a loading shell for a page load"
1796
1796
  caption="The Navigation Inspector paused on a page load."
1797
1797
  height={389}
1798
- srcDark="https://h8DxKfmAPhn8O0p3.public.blob.vercel-storage.com/docs/dark/inspector-load.png"
1799
- srcLight="https://h8DxKfmAPhn8O0p3.public.blob.vercel-storage.com/docs/light/inspector-load.png"
1798
+ srcDark="https://h8dxkfmaphn8o0p3.public.blob.vercel-storage.com/docs/dark/inspector-load.png"
1799
+ srcLight="https://h8dxkfmaphn8o0p3.public.blob.vercel-storage.com/docs/light/inspector-load.png"
1800
+ unoptimized
1800
1801
  width={472}
1801
1802
  />
1802
1803
 
@@ -1813,6 +1814,43 @@ For theme-aware images, provide both sources:
1813
1814
  />
1814
1815
  ```
1815
1816
 
1817
+ ### Tabs
1818
+
1819
+ Use `TabsWithChildren` and `TabContent` to switch between related instructions,
1820
+ code examples, or other MDX components. Both are available without imports.
1821
+ The `tabs` array defines the labels, and each panel's `order` starts at `1`.
1822
+
1823
+ ```mdx
1824
+ <TabsWithChildren tabs={["Dashboard", "CLI"]} ariaLabel="Setup method">
1825
+ <TabContent order={1}>
1826
+ Open your project's settings in the dashboard.
1827
+ </TabContent>
1828
+ <TabContent order={2}>
1829
+ Connect your local project using the CLI.
1830
+ </TabContent>
1831
+ </TabsWithChildren>
1832
+ ```
1833
+
1834
+ This renders as:
1835
+
1836
+ <TabsWithChildren tabs={["Dashboard", "CLI"]} ariaLabel="Setup method">
1837
+ <TabContent order={1}>
1838
+ Open your project's settings in the dashboard.
1839
+ </TabContent>
1840
+ <TabContent order={2}>
1841
+ Connect your local project using the CLI.
1842
+ </TabContent>
1843
+ </TabsWithChildren>
1844
+
1845
+ Use the arrow keys, Home, or End to select a tab. Each tab is linked to its panel
1846
+ for assistive technology. Inactive panels stay mounted and hidden, preserving
1847
+ local state when you return to a tab. Nested tab groups manage their selection
1848
+ independently.
1849
+
1850
+ In React, use `defaultValue="tab2"` to start on the second tab, or pass `value`
1851
+ and `onValueChange` to control selection. Values follow the panel order
1852
+ (`tab1`, `tab2`, and so on).
1853
+
1816
1854
  ## GitHub Flavored Markdown
1817
1855
 
1818
1856
  Geistdocs supports GFM extensions including tables, task lists, and autolinks.
@@ -1921,8 +1959,8 @@ export const Button = ({ children }) => {
1921
1959
 
1922
1960
  ### Tabs and switchers
1923
1961
 
1924
- Use consecutive fences with `tab` metadata for code tabs that expose every
1925
- option at once:
1962
+ Code blocks support tabs and compact switchers for selecting between code examples.
1963
+ Use consecutive fences with `tab` metadata to show all code tab labels at once:
1926
1964
 
1927
1965
  ````md
1928
1966
  ```ts tab="TypeScript" title="example.ts"
@@ -75,7 +75,7 @@
75
75
  "description": "Learn about the supported markdown syntax and formatting options",
76
76
  "path": "pages/syntax.md",
77
77
  "source": "apps/template/content/docs/syntax.mdx",
78
- "summary": "Supported MDX syntax including text formatting, code blocks, line highlighting, and Mermaid diagrams.",
78
+ "summary": "Supported MDX components and syntax including tabs, text formatting, code blocks, line highlighting, and Mermaid diagrams.",
79
79
  "title": "Syntax",
80
80
  "type": "reference",
81
81
  "url": "/docs/syntax"
@@ -242,5 +242,5 @@
242
242
  }
243
243
  ],
244
244
  "source": "apps/template/content/docs",
245
- "version": "2.3.0"
245
+ "version": "2.3.2"
246
246
  }
@@ -2,7 +2,7 @@
2
2
  title: Syntax
3
3
  description: Learn about the supported markdown syntax and formatting options
4
4
  type: reference
5
- summary: Supported MDX syntax including text formatting, code blocks, line highlighting, and Mermaid diagrams.
5
+ summary: Supported MDX components and syntax including tabs, text formatting, code blocks, line highlighting, and Mermaid diagrams.
6
6
  url: /docs/syntax
7
7
  source: apps/template/content/docs/syntax.mdx
8
8
  prerequisites:
@@ -286,8 +286,9 @@ This renders as:
286
286
  alt="Navigation Inspector showing a loading shell for a page load"
287
287
  caption="The Navigation Inspector paused on a page load."
288
288
  height={389}
289
- srcDark="https://h8DxKfmAPhn8O0p3.public.blob.vercel-storage.com/docs/dark/inspector-load.png"
290
- srcLight="https://h8DxKfmAPhn8O0p3.public.blob.vercel-storage.com/docs/light/inspector-load.png"
289
+ srcDark="https://h8dxkfmaphn8o0p3.public.blob.vercel-storage.com/docs/dark/inspector-load.png"
290
+ srcLight="https://h8dxkfmaphn8o0p3.public.blob.vercel-storage.com/docs/light/inspector-load.png"
291
+ unoptimized
291
292
  width={472}
292
293
  />
293
294
 
@@ -304,6 +305,43 @@ For theme-aware images, provide both sources:
304
305
  />
305
306
  ```
306
307
 
308
+ ### Tabs
309
+
310
+ Use `TabsWithChildren` and `TabContent` to switch between related instructions,
311
+ code examples, or other MDX components. Both are available without imports.
312
+ The `tabs` array defines the labels, and each panel's `order` starts at `1`.
313
+
314
+ ```mdx
315
+ <TabsWithChildren tabs={["Dashboard", "CLI"]} ariaLabel="Setup method">
316
+ <TabContent order={1}>
317
+ Open your project's settings in the dashboard.
318
+ </TabContent>
319
+ <TabContent order={2}>
320
+ Connect your local project using the CLI.
321
+ </TabContent>
322
+ </TabsWithChildren>
323
+ ```
324
+
325
+ This renders as:
326
+
327
+ <TabsWithChildren tabs={["Dashboard", "CLI"]} ariaLabel="Setup method">
328
+ <TabContent order={1}>
329
+ Open your project's settings in the dashboard.
330
+ </TabContent>
331
+ <TabContent order={2}>
332
+ Connect your local project using the CLI.
333
+ </TabContent>
334
+ </TabsWithChildren>
335
+
336
+ Use the arrow keys, Home, or End to select a tab. Each tab is linked to its panel
337
+ for assistive technology. Inactive panels stay mounted and hidden, preserving
338
+ local state when you return to a tab. Nested tab groups manage their selection
339
+ independently.
340
+
341
+ In React, use `defaultValue="tab2"` to start on the second tab, or pass `value`
342
+ and `onValueChange` to control selection. Values follow the panel order
343
+ (`tab1`, `tab2`, and so on).
344
+
307
345
  ## GitHub Flavored Markdown
308
346
 
309
347
  Geistdocs supports GFM extensions including tables, task lists, and autolinks.
@@ -412,8 +450,8 @@ export const Button = ({ children }) => {
412
450
 
413
451
  ### Tabs and switchers
414
452
 
415
- Use consecutive fences with `tab` metadata for code tabs that expose every
416
- option at once:
453
+ Code blocks support tabs and compact switchers for selecting between code examples.
454
+ Use consecutive fences with `tab` metadata to show all code tab labels at once:
417
455
 
418
456
  ````md
419
457
  ```ts tab="TypeScript" title="example.ts"
package/docs/sitemap.md CHANGED
@@ -10,7 +10,7 @@ Use it to choose focused page files from `docs/pages/` before reading the full `
10
10
  - [Migrate to Geistdocs](pages/migration.md) | URL: /docs/migration | Type: guide | Summary: Move an existing documentation site to @vercel/geistdocs while keeping local content, routing, middleware behavior, and AI-readable surfaces intact.
11
11
  - [Choose a Geistdocs package](pages/packages.md) | URL: /docs/packages | Type: guide | Summary: Use the public package by default and the private package only where restricted Vercel npm dependencies are already available.
12
12
  - [Configuration](pages/configuration.md) | URL: /docs/configuration | Type: reference | Summary: Configure site metadata, navigation, AI features, page actions, translations, and local adapters.
13
- - [Syntax](pages/syntax.md) | URL: /docs/syntax | Type: reference | Summary: Supported MDX syntax including text formatting, code blocks, line highlighting, and Mermaid diagrams.
13
+ - [Syntax](pages/syntax.md) | URL: /docs/syntax | Type: reference | Summary: Supported MDX components and syntax including tabs, text formatting, code blocks, line highlighting, and Mermaid diagrams.
14
14
  - [Geistdocs Provider](pages/provider.md) | URL: /docs/provider | Type: reference | Summary: The root provider component that wraps your application to handle toast notifications, search, and analytics.
15
15
  - [Versioned docs](pages/versioned-docs.md) | URL: /docs/versioned-docs | Type: guide | Summary: Use createVersionedSources to configure stable, pre-release, or host-based documentation versions.
16
16
  - [Proxy and markdown routes](pages/proxy.md) | URL: /docs/proxy | Type: reference | Summary: Configure createProxy with generated route discovery, request hooks, markdown mappings, and a static Next.js matcher.
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": "2.3.0",
4
+ "version": "2.3.2",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,6 +24,8 @@
24
24
  "cli.js",
25
25
  "dist",
26
26
  "docs",
27
+ "remark-details.d.ts",
28
+ "remark-details.js",
27
29
  "source-config.js",
28
30
  "template",
29
31
  "public-foundation.css",
@@ -178,10 +180,18 @@
178
180
  "types": "./dist/providers/public/components/theme-switcher.d.ts",
179
181
  "default": "./dist/providers/public/components/theme-switcher.js"
180
182
  },
183
+ "./components/tabs": {
184
+ "types": "./dist/providers/public/components/tabs.d.ts",
185
+ "default": "./dist/providers/public/components/tabs.js"
186
+ },
181
187
  "./components/code-block": {
182
188
  "types": "./dist/components/code-block.d.ts",
183
189
  "default": "./dist/components/code-block.js"
184
190
  },
191
+ "./components/tabs-with-children": {
192
+ "types": "./dist/components/tabs-with-children.d.ts",
193
+ "default": "./dist/components/tabs-with-children.js"
194
+ },
185
195
  "./components/code-block-tabs": {
186
196
  "types": "./dist/components/code-block-tabs.d.ts",
187
197
  "default": "./dist/components/code-block-tabs.js"
@@ -1,3 +1,3 @@
1
1
  import type { Root } from "mdast";
2
+
2
3
  export declare const remarkDetails: () => (tree: Root) => void;
3
- //# sourceMappingURL=remark-details.d.ts.map
@@ -0,0 +1,16 @@
1
+ const visit = (node) => {
2
+ if (
3
+ (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") &&
4
+ (node.name === "details" || node.name === "summary")
5
+ ) {
6
+ node.name = node.name === "details" ? "Details" : "Summary";
7
+ }
8
+
9
+ for (const child of node.children ?? []) {
10
+ visit(child);
11
+ }
12
+ };
13
+
14
+ export const remarkDetails = () => (tree) => {
15
+ visit(tree);
16
+ };
package/source-config.js CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  } from "fumadocs-mdx/config";
16
16
  import lastModified from "fumadocs-mdx/plugins/last-modified";
17
17
  import { z } from "zod";
18
+ import { remarkDetails } from "./remark-details.js";
18
19
 
19
20
  // Mirrors src/internal/last-modified.ts. This file must stay dependency-free
20
21
  // on dist so source.config.ts can load it before the package is built.
@@ -264,7 +265,8 @@ export const resolveGeistdocsRemarkPlugins = (
264
265
  structureIndex === -1 ? list.length : structureIndex,
265
266
  0,
266
267
  remarkMdxMermaid,
267
- ...consumerPlugins
268
+ ...consumerPlugins,
269
+ remarkDetails
268
270
  );
269
271
 
270
272
  return list;
@@ -2,7 +2,7 @@
2
2
  title: Syntax
3
3
  description: Learn about the supported markdown syntax and formatting options
4
4
  type: reference
5
- summary: Supported MDX syntax including text formatting, code blocks, line highlighting, and Mermaid diagrams.
5
+ summary: Supported MDX components and syntax including tabs, text formatting, code blocks, line highlighting, and Mermaid diagrams.
6
6
  prerequisites:
7
7
  - /docs/getting-started
8
8
  related:
@@ -290,8 +290,9 @@ This renders as:
290
290
  alt="Navigation Inspector showing a loading shell for a page load"
291
291
  caption="The Navigation Inspector paused on a page load."
292
292
  height={389}
293
- srcDark="https://h8DxKfmAPhn8O0p3.public.blob.vercel-storage.com/docs/dark/inspector-load.png"
294
- srcLight="https://h8DxKfmAPhn8O0p3.public.blob.vercel-storage.com/docs/light/inspector-load.png"
293
+ srcDark="https://h8dxkfmaphn8o0p3.public.blob.vercel-storage.com/docs/dark/inspector-load.png"
294
+ srcLight="https://h8dxkfmaphn8o0p3.public.blob.vercel-storage.com/docs/light/inspector-load.png"
295
+ unoptimized
295
296
  width={472}
296
297
  />
297
298
 
@@ -308,6 +309,43 @@ For theme-aware images, provide both sources:
308
309
  />
309
310
  ```
310
311
 
312
+ ### Tabs
313
+
314
+ Use `TabsWithChildren` and `TabContent` to switch between related instructions,
315
+ code examples, or other MDX components. Both are available without imports.
316
+ The `tabs` array defines the labels, and each panel's `order` starts at `1`.
317
+
318
+ ```mdx
319
+ <TabsWithChildren tabs={["Dashboard", "CLI"]} ariaLabel="Setup method">
320
+ <TabContent order={1}>
321
+ Open your project's settings in the dashboard.
322
+ </TabContent>
323
+ <TabContent order={2}>
324
+ Connect your local project using the CLI.
325
+ </TabContent>
326
+ </TabsWithChildren>
327
+ ```
328
+
329
+ This renders as:
330
+
331
+ <TabsWithChildren tabs={["Dashboard", "CLI"]} ariaLabel="Setup method">
332
+ <TabContent order={1}>
333
+ Open your project's settings in the dashboard.
334
+ </TabContent>
335
+ <TabContent order={2}>
336
+ Connect your local project using the CLI.
337
+ </TabContent>
338
+ </TabsWithChildren>
339
+
340
+ Use the arrow keys, Home, or End to select a tab. Each tab is linked to its panel
341
+ for assistive technology. Inactive panels stay mounted and hidden, preserving
342
+ local state when you return to a tab. Nested tab groups manage their selection
343
+ independently.
344
+
345
+ In React, use `defaultValue="tab2"` to start on the second tab, or pass `value`
346
+ and `onValueChange` to control selection. Values follow the panel order
347
+ (`tab1`, `tab2`, and so on).
348
+
311
349
  ## GitHub Flavored Markdown
312
350
 
313
351
  Geistdocs supports GFM extensions including tables, task lists, and autolinks.
@@ -416,8 +454,8 @@ export const Button = ({ children }) => {
416
454
 
417
455
  ### Tabs and switchers
418
456
 
419
- Use consecutive fences with `tab` metadata for code tabs that expose every
420
- option at once:
457
+ Code blocks support tabs and compact switchers for selecting between code examples.
458
+ Use consecutive fences with `tab` metadata to show all code tab labels at once:
421
459
 
422
460
  ````md
423
461
  ```ts tab="TypeScript" title="example.ts"
@@ -17,7 +17,7 @@
17
17
  "@streamdown/code": "^1.0.1",
18
18
  "@vercel/agent-readability": "^0.7.0",
19
19
  "@vercel/analytics": "^1.6.1",
20
- "@vercel/geistdocs": "2.3.0",
20
+ "@vercel/geistdocs": "2.3.2",
21
21
  "@vercel/speed-insights": "^1.3.1",
22
22
  "ai": "^6.0.132",
23
23
  "clsx": "^2.1.1",
@@ -1 +0,0 @@
1
- {"version":3,"file":"remark-details.d.ts","sourceRoot":"","sources":["../../src/internal/remark-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAQlC,eAAO,MAAM,aAAa,SAAU,MAAM,IAAI,SAW7C,CAAC"}
@@ -1,11 +0,0 @@
1
- import { visit } from "unist-util-visit";
2
- export const remarkDetails = () => (tree) => {
3
- visit(tree, (node) => {
4
- const element = node;
5
- if ((element.type === "mdxJsxFlowElement" ||
6
- element.type === "mdxJsxTextElement") &&
7
- (element.name === "details" || element.name === "summary")) {
8
- element.name = element.name === "details" ? "Details" : "Summary";
9
- }
10
- });
11
- };