@vercel/geistdocs 2.15.4 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.d.ts +3 -3
- package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.js +3 -3
- package/dist/internal/navbar/navbar-logo.d.ts +5 -3
- package/dist/internal/navbar/navbar-logo.d.ts.map +1 -1
- package/dist/internal/navbar/navbar-logo.js +71 -14
- package/dist/navbar.js +4 -3
- package/docs/agents.md +1 -1
- package/docs/llms.txt +14 -2
- package/docs/manifest.json +1 -1
- package/docs/pages/configuration.md +13 -1
- package/package.json +10 -3
- package/rehype-code-highlights.d.ts +13 -0
- package/rehype-code-highlights.js +278 -0
- package/source-config-public.d.ts +15 -0
- package/source-config-public.js +47 -0
- package/template/content/docs/configuration.mdx +13 -1
- package/template/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4,4 +4,4 @@ import{Option as Rn,program as A}from"commander";import{access as Ke,copyFile as
|
|
|
4
4
|
`);throw new AggregateError(i,`Mixedbread search sync did not complete:
|
|
5
5
|
${a}`)}return r},Ft=async({client:e,file:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:i})=>{let s=t,o=Date.now()+r;for(;s.status==="pending"||s.status==="in_progress";){if(Date.now()>=o)throw new Error(`Mixedbread timed out while indexing file ${t.id}.`);await i(n),s=await e.retrieveStoreFile(t.id)}if(s.status!=="completed")throw new Error(`Mixedbread failed to index file ${t.id} (${s.status}).`);return s},Dt=async({client:e,desired:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:i})=>{let s=await e.uploadFile({content:t.document.content,filename:`${U(t.document.id).slice(0,32)}.md`}),o;try{o=await e.createStoreFile({externalId:t.externalId,fileId:s,metadata:{...t.metadata,[g.rawFileId]:s}})}catch(a){try{await e.deleteFile(s)}catch(d){throw new AggregateError([a,d],`Mixedbread failed to attach and clean up raw file ${s}.`)}throw a}return Ft({client:e,file:o,pollIntervalMs:n,pollTimeoutMs:r,sleep:i})},Ie=async({client:e,concurrency:t=St,manifest:n,pollIntervalMs:r=_t,pollTimeoutMs:i=Tt,revision:s,revisionAncestors:o=[],revisionTimestamp:a,sleep:d=Rt})=>{let c=_e(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=>At(p,u,s,o,a)),m=new Map(l.map(p=>[p.document.id,p])),h=(await be(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),x=new Map,P=new Set;for(let p of h){W(p.metadata,s,a)&&P.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)||P.has(p.document.id)));await Ee(_,t,p=>Dt({client:e,desired:p,pollIntervalMs:r,pollTimeoutMs:i,sleep:d}));let b=(await be(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),D=new Set(b.filter(({metadata:p})=>W(p,s,a)).map(({metadata:p})=>p.documentId)),ie=new Set;for(let p of l){if(D.has(p.document.id))continue;let ae=b.filter(({file:V,metadata:k})=>V.status==="completed"&&k.documentId===p.document.id&&k.contentHash===p.hash).sort((V,k)=>V.file.id.localeCompare(k.file.id))[0];ae&&ie.add(ae.file.id)}let oe=b.filter(({file:p,metadata:y})=>p.status!=="pending"&&p.status!=="in_progress"&&!W(y,s,a)&&Mt({currentRevision:s,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 Ot=50,$t=e=>`vercel integration add mixedbread --name docs-${e||"your-site-id"} --environment production`,ve=(e,t)=>kt("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim(),Nt=e=>{let t=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),n=[];try{n=ve(e,["rev-list",`--max-count=${Ot+1}`,t||"HEAD"]).split(`
|
|
6
6
|
`).filter(Boolean)}catch{n=[]}let r=t||n[0],i;for(let s of Array.from(new Set([r,"HEAD"].filter(Boolean))))try{let o=Number(ve(e,["show","-s","--format=%ct",s]));if(Number.isFinite(o)){i=o;break}}catch{}return{revision:r,revisionAncestors:n.filter(s=>s!==r),revisionTimestamp:i}},Pe=async({allowNonProduction:e=!1,dir:t=".next"}={})=>{let n=process.cwd();Ct.loadEnvConfig(n,!1);let r=process.env.MXBAI_API_KEY?.trim(),i=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!=!!i)throw new Error("Mixedbread is partially configured. Set both MXBAI_API_KEY and MXBAI_STORE_ID.");let s;try{s=await Te({cwd:n,outputDirectory:t})}catch(a){if(!(r||i)){console.log("Geistdocs search sync skipped: no Mixedbread credentials or static search export were found.");return}throw a}if(s.provider!=="mixedbread"){console.log("Geistdocs search sync skipped: Ask AI uses local retrieval.");return}if(!(r&&i))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:",$t(s.siteId)].join(`
|
|
7
|
-
`));let o=await Ie({client:we({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:i}),manifest:s,...Nt(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as Gt,writeFileSync as Ut}from"fs";import{mkdir as Lt,readFile as Z,writeFile as jt}from"fs/promises";import{dirname as Bt,extname as Vt,relative as Fe,resolve as j}from"path";import{intro as Jt,isCancel as Ht,log as I,multiselect as Xt,outro as L,spinner as Kt}from"@clack/prompts";import{glob as Yt}from"glob";import{Node as F,Project as qt,SyntaxKind as zt}from"ts-morph";var Wt="geistdocs.tsx",Qt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,Ae=()=>({version:1,entries:{}}),Zt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},en=e=>{let t=j(process.cwd(),e);return Gt(t,"utf8")},Me=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):[],tn=e=>{try{let t=new qt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=en(e),s=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!s)return[];if(F.isObjectLiteralExpression(s))return Me(s);let o=s.getFirstDescendantByKind(zt.ObjectLiteralExpression);return o?Me(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},nn=async()=>{let e=await Xt({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 Ht(e)&&(L("Translation cancelled"),process.exit(0)),e},rn=async e=>(await Yt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),sn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?Ae():{version:1,entries:n.entries}}catch{return Ae()}},Re=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Ut(t,n,"utf8")},on=async e=>{let t=await Promise.all(e.map(async n=>[n,await Zt(n)]));return Object.fromEntries(t)},an=(e,t)=>{let n=Vt(e);return`${e.slice(0,-n.length)}.${t}${n}`},De=(e,t)=>`${Fe(process.cwd(),e)}::${t}`,cn=(e,t,n,r,i=!1)=>{let s=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=an(a,c),l=De(a,c),m=r.entries[l];if(!i&&m?.hash===d){o+=1;continue}s.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:s,skippedCount:o}},dn=async e=>{await Lt(Bt(e),{recursive:!0})},ln=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 s=await r.text();throw new Error(`API request failed (${r.status}): ${s}`)}let i=await r.json();if(!i.translation)throw new Error("API response did not include a translation");return i.translation},pn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),i=await ln(t,r,e.locale);await dn(e.targetFile),await jt(e.targetFile,i,"utf8"),n.entries[De(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},ke=async(e,t)=>{Jt("Translate MDX content");let n=e??Qt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",i=tn(t.config??Wt),s=await rn(n);s.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),L("Translation cancelled"),process.exit(1)),I.info(`Found ${s.length} MDX file(s) matching pattern`),i.length===0&&(i=await nn());let o=j(process.cwd(),ee),a=await sn();await Re(a),I.info(`Using cache: ${o}`);let d=await on(s),{tasks:c,skippedCount:u}=cn(i,s,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),L(`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=Kt();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await pn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Fe(process.cwd(),x.targetFile)}`)})),await Re(a);m.stop("Translation complete!"),L(`Created/updated ${c.length} file(s)`)};import{access as un,copyFile as gn,mkdir as Ne,rm as re}from"fs/promises";import{dirname as mn,join as v}from"path";import{intro as fn,log as w,outro as B,spinner as Ge}from"@clack/prompts";import{glob as hn}from"glob";var wn=["**/*"],yn=["content/docs/**"],te=".geistdocs-tmp",xn=async(e,t)=>{let n=v(e,t);await re(n,{recursive:!0,force:!0}),await Ne(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),Ce=async(e,t,n)=>(await hn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),bn=async e=>{try{return await un(e),!0}catch{return!1}},En=async(e,t,n)=>{let r=v(t,e),i=v(n,e);return await bn(r)?(await gn(r,i),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},Sn=async(e,t)=>{let n=v(t,e);return await re(n,{force:!0}),{success:!0}},Oe=20,$e=async(e,t,n)=>{let r=[];for(let i=0;i<e.length;i+=n){let s=e.slice(i,i+n),o=await Promise.all(s.map(t));r.push(...o)}return r},_n=async(e,t,n,r,i)=>{let s={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>mn(v(r,d))))];i.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>Ne(d,{recursive:!0}))),i.message(`Updating ${e.length} files...`);let a=await $e(e,async d=>{let c=await En(d,n,r);return{file:d,...c}},Oe);for(let{file:d,success:c,error:u}of a)c?s.success.push(d):s.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){i.message(`Deleting ${t.length} files...`);let d=await $e(t,async c=>{try{return await Sn(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Oe);for(let c of d)c.success?s.deleted.push(c.file):s.failed.push({file:c.file,error:c.error})}return s},Tn=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}`)}},In=e=>e.includes("canary")?"canary":"latest",vn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(S)}`);if(!t.ok)throw new Error(`Failed to resolve ${S}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${S}`);return r},Pn=async e=>{let t=await M(e),n=J(t,S);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=In(n),i=await vn(r);return n===i?{currentVersion:n,nextVersion:i,updateTag:r,updated:!1}:($(t,S,i),await O(e,t),{currentVersion:n,nextVersion:i,updateTag:r,updated:!0})},An=async(e,t,n)=>{let r=await M(e);if(!le(r,S))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:i,nextVersion:s,updateTag:o,updated:a}=await Pn(e);if(!a)return w.success(i?`@vercel/geistdocs is already at ${s} (${o}).`:"No package version update was needed."),B("Package-based site is already up to date."),!0;w.info(`Bumping ${S} from ${i} to ${s} (${o})`);let d=Ge();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),B("Please review and test the upgraded package version."),!0},Mn=async(e,t,n,r,i)=>{let s=v(e,te),o=Ge(),a=i?.sync?s:t;o.start("Preparing template snapshot..."),i?.sync&&(await xn(e,te),await N(s)),o.message("Scanning for files...");let d=await Ce(n,r,a),c=[];if(i?.sync){o.message("Comparing with local files...");let l=await Ce(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."),i?.sync&&await ne(s),B("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),i?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await _n(d,c,a,e,o);i?.sync&&(o.message("Cleaning up..."),await ne(s)),o.stop("Update complete!"),Tn(u),B("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),i=e&&e.length>0?e:wn,s=e&&e.length>0?[]:yn;try{if(fn("Let's update your Geistdocs project!"),await An(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 Mn(n,r,i,s,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(v(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.15.4","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").addOption(new Rn("--brand <brand>","Navbar brand").choices(["vercel","labs"]).default("vercel")).option("--disable-git","Disable git initialization").action(he);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(ke);var Fn=A.command("search").description("Manage the external search index used by Ask AI");Fn.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 Ie({client:we({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:i}),manifest:s,...Nt(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as Gt,writeFileSync as Ut}from"fs";import{mkdir as Lt,readFile as Z,writeFile as jt}from"fs/promises";import{dirname as Bt,extname as Vt,relative as Fe,resolve as j}from"path";import{intro as Jt,isCancel as Ht,log as I,multiselect as Xt,outro as L,spinner as Kt}from"@clack/prompts";import{glob as Yt}from"glob";import{Node as F,Project as qt,SyntaxKind as zt}from"ts-morph";var Wt="geistdocs.tsx",Qt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,Ae=()=>({version:1,entries:{}}),Zt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},en=e=>{let t=j(process.cwd(),e);return Gt(t,"utf8")},Me=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):[],tn=e=>{try{let t=new qt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=en(e),s=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!s)return[];if(F.isObjectLiteralExpression(s))return Me(s);let o=s.getFirstDescendantByKind(zt.ObjectLiteralExpression);return o?Me(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},nn=async()=>{let e=await Xt({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 Ht(e)&&(L("Translation cancelled"),process.exit(0)),e},rn=async e=>(await Yt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),sn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?Ae():{version:1,entries:n.entries}}catch{return Ae()}},Re=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Ut(t,n,"utf8")},on=async e=>{let t=await Promise.all(e.map(async n=>[n,await Zt(n)]));return Object.fromEntries(t)},an=(e,t)=>{let n=Vt(e);return`${e.slice(0,-n.length)}.${t}${n}`},De=(e,t)=>`${Fe(process.cwd(),e)}::${t}`,cn=(e,t,n,r,i=!1)=>{let s=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=an(a,c),l=De(a,c),m=r.entries[l];if(!i&&m?.hash===d){o+=1;continue}s.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:s,skippedCount:o}},dn=async e=>{await Lt(Bt(e),{recursive:!0})},ln=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 s=await r.text();throw new Error(`API request failed (${r.status}): ${s}`)}let i=await r.json();if(!i.translation)throw new Error("API response did not include a translation");return i.translation},pn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),i=await ln(t,r,e.locale);await dn(e.targetFile),await jt(e.targetFile,i,"utf8"),n.entries[De(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},ke=async(e,t)=>{Jt("Translate MDX content");let n=e??Qt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",i=tn(t.config??Wt),s=await rn(n);s.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),L("Translation cancelled"),process.exit(1)),I.info(`Found ${s.length} MDX file(s) matching pattern`),i.length===0&&(i=await nn());let o=j(process.cwd(),ee),a=await sn();await Re(a),I.info(`Using cache: ${o}`);let d=await on(s),{tasks:c,skippedCount:u}=cn(i,s,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),L(`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=Kt();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await pn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Fe(process.cwd(),x.targetFile)}`)})),await Re(a);m.stop("Translation complete!"),L(`Created/updated ${c.length} file(s)`)};import{access as un,copyFile as gn,mkdir as Ne,rm as re}from"fs/promises";import{dirname as mn,join as v}from"path";import{intro as fn,log as w,outro as B,spinner as Ge}from"@clack/prompts";import{glob as hn}from"glob";var wn=["**/*"],yn=["content/docs/**"],te=".geistdocs-tmp",xn=async(e,t)=>{let n=v(e,t);await re(n,{recursive:!0,force:!0}),await Ne(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),Ce=async(e,t,n)=>(await hn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),bn=async e=>{try{return await un(e),!0}catch{return!1}},En=async(e,t,n)=>{let r=v(t,e),i=v(n,e);return await bn(r)?(await gn(r,i),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},Sn=async(e,t)=>{let n=v(t,e);return await re(n,{force:!0}),{success:!0}},Oe=20,$e=async(e,t,n)=>{let r=[];for(let i=0;i<e.length;i+=n){let s=e.slice(i,i+n),o=await Promise.all(s.map(t));r.push(...o)}return r},_n=async(e,t,n,r,i)=>{let s={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>mn(v(r,d))))];i.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>Ne(d,{recursive:!0}))),i.message(`Updating ${e.length} files...`);let a=await $e(e,async d=>{let c=await En(d,n,r);return{file:d,...c}},Oe);for(let{file:d,success:c,error:u}of a)c?s.success.push(d):s.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){i.message(`Deleting ${t.length} files...`);let d=await $e(t,async c=>{try{return await Sn(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Oe);for(let c of d)c.success?s.deleted.push(c.file):s.failed.push({file:c.file,error:c.error})}return s},Tn=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}`)}},In=e=>e.includes("canary")?"canary":"latest",vn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(S)}`);if(!t.ok)throw new Error(`Failed to resolve ${S}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${S}`);return r},Pn=async e=>{let t=await M(e),n=J(t,S);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=In(n),i=await vn(r);return n===i?{currentVersion:n,nextVersion:i,updateTag:r,updated:!1}:($(t,S,i),await O(e,t),{currentVersion:n,nextVersion:i,updateTag:r,updated:!0})},An=async(e,t,n)=>{let r=await M(e);if(!le(r,S))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:i,nextVersion:s,updateTag:o,updated:a}=await Pn(e);if(!a)return w.success(i?`@vercel/geistdocs is already at ${s} (${o}).`:"No package version update was needed."),B("Package-based site is already up to date."),!0;w.info(`Bumping ${S} from ${i} to ${s} (${o})`);let d=Ge();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),B("Please review and test the upgraded package version."),!0},Mn=async(e,t,n,r,i)=>{let s=v(e,te),o=Ge(),a=i?.sync?s:t;o.start("Preparing template snapshot..."),i?.sync&&(await xn(e,te),await N(s)),o.message("Scanning for files...");let d=await Ce(n,r,a),c=[];if(i?.sync){o.message("Comparing with local files...");let l=await Ce(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."),i?.sync&&await ne(s),B("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),i?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await _n(d,c,a,e,o);i?.sync&&(o.message("Cleaning up..."),await ne(s)),o.stop("Update complete!"),Tn(u),B("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),i=e&&e.length>0?e:wn,s=e&&e.length>0?[]:yn;try{if(fn("Let's update your Geistdocs project!"),await An(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 Mn(n,r,i,s,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(v(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.16.0","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").addOption(new Rn("--brand <brand>","Navbar brand").choices(["vercel","labs"]).default("vercel")).option("--disable-git","Disable git initialization").action(he);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(ke);var Fn=A.command("search").description("Manage the external search index used by Ask AI");Fn.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});
|
package/dist/config.d.ts
CHANGED
|
@@ -289,10 +289,10 @@ export interface GeistdocsConfig {
|
|
|
289
289
|
navbarGithub?: GeistdocsFeatureConfig;
|
|
290
290
|
navbarOssProducts?: GeistdocsNavbarOssProduct[];
|
|
291
291
|
/**
|
|
292
|
-
* Navbar layout. `"
|
|
293
|
-
* for `"vercel"`.
|
|
292
|
+
* Navbar layout. `"vercel-labs"` selects the Labs product menu and mark;
|
|
293
|
+
* `"standard"` remains accepted as a compatibility alias for `"vercel"`.
|
|
294
294
|
*/
|
|
295
|
-
navbarVariant?: "oss" | "vercel" | "standard";
|
|
295
|
+
navbarVariant?: "oss" | "vercel" | "vercel-labs" | "standard";
|
|
296
296
|
pageActions?: GeistdocsPageActionsConfig;
|
|
297
297
|
prompt?: string;
|
|
298
298
|
search?: GeistdocsFeatureConfig;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,GAAG,SAAS,WAO7D,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS,WAoBvE,CAAC;AAEF,qFAAqF;AAC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YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,eAAe,EAAE,QAAQ,CAAC,KAAG,CAAW,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { GeistdocsNavbarOssProduct, GeistdocsNavItem } from "../../config";
|
|
1
|
+
import type { GeistdocsConfig, GeistdocsNavbarOssProduct, GeistdocsNavItem } from "../../config";
|
|
2
2
|
interface MobileMenuProps {
|
|
3
3
|
activeProduct?: string;
|
|
4
4
|
githubUrl?: string | null;
|
|
5
5
|
nav: GeistdocsNavItem[];
|
|
6
|
+
navbarVariant?: GeistdocsConfig["navbarVariant"];
|
|
6
7
|
ossProducts?: GeistdocsNavbarOssProduct[];
|
|
7
|
-
|
|
8
|
-
showOss?: boolean;
|
|
8
|
+
showProductMenu?: boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare const MobileMenu: (props: MobileMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,yBAAyB,EAEzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAQtB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,
|
|
1
|
+
{"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EAEzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAQtB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;IACjD,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA4bD,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAEhD,CAAC"}
|
|
@@ -54,7 +54,7 @@ function OssCollapsible({ sections, onLinkClick, }) {
|
|
|
54
54
|
function MobileMenuButton({ controls, expanded, onClick, ref, }) {
|
|
55
55
|
return (_jsx("button", { "aria-controls": controls, "aria-expanded": expanded, "aria-label": expanded ? "Close menu" : "Open menu", className: "relative flex @min-[1024px]:hidden size-8 items-center justify-center rounded-full border border-gray-200 transition-colors hover:bg-gray-100", "data-slot": "mobile-menu-toggle", onClick: onClick, ref: ref, type: "button", children: _jsxs("span", { className: "flex flex-col items-center justify-center gap-[5px]", children: [_jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-transform duration-150", expanded && "translate-y-[3.25px] rotate-45") }), _jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-transform duration-150", expanded && "-translate-y-[3.25px] -rotate-45") })] }) }));
|
|
56
56
|
}
|
|
57
|
-
const MobileMenuState = ({ activeProduct, githubUrl, nav, ossProducts,
|
|
57
|
+
const MobileMenuState = ({ activeProduct, githubUrl, nav, navbarVariant, ossProducts, showProductMenu = false, }) => {
|
|
58
58
|
const isDesktop = useMediaQuery("(min-width: 1024px)");
|
|
59
59
|
const [show, setShow] = useState(false);
|
|
60
60
|
const isActive = useNavActive(nav);
|
|
@@ -63,8 +63,8 @@ const MobileMenuState = ({ activeProduct, githubUrl, nav, ossProducts, showOss =
|
|
|
63
63
|
const panelRef = useRef(null);
|
|
64
64
|
// Resolve the default/custom list and drop the active product here on the
|
|
65
65
|
// client, where `DEFAULT_OSS_PRODUCTS` is a real array (see resolveOssProducts).
|
|
66
|
-
const products =
|
|
67
|
-
? resolveOssProducts(ossProducts, activeProduct)
|
|
66
|
+
const products = showProductMenu
|
|
67
|
+
? resolveOssProducts(ossProducts, activeProduct, navbarVariant)
|
|
68
68
|
: [];
|
|
69
69
|
// Featured products (eve) go under "Latest"; the rest group by `section`,
|
|
70
70
|
// preserving first-seen order (Frameworks / SDKs / Other).
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import type { GeistdocsNavbarOssProduct } from "../../config";
|
|
2
|
+
import type { GeistdocsConfig, GeistdocsNavbarOssProduct } from "../../config";
|
|
3
3
|
export declare const DEFAULT_OSS_SECTION = "Open Source";
|
|
4
4
|
export declare const DEFAULT_OSS_PRODUCTS: GeistdocsNavbarOssProduct[];
|
|
5
|
+
/** Default flyout for `navbarVariant: "vercel-labs"`, mirroring vercel.com/labs. */
|
|
6
|
+
export declare const DEFAULT_LABS_PRODUCTS: GeistdocsNavbarOssProduct[];
|
|
5
7
|
/**
|
|
6
8
|
* Full-bleed panel below the header used by navbar dropdowns. Hidden when
|
|
7
9
|
* closed, and force-mounted in the server HTML so links stay crawlable (see
|
|
@@ -23,7 +25,7 @@ export declare function PanelLink({ active, product, }: {
|
|
|
23
25
|
* and is a client-only value — resolving it on the server yields a client
|
|
24
26
|
* reference, not the array.
|
|
25
27
|
*/
|
|
26
|
-
export declare function resolveOssProducts(products: GeistdocsNavbarOssProduct[] | undefined, activeProduct: string | undefined): GeistdocsNavbarOssProduct[];
|
|
28
|
+
export declare function resolveOssProducts(products: GeistdocsNavbarOssProduct[] | undefined, activeProduct: string | undefined, variant?: GeistdocsConfig["navbarVariant"]): GeistdocsNavbarOssProduct[];
|
|
27
29
|
type NavbarLogoProps = {
|
|
28
30
|
/**
|
|
29
31
|
* The Vercel mark, rendered by the server navbar so its SVGs (the Labs
|
|
@@ -36,7 +38,7 @@ type NavbarLogoProps = {
|
|
|
36
38
|
activeProduct?: string;
|
|
37
39
|
logo: ReactNode;
|
|
38
40
|
ossProducts?: GeistdocsNavbarOssProduct[];
|
|
39
|
-
variant: "oss";
|
|
41
|
+
variant: "oss" | "vercel-labs";
|
|
40
42
|
} | {
|
|
41
43
|
logo: ReactNode;
|
|
42
44
|
variant?: "vercel";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navbar-logo.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/navbar-logo.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"navbar-logo.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/navbar-logo.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAW/E,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAWjD,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,EAgF3D,CAAC;AAKF,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,EAAE,yBAAyB,EAyC5D,CAAC;AAqCF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,gNAC4K,CAAC;AAIhN;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACzE,2CA+BA;AAwCD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,yBAAyB,EAAE,GAAG,SAAS,EACjD,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,GACzC,yBAAyB,EAAE,CAM7B;AAED,KAAK,eAAe,GAAG;IACrB;;;OAGG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,CACA;IACE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,OAAO,EAAE,KAAK,GAAG,aAAa,CAAC;CAChC,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB,CACJ,CAAC;AAEF,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,SAAS,EACT,IAAU,EACV,GAAG,KAAK,EACT,EAAE,eAAe,2CA0MjB"}
|
|
@@ -11,15 +11,16 @@ import { LocalizedLink, useLocalizedHref } from "../localized-link";
|
|
|
11
11
|
import { NavigationMenu, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, } from "../ui/navigation-menu";
|
|
12
12
|
import { useServerPanelMount } from "./use-server-panel-mount";
|
|
13
13
|
export const DEFAULT_OSS_SECTION = "Open Source";
|
|
14
|
+
const FEATURED_EVE = {
|
|
15
|
+
description: "The framework for building agents",
|
|
16
|
+
featured: true,
|
|
17
|
+
href: "https://eve.dev/",
|
|
18
|
+
id: "eve",
|
|
19
|
+
label: "eve",
|
|
20
|
+
logo: _jsx(LogoEveSvg, { height: 18 }),
|
|
21
|
+
};
|
|
14
22
|
export const DEFAULT_OSS_PRODUCTS = [
|
|
15
|
-
|
|
16
|
-
description: "The framework for building agents",
|
|
17
|
-
featured: true,
|
|
18
|
-
href: "https://eve.dev/",
|
|
19
|
-
id: "eve",
|
|
20
|
-
label: "eve",
|
|
21
|
-
logo: _jsx(LogoEveSvg, { height: 18 }),
|
|
22
|
-
},
|
|
23
|
+
FEATURED_EVE,
|
|
23
24
|
{
|
|
24
25
|
href: "https://nextjs.org/",
|
|
25
26
|
id: "nextjs",
|
|
@@ -99,6 +100,61 @@ export const DEFAULT_OSS_PRODUCTS = [
|
|
|
99
100
|
section: "Other",
|
|
100
101
|
},
|
|
101
102
|
];
|
|
103
|
+
const LABS_PRODUCTS_SECTION = "Products";
|
|
104
|
+
const LABS_EXPERIMENTS_SECTION = "Experiments";
|
|
105
|
+
/** Default flyout for `navbarVariant: "vercel-labs"`, mirroring vercel.com/labs. */
|
|
106
|
+
export const DEFAULT_LABS_PRODUCTS = [
|
|
107
|
+
FEATURED_EVE,
|
|
108
|
+
...[
|
|
109
|
+
["agent-browser", "https://agent-browser.dev/"],
|
|
110
|
+
["skills", "https://skills.sh/"],
|
|
111
|
+
["json-render", "https://json-render.dev/"],
|
|
112
|
+
["portless", "https://portless.sh/"],
|
|
113
|
+
["deepsec", "https://deepsec.sh/"],
|
|
114
|
+
["just-bash", "https://justbash.dev/"],
|
|
115
|
+
["fx", "https://fx.sh/"],
|
|
116
|
+
["vgpu", "https://vgpu.sh/"],
|
|
117
|
+
].map(([label, href]) => ({
|
|
118
|
+
href,
|
|
119
|
+
id: label,
|
|
120
|
+
label,
|
|
121
|
+
section: LABS_PRODUCTS_SECTION,
|
|
122
|
+
})),
|
|
123
|
+
...[
|
|
124
|
+
["agent-desktop", "https://agent-browser.dev/desktop"],
|
|
125
|
+
["scriptc", "https://scriptc.dev/"],
|
|
126
|
+
["Native SDK", "https://native-sdk.dev/"],
|
|
127
|
+
["ai-cli", "https://ai-cli.dev/"],
|
|
128
|
+
["wterm", "https://wterm.dev/"],
|
|
129
|
+
["emulate", "https://emulate.dev/"],
|
|
130
|
+
["opensrc", "https://opensrc.sh/"],
|
|
131
|
+
].map(([label, href]) => ({
|
|
132
|
+
href,
|
|
133
|
+
id: label.toLowerCase().replace(" ", "-"),
|
|
134
|
+
label,
|
|
135
|
+
section: LABS_EXPERIMENTS_SECTION,
|
|
136
|
+
})),
|
|
137
|
+
{
|
|
138
|
+
href: "https://vercel.com/labs",
|
|
139
|
+
id: "labs-all",
|
|
140
|
+
label: "View all",
|
|
141
|
+
section: LABS_EXPERIMENTS_SECTION,
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
/** Sections longer than this split into side-by-side columns. */
|
|
145
|
+
const MAX_COLUMN_ITEMS = 5;
|
|
146
|
+
function chunkColumns(items) {
|
|
147
|
+
if (items.length <= MAX_COLUMN_ITEMS) {
|
|
148
|
+
return [items];
|
|
149
|
+
}
|
|
150
|
+
const count = Math.ceil(items.length / MAX_COLUMN_ITEMS);
|
|
151
|
+
const size = Math.ceil(items.length / count);
|
|
152
|
+
const columns = [];
|
|
153
|
+
for (let i = 0; i < items.length; i += size) {
|
|
154
|
+
columns.push(items.slice(i, i + size));
|
|
155
|
+
}
|
|
156
|
+
return columns;
|
|
157
|
+
}
|
|
102
158
|
function groupOssProducts(products) {
|
|
103
159
|
const sections = [];
|
|
104
160
|
for (const product of products) {
|
|
@@ -131,7 +187,7 @@ export function PanelLink({ active, product, }) {
|
|
|
131
187
|
}
|
|
132
188
|
function OssFeaturedCard({ product }) {
|
|
133
189
|
const external = product.external ?? product.href.startsWith("http");
|
|
134
|
-
const card = (_jsxs("span", { className: "flex h-full w-[220px] flex-col gap-3 rounded-lg border border-gray-alpha-400 bg-background-100 p-4 no-underline transition-colors hover:border-gray-alpha-500", children: [_jsx("span", { className: "flex flex-1 items-center justify-center rounded-md bg-gray-100", children: product.logo }), product.description ? (_jsx("span", { className: "text-copy-14 text-gray-900", children: product.description })) : null] }));
|
|
190
|
+
const card = (_jsxs("span", { className: "flex h-full w-[220px] flex-col gap-3 rounded-lg border border-gray-alpha-400 bg-background-100 p-4 no-underline transition-colors hover:border-gray-alpha-500", children: [_jsx("span", { className: "flex min-h-[74px] flex-1 items-center justify-center rounded-md bg-gray-100", children: product.logo }), product.description ? (_jsx("span", { className: "text-copy-14 text-gray-900", children: product.description })) : null] }));
|
|
135
191
|
return (_jsx(NavigationMenuLink, { asChild: true, children: external ? (_jsx("a", { className: "w-fit! rounded-lg no-underline outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-200", href: product.href, rel: "noopener noreferrer", target: "_blank", children: card })) : (_jsx(LocalizedLink, { className: "w-fit! rounded-lg no-underline outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-200", href: product.href, children: card })) }));
|
|
136
192
|
}
|
|
137
193
|
/**
|
|
@@ -141,13 +197,14 @@ function OssFeaturedCard({ product }) {
|
|
|
141
197
|
* and is a client-only value — resolving it on the server yields a client
|
|
142
198
|
* reference, not the array.
|
|
143
199
|
*/
|
|
144
|
-
export function resolveOssProducts(products, activeProduct) {
|
|
145
|
-
|
|
200
|
+
export function resolveOssProducts(products, activeProduct, variant) {
|
|
201
|
+
const defaults = variant === "vercel-labs" ? DEFAULT_LABS_PRODUCTS : DEFAULT_OSS_PRODUCTS;
|
|
202
|
+
return (products ?? defaults).filter((product) => product.id !== activeProduct && product.href !== activeProduct);
|
|
146
203
|
}
|
|
147
204
|
export function NavbarLogo({ brandMark, className, href = "/", ...props }) {
|
|
148
|
-
const isOss = props.variant === "oss";
|
|
205
|
+
const isOss = props.variant === "oss" || props.variant === "vercel-labs";
|
|
149
206
|
const ossProducts = isOss
|
|
150
|
-
? resolveOssProducts(props.ossProducts, props.activeProduct)
|
|
207
|
+
? resolveOssProducts(props.ossProducts, props.activeProduct, props.variant)
|
|
151
208
|
: [];
|
|
152
209
|
const featuredProducts = ossProducts.filter((product) => product.featured);
|
|
153
210
|
const ossSections = groupOssProducts(ossProducts.filter((product) => !product.featured));
|
|
@@ -222,5 +279,5 @@ export function NavbarLogo({ brandMark, className, href = "/", ...props }) {
|
|
|
222
279
|
}, onMouseEnter: () => {
|
|
223
280
|
cancelPointerLeave();
|
|
224
281
|
logoHoveredRef.current = true;
|
|
225
|
-
}, onMouseLeave: schedulePointerLeave, children: _jsx("div", { className: "mx-auto w-full max-w-[1448px] px-2", children: _jsxs("div", { className: "flex flex-nowrap gap-x-10 pt-4 pb-6 pl-4", children: [featuredProducts.length > 0 ? (_jsxs("div", { className: "flex shrink-0 flex-col", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: "Latest" }), _jsx("div", { className: "mt-[5px] flex flex-1 gap-x-10", children: featuredProducts.map((product) => (_jsx(OssFeaturedCard, { product: product }, product.href))) })] })) : null, ossSections.map((section) => (_jsxs("div", { className: "
|
|
282
|
+
}, onMouseLeave: schedulePointerLeave, children: _jsx("div", { className: "mx-auto w-full max-w-[1448px] px-2", children: _jsxs("div", { className: "flex flex-nowrap gap-x-10 pt-4 pb-6 pl-4", children: [featuredProducts.length > 0 ? (_jsxs("div", { className: "flex shrink-0 flex-col", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: "Latest" }), _jsx("div", { className: "mt-[5px] flex flex-1 gap-x-10", children: featuredProducts.map((product) => (_jsx(OssFeaturedCard, { product: product }, product.href))) })] })) : null, ossSections.map((section) => (_jsxs("div", { className: "shrink-0", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: section.heading }), _jsx("div", { className: "flex gap-x-10", children: chunkColumns(section.items).map((column) => (_jsx("ul", { className: "mt-[5px] flex min-w-[180px] list-none flex-col", children: column.map((product) => (_jsx("li", { className: "flex", children: _jsx(PanelLink, { product: product }) }, product.id ?? product.href))) }, column[0]?.href))) })] }, section.heading)))] }) }) })] }) }) }), _jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none fixed inset-x-0 top-16 bottom-0 z-0 bg-background-200/60", navValue ? "opacity-100" : "opacity-0") })] })] })) : null] }));
|
|
226
283
|
}
|
package/dist/navbar.js
CHANGED
|
@@ -12,7 +12,7 @@ export const Navbar = ({ config }) => {
|
|
|
12
12
|
const nav = config.nav ?? [];
|
|
13
13
|
const configuredVariant = config.navbarVariant ?? "oss";
|
|
14
14
|
const variant = configuredVariant === "standard" ? "vercel" : configuredVariant;
|
|
15
|
-
const
|
|
15
|
+
const isProductMenu = variant === "oss" || variant === "vercel-labs";
|
|
16
16
|
const showGithub = config.navbarGithub?.enabled !== false;
|
|
17
17
|
const buttonLabel = config.ai?.buttonLabel?.trim();
|
|
18
18
|
const askLabel = buttonLabel ? _jsx("span", { children: buttonLabel }) : undefined;
|
|
@@ -20,6 +20,7 @@ export const Navbar = ({ config }) => {
|
|
|
20
20
|
// The default product list lives in a "use client" module, so it is resolved
|
|
21
21
|
// and filtered inside the mobile menu.
|
|
22
22
|
const activeProduct = config.navbarActiveProduct;
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const brand = variant === "vercel-labs" ? "labs" : config.navbarBrand;
|
|
24
|
+
const brandMark = _jsx(NavbarBrand, { brand: brand, variant: variant });
|
|
25
|
+
return (_jsx(NavbarShell, { children: _jsxs("div", { className: "@container mx-auto flex w-full max-w-[1448px] justify-between px-2", children: [_jsxs("div", { className: "flex select-none flex-row items-center", children: [isProductMenu ? (_jsx(NavbarLogo, { activeProduct: activeProduct, brandMark: brandMark, className: "ml-4", href: config.logoHref, logo: config.logo, ossProducts: config.navbarOssProducts, variant: variant })) : (_jsx(NavbarLogo, { brandMark: brandMark, className: "ml-4", href: config.logoHref, logo: config.logo, variant: "vercel" })), _jsx(DesktopMenu, { className: "@min-[1024px]:flex hidden", items: nav, variant: variant === "vercel" ? "vercel" : "oss" })] }), _jsxs("div", { className: "mr-4 flex flex-row items-center justify-end gap-2", children: [_jsx(SearchButton, { className: "@min-[1024px]:flex hidden w-36" }), _jsx(AskAIButton, { className: "@min-[768px]:flex hidden shrink-0", size: "small", variant: "secondary", children: askLabel }), _jsx(AskAIButton, { className: "@min-[768px]:hidden", size: "small", variant: "secondary", children: askLabel }), showGithub ? (_jsx(GitHubButton, { className: "@min-[768px]:inline-flex hidden shrink-0", github: config.github })) : null, _jsx(MobileMenu, { activeProduct: activeProduct, githubUrl: githubUrl, nav: nav, navbarVariant: variant, ossProducts: config.navbarOssProducts, showProductMenu: isProductMenu })] })] }) }));
|
|
25
26
|
};
|
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
|
+
These docs are bundled with `@vercel/geistdocs` 2.16.0 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
|
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
|
+
These docs are bundled with `@vercel/geistdocs` 2.16.0.
|
|
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
|
|
@@ -1244,7 +1244,7 @@ export const navbarBrand: GeistdocsNavbarBrand = "labs";
|
|
|
1244
1244
|
|
|
1245
1245
|
The generated `lib/geistdocs/config.tsx` forwards this export to `defineConfig`. Existing sites can forward it in their adapter or set `navbarBrand: "labs"` directly in `defineConfig`. Private projects use the type from `@vercel/geistdocs-private/config`.
|
|
1246
1246
|
|
|
1247
|
-
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes.
|
|
1247
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Set `navbarVariant: "vercel-labs"` in `defineConfig` to use the Labs mark and show the Labs products and experiments menu. The previous `"standard"` value remains supported as an alias for `"vercel"`. The `"oss"` (default) layout keeps your project's `Logo` and `logoHref` separate from the brand and shows the OSS product menu. The `"vercel"` layout shows the selected brand mark, with no separator, project logo, or product menu.
|
|
1248
1248
|
|
|
1249
1249
|
For new projects, both CLIs accept `--brand labs`; omitting it or using `--brand vercel` preserves the defaults. See [Create a Labs starter](/docs/getting-started#create-a-labs-starter).
|
|
1250
1250
|
|
|
@@ -1424,6 +1424,18 @@ export const docs = defineDocs({
|
|
|
1424
1424
|
export default defineGeistdocsSourceConfig();
|
|
1425
1425
|
```
|
|
1426
1426
|
|
|
1427
|
+
### Code highlighter (public package)
|
|
1428
|
+
|
|
1429
|
+
The public package uses [Highlights](https://diffs.com/highlights), which tokenizes code with WebAssembly lexers while keeping the JavaScript MDX compiler. Geist colors, titles, icons, tabs and `[!code ...]` annotations are preserved. Some token colors differ from Shiki, and unsupported languages render as plain text. To use Shiki's TextMate grammars instead, pass `highlighter: "shiki"`:
|
|
1430
|
+
|
|
1431
|
+
```ts title="source.config.ts"
|
|
1432
|
+
export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
|
|
1433
|
+
```
|
|
1434
|
+
|
|
1435
|
+
Set `highlighter: false` or `mdxOptions.rehypeCodeOptions: false` to disable built-in highlighting when providing your own plugin. A `rehypePlugins` callback can also remove or replace Fumadocs' default highlighter without Highlights being added back.
|
|
1436
|
+
|
|
1437
|
+
The private package retains its existing Shiki pipeline. The `highlighter` option above is available only in the public package.
|
|
1438
|
+
|
|
1427
1439
|
To serve docs from the site root, use `route: "/"` in `content` and `baseUrl: "/"` in `createSource`. Root-mounted docs need explicit `markdownRoutes`; Geistdocs does not infer a broad `/*path` mapping because it can capture homepages and non-docs app routes.
|
|
1428
1440
|
|
|
1429
1441
|
## Page URLs
|
package/docs/manifest.json
CHANGED
|
@@ -105,7 +105,7 @@ export const navbarBrand: GeistdocsNavbarBrand = "labs";
|
|
|
105
105
|
|
|
106
106
|
The generated `lib/geistdocs/config.tsx` forwards this export to `defineConfig`. Existing sites can forward it in their adapter or set `navbarBrand: "labs"` directly in `defineConfig`. Private projects use the type from `@vercel/geistdocs-private/config`.
|
|
107
107
|
|
|
108
|
-
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes.
|
|
108
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Set `navbarVariant: "vercel-labs"` in `defineConfig` to use the Labs mark and show the Labs products and experiments menu. The previous `"standard"` value remains supported as an alias for `"vercel"`. The `"oss"` (default) layout keeps your project's `Logo` and `logoHref` separate from the brand and shows the OSS product menu. The `"vercel"` layout shows the selected brand mark, with no separator, project logo, or product menu.
|
|
109
109
|
|
|
110
110
|
For new projects, both CLIs accept `--brand labs`; omitting it or using `--brand vercel` preserves the defaults. See [Create a Labs starter](/docs/getting-started#create-a-labs-starter).
|
|
111
111
|
|
|
@@ -285,6 +285,18 @@ export const docs = defineDocs({
|
|
|
285
285
|
export default defineGeistdocsSourceConfig();
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
+
### Code highlighter (public package)
|
|
289
|
+
|
|
290
|
+
The public package uses [Highlights](https://diffs.com/highlights), which tokenizes code with WebAssembly lexers while keeping the JavaScript MDX compiler. Geist colors, titles, icons, tabs and `[!code ...]` annotations are preserved. Some token colors differ from Shiki, and unsupported languages render as plain text. To use Shiki's TextMate grammars instead, pass `highlighter: "shiki"`:
|
|
291
|
+
|
|
292
|
+
```ts title="source.config.ts"
|
|
293
|
+
export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Set `highlighter: false` or `mdxOptions.rehypeCodeOptions: false` to disable built-in highlighting when providing your own plugin. A `rehypePlugins` callback can also remove or replace Fumadocs' default highlighter without Highlights being added back.
|
|
297
|
+
|
|
298
|
+
The private package retains its existing Shiki pipeline. The `highlighter` option above is available only in the public package.
|
|
299
|
+
|
|
288
300
|
To serve docs from the site root, use `route: "/"` in `content` and `baseUrl: "/"` in `createSource`. Root-mounted docs need explicit `markdownRoutes`; Geistdocs does not infer a broad `/*path` mapping because it can capture homepages and non-docs app routes.
|
|
289
301
|
|
|
290
302
|
## Page URLs
|
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.
|
|
4
|
+
"version": "2.16.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,11 +27,15 @@
|
|
|
27
27
|
"cli.js",
|
|
28
28
|
"dist",
|
|
29
29
|
"docs",
|
|
30
|
+
"rehype-code-highlights.d.ts",
|
|
31
|
+
"rehype-code-highlights.js",
|
|
30
32
|
"rehype-task-list-labels.d.ts",
|
|
31
33
|
"rehype-task-list-labels.js",
|
|
32
34
|
"remark-details.d.ts",
|
|
33
35
|
"remark-details.js",
|
|
34
36
|
"source-config.js",
|
|
37
|
+
"source-config-public.js",
|
|
38
|
+
"source-config-public.d.ts",
|
|
35
39
|
"template",
|
|
36
40
|
"public-foundation.css",
|
|
37
41
|
"shared-theme.css",
|
|
@@ -161,8 +165,8 @@
|
|
|
161
165
|
"default": "./dist/providers/public/utils.js"
|
|
162
166
|
},
|
|
163
167
|
"./source-config": {
|
|
164
|
-
"types": "./
|
|
165
|
-
"default": "./source-config.js"
|
|
168
|
+
"types": "./source-config-public.d.ts",
|
|
169
|
+
"default": "./source-config-public.js"
|
|
166
170
|
},
|
|
167
171
|
"./docs/agents.md": "./docs/agents.md",
|
|
168
172
|
"./docs/llms.txt": "./docs/llms.txt",
|
|
@@ -307,6 +311,8 @@
|
|
|
307
311
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
308
312
|
"@next/env": "16.3.3",
|
|
309
313
|
"@orama/tokenizers": "^3.1.16",
|
|
314
|
+
"@pierre/highlights": "0.5.1",
|
|
315
|
+
"@shikijs/rehype": "3.19.0",
|
|
310
316
|
"@streamdown/cjk": "^1.0.1",
|
|
311
317
|
"@types/mdx": "^2.0.13",
|
|
312
318
|
"@types/react": "^19.2.7",
|
|
@@ -335,6 +341,7 @@
|
|
|
335
341
|
"remark-mdx": "^3.1.1",
|
|
336
342
|
"remark-parse": "^11.0.0",
|
|
337
343
|
"remark-stringify": "^11.0.0",
|
|
344
|
+
"shiki": "3.19.0",
|
|
338
345
|
"sonner": "^2.0.8",
|
|
339
346
|
"streamdown": "^2.1.0",
|
|
340
347
|
"tailwind-merge": "^3.4.0",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RehypeCodeOptions } from "fumadocs-core/mdx-plugins";
|
|
2
|
+
import type { Root } from "hast";
|
|
3
|
+
|
|
4
|
+
/** Zed-format Geist theme for @pierre/highlights, using Geist's Shiki CSS variables. */
|
|
5
|
+
export declare const geistHighlightsTheme: Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Drop-in for Fumadocs' `rehypeCode` that tokenizes with
|
|
9
|
+
* @pierre/highlights while keeping Shiki's HAST output and transformers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const rehypeCodeHighlights: (
|
|
12
|
+
options?: Partial<RehypeCodeOptions>
|
|
13
|
+
) => (tree: Root, file: unknown) => Promise<void>;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { codeToTokens, isSupportedLanguage } from "@pierre/highlights";
|
|
2
|
+
import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
|
|
3
|
+
import {
|
|
4
|
+
rehypeCodeDefaultOptions,
|
|
5
|
+
transformerIcon,
|
|
6
|
+
transformerTab,
|
|
7
|
+
} from "fumadocs-core/mdx-plugins";
|
|
8
|
+
import { tokensToHast, transformerDecorations } from "shiki/core";
|
|
9
|
+
|
|
10
|
+
// Highlights code blocks with @pierre/highlights (hand-written
|
|
11
|
+
// Wasm lexers) instead of Shiki's TextMate grammars, while keeping Shiki's
|
|
12
|
+
// HAST output and transformer pipeline so Fumadocs' code block features
|
|
13
|
+
// (titles, icons, tabs, line notation, diffs, focus) keep working.
|
|
14
|
+
|
|
15
|
+
const v = (name) => `token-${name}`;
|
|
16
|
+
|
|
17
|
+
// Maps Highlights' Zed token names onto the same CSS variables the Geist
|
|
18
|
+
// Shiki theme uses (see `geistShikiTheme`), so the existing palette applies.
|
|
19
|
+
// With a `cssVariables` palette, colors are variable suffixes: `token-keyword`
|
|
20
|
+
// renders as `var(--shiki-token-keyword)`.
|
|
21
|
+
export const geistHighlightsTheme = {
|
|
22
|
+
name: "geist",
|
|
23
|
+
appearance: "light",
|
|
24
|
+
cssVariables: {
|
|
25
|
+
prefix: "--shiki-",
|
|
26
|
+
defaults: { "color-text": "inherit", "color-background": "transparent" },
|
|
27
|
+
},
|
|
28
|
+
style: {
|
|
29
|
+
"editor.foreground": "color-text",
|
|
30
|
+
"editor.background": "color-background",
|
|
31
|
+
syntax: {
|
|
32
|
+
comment: v("comment"),
|
|
33
|
+
"comment.doc": v("comment"),
|
|
34
|
+
"keyword.jsdoc": v("comment"),
|
|
35
|
+
"type.jsdoc": v("comment"),
|
|
36
|
+
"variable.jsdoc": v("comment"),
|
|
37
|
+
constant: v("constant"),
|
|
38
|
+
"constant.builtin": v("constant"),
|
|
39
|
+
boolean: v("constant"),
|
|
40
|
+
number: v("constant"),
|
|
41
|
+
enum: v("constant"),
|
|
42
|
+
"variable.special": v("constant"),
|
|
43
|
+
function: v("function"),
|
|
44
|
+
"function.definition": v("function"),
|
|
45
|
+
"function.method": v("function"),
|
|
46
|
+
constructor: v("function"),
|
|
47
|
+
type: v("function"),
|
|
48
|
+
"type.class": v("function"),
|
|
49
|
+
tag: v("function"),
|
|
50
|
+
"tag.jsx": v("function"),
|
|
51
|
+
"tag.component.jsx": v("function"),
|
|
52
|
+
"tag.doctype": v("function"),
|
|
53
|
+
title: v("function"),
|
|
54
|
+
namespace: v("function"),
|
|
55
|
+
selector: v("function"),
|
|
56
|
+
"selector.class": v("function"),
|
|
57
|
+
"selector.id": v("function"),
|
|
58
|
+
"selector.pseudo": v("function"),
|
|
59
|
+
attribute: v("constant"),
|
|
60
|
+
"attribute.jsx": v("constant"),
|
|
61
|
+
"variable.parameter": v("parameter"),
|
|
62
|
+
property: v("parameter"),
|
|
63
|
+
"property.json_key": v("parameter"),
|
|
64
|
+
label: v("parameter"),
|
|
65
|
+
"text.jsx": v("parameter"),
|
|
66
|
+
"punctuation.list_marker": v("parameter"),
|
|
67
|
+
keyword: v("keyword"),
|
|
68
|
+
"keyword.control": v("keyword"),
|
|
69
|
+
"keyword.declaration": v("keyword"),
|
|
70
|
+
"keyword.import": v("keyword"),
|
|
71
|
+
"keyword.operator": v("keyword"),
|
|
72
|
+
operator: v("keyword"),
|
|
73
|
+
preproc: v("keyword"),
|
|
74
|
+
string: v("string"),
|
|
75
|
+
"string.escape": v("string"),
|
|
76
|
+
"string.special": v("string"),
|
|
77
|
+
"string.special.symbol": v("string"),
|
|
78
|
+
"text.literal": v("string"),
|
|
79
|
+
"string.regex": v("string-expression"),
|
|
80
|
+
punctuation: v("punctuation"),
|
|
81
|
+
"punctuation.bracket": v("punctuation"),
|
|
82
|
+
"punctuation.delimiter": v("punctuation"),
|
|
83
|
+
"punctuation.special": v("keyword"),
|
|
84
|
+
"punctuation.markup": v("punctuation"),
|
|
85
|
+
"punctuation.bracket.html": v("parameter"),
|
|
86
|
+
"punctuation.bracket.jsx": v("parameter"),
|
|
87
|
+
"punctuation.delimiter.html": v("parameter"),
|
|
88
|
+
"punctuation.delimiter.jsx": v("parameter"),
|
|
89
|
+
link_uri: v("link"),
|
|
90
|
+
link_text: v("parameter"),
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Fenced-code names that Highlights doesn't know but Shiki users write.
|
|
96
|
+
const LANG_ALIASES = {
|
|
97
|
+
plaintext: "plain",
|
|
98
|
+
txt: "plain",
|
|
99
|
+
"": "plain",
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const resolveLang = (lang) => {
|
|
103
|
+
const name = LANG_ALIASES[lang] ?? lang ?? "plain";
|
|
104
|
+
return isSupportedLanguage(name) ? name : "plain";
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const TRAILING_NEWLINE = /\n$/;
|
|
108
|
+
|
|
109
|
+
const ENFORCE_ORDER = { pre: 0, undefined: 1, post: 2 };
|
|
110
|
+
|
|
111
|
+
const getTransformers = (options) => [
|
|
112
|
+
...[...(options.transformers ?? [])].sort(
|
|
113
|
+
(a, b) => ENFORCE_ORDER[a.enforce] - ENFORCE_ORDER[b.enforce]
|
|
114
|
+
),
|
|
115
|
+
transformerDecorations(),
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
const UNSTYLED = "var(--shiki-foreground)";
|
|
119
|
+
const COMMENT = "var(--shiki-token-comment)";
|
|
120
|
+
const TRAILING_SPACE = /[\t ]+$/;
|
|
121
|
+
|
|
122
|
+
const joinCommentWhitespace = (line) => {
|
|
123
|
+
for (let index = 1; index < line.length; index++) {
|
|
124
|
+
const token = line[index];
|
|
125
|
+
if (token.htmlStyle?.color !== COMMENT) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
// Shiki groups JSX indentation with the opening brace. Its annotation
|
|
129
|
+
// transformer recognizes a standalone JSX comment by those three tokens.
|
|
130
|
+
const opening = index - 1;
|
|
131
|
+
if (
|
|
132
|
+
token.content.trimStart().startsWith("/*") &&
|
|
133
|
+
line[opening].content.trim() === "{" &&
|
|
134
|
+
line[index + 1]?.content.trim() === "}" &&
|
|
135
|
+
line.slice(0, opening).every((part) => part.content.trim() === "")
|
|
136
|
+
) {
|
|
137
|
+
const indentation = line
|
|
138
|
+
.slice(0, opening)
|
|
139
|
+
.map((part) => part.content)
|
|
140
|
+
.join("");
|
|
141
|
+
line[opening].content = indentation + line[opening].content;
|
|
142
|
+
line[opening].offset -= indentation.length;
|
|
143
|
+
line.splice(0, opening);
|
|
144
|
+
index -= opening;
|
|
145
|
+
}
|
|
146
|
+
// Shiki includes the separator before a comment in its comment token.
|
|
147
|
+
// Match that boundary so notation removal also removes the separator,
|
|
148
|
+
// without trimming authored whitespace from unrelated code lines.
|
|
149
|
+
while (index > 0) {
|
|
150
|
+
const previous = line[index - 1];
|
|
151
|
+
const whitespace = previous.content.match(TRAILING_SPACE)?.[0];
|
|
152
|
+
if (!whitespace) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
previous.content = previous.content.slice(0, -whitespace.length);
|
|
156
|
+
token.content = whitespace + token.content;
|
|
157
|
+
token.offset -= whitespace.length;
|
|
158
|
+
if (previous.content) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
line.splice(index - 1, 1);
|
|
162
|
+
index--;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const tokenize = (code, options) => {
|
|
168
|
+
const result = codeToTokens(code, {
|
|
169
|
+
lang: resolveLang(options.lang),
|
|
170
|
+
themes: { light: geistHighlightsTheme },
|
|
171
|
+
defaultColor: "light",
|
|
172
|
+
cssVariablePrefix: "--shiki-",
|
|
173
|
+
});
|
|
174
|
+
// Highlights colors unstyled runs with `var(--shiki-foreground)`; Shiki uses
|
|
175
|
+
// the theme foreground, which Geist defines as `--shiki-color-text`.
|
|
176
|
+
for (const line of result.tokens) {
|
|
177
|
+
joinCommentWhitespace(line);
|
|
178
|
+
for (const token of line) {
|
|
179
|
+
if (token.htmlStyle?.color === UNSTYLED) {
|
|
180
|
+
token.htmlStyle = { ...token.htmlStyle, color: result.fg };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
tokens: result.tokens,
|
|
186
|
+
fg: result.fg,
|
|
187
|
+
bg: result.bg,
|
|
188
|
+
themeName: "shiki-themes geist",
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* A minimal Shiki highlighter: enough of the API for `@shikijs/rehype/core`.
|
|
194
|
+
* Mirrors Shiki's `codeToHast` (preprocess → tokens → token transformers →
|
|
195
|
+
* `tokensToHast`), swapping the tokenizer for Highlights.
|
|
196
|
+
*/
|
|
197
|
+
export const highlightsShikiAdapter = {
|
|
198
|
+
getLoadedLanguages: () => [],
|
|
199
|
+
loadLanguage: async () => undefined,
|
|
200
|
+
codeToTokens: (code, options) => tokenize(code, options),
|
|
201
|
+
codeToHast(code, options) {
|
|
202
|
+
const transformers = getTransformers(options);
|
|
203
|
+
const context = {
|
|
204
|
+
meta: {},
|
|
205
|
+
options,
|
|
206
|
+
codeToHast: (c, o) => highlightsShikiAdapter.codeToHast(c, o),
|
|
207
|
+
codeToTokens: (c, o) => tokenize(c, o),
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
let input = code;
|
|
211
|
+
for (const transformer of transformers) {
|
|
212
|
+
input = transformer.preprocess?.call(context, input, options) || input;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let { tokens, fg, bg, themeName } = tokenize(input, options);
|
|
216
|
+
const contextSource = {
|
|
217
|
+
...context,
|
|
218
|
+
get source() {
|
|
219
|
+
return input;
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
for (const transformer of transformers) {
|
|
223
|
+
tokens = transformer.tokens?.call(contextSource, tokens) || tokens;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return tokensToHast(
|
|
227
|
+
tokens,
|
|
228
|
+
{
|
|
229
|
+
...options,
|
|
230
|
+
fg,
|
|
231
|
+
bg,
|
|
232
|
+
themeName,
|
|
233
|
+
transformers: options.transformers,
|
|
234
|
+
},
|
|
235
|
+
contextSource
|
|
236
|
+
);
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/** Drop-in for Fumadocs' `rehypeCode`, backed by @pierre/highlights. */
|
|
241
|
+
export const rehypeCodeHighlights = (userOptions = {}) => {
|
|
242
|
+
const options = { ...rehypeCodeDefaultOptions, ...userOptions };
|
|
243
|
+
const transformers = [...(options.transformers ?? [])];
|
|
244
|
+
|
|
245
|
+
// Same preprocessing as Fumadocs' rehypeCode.
|
|
246
|
+
transformers.unshift({
|
|
247
|
+
name: "rehype-code:pre-process",
|
|
248
|
+
preprocess(code, { meta }) {
|
|
249
|
+
if (meta && "__parsed_raw" in meta) {
|
|
250
|
+
meta.__raw = meta.__parsed_raw;
|
|
251
|
+
// biome-ignore lint/performance/noDelete: matches Fumadocs.
|
|
252
|
+
delete meta.__parsed_raw;
|
|
253
|
+
}
|
|
254
|
+
if (meta && options.filterMetaString) {
|
|
255
|
+
meta.__raw = options.filterMetaString(meta.__raw ?? "");
|
|
256
|
+
}
|
|
257
|
+
return code.replace(TRAILING_NEWLINE, "");
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
if (options.icon !== false) {
|
|
261
|
+
transformers.push(transformerIcon(options.icon));
|
|
262
|
+
}
|
|
263
|
+
if (options.tab !== false) {
|
|
264
|
+
transformers.push(transformerTab());
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// `lazy` routes every language through `loadLanguage`, which is a no-op:
|
|
268
|
+
// Highlights bundles its lexers and unknown languages fall back to plain.
|
|
269
|
+
const transformer = rehypeShikiFromHighlighter(highlightsShikiAdapter, {
|
|
270
|
+
...options,
|
|
271
|
+
lazy: true,
|
|
272
|
+
transformers,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return async (tree, file) => {
|
|
276
|
+
await transformer(tree, file, () => undefined);
|
|
277
|
+
};
|
|
278
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GeistdocsSourceConfigOptions as BaseOptions,
|
|
3
|
+
defineGeistdocsSourceConfig as defineBaseConfig,
|
|
4
|
+
} from "./dist/source-config.js";
|
|
5
|
+
|
|
6
|
+
export * from "./dist/source-config.js";
|
|
7
|
+
|
|
8
|
+
export interface GeistdocsSourceConfigOptions extends BaseOptions {
|
|
9
|
+
/** Public package only. Defaults to Highlights; false disables highlighting. */
|
|
10
|
+
highlighter?: "highlights" | "shiki" | false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare const defineGeistdocsSourceConfig: (
|
|
14
|
+
options?: GeistdocsSourceConfigOptions
|
|
15
|
+
) => ReturnType<typeof defineBaseConfig>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { rehypeCodeHighlights } from "./rehype-code-highlights.js";
|
|
2
|
+
import { defineGeistdocsSourceConfig as defineBaseConfig } from "./source-config.js";
|
|
3
|
+
|
|
4
|
+
// biome-ignore lint/performance/noBarrelFile: this package entry point reuses the already-loaded source config.
|
|
5
|
+
export * from "./source-config.js";
|
|
6
|
+
|
|
7
|
+
// Keep the shared source config on Shiki: the private product copies that
|
|
8
|
+
// entry point and must not acquire a dependency on Highlights.
|
|
9
|
+
export const defineGeistdocsSourceConfig = (options = {}) => {
|
|
10
|
+
const { highlighter = "highlights", ...config } = options;
|
|
11
|
+
if (!["highlights", "shiki", false].includes(highlighter)) {
|
|
12
|
+
throw new TypeError(`Unknown code highlighter: ${highlighter}`);
|
|
13
|
+
}
|
|
14
|
+
const result = defineBaseConfig(config);
|
|
15
|
+
const mdx = result.mdxOptions;
|
|
16
|
+
if (highlighter === false || config.mdxOptions?.rehypeCodeOptions === false) {
|
|
17
|
+
mdx.rehypeCodeOptions = false;
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
if (highlighter === "shiki") {
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const plugins = mdx.rehypePlugins;
|
|
25
|
+
if (typeof plugins === "function") {
|
|
26
|
+
mdx.rehypePlugins = (defaults) => {
|
|
27
|
+
// Fumadocs 14 puts its enabled code highlighter first. Capture the
|
|
28
|
+
// loader's instance before the consumer can reorder or remove it;
|
|
29
|
+
// pnpm may give Geistdocs a different copy of fumadocs-core.
|
|
30
|
+
const first = defaults[0];
|
|
31
|
+
const defaultHighlighter = Array.isArray(first) ? first[0] : first;
|
|
32
|
+
return plugins(defaults).map((entry) => {
|
|
33
|
+
const [plugin, pluginOptions] = Array.isArray(entry) ? entry : [entry];
|
|
34
|
+
return defaultHighlighter && plugin === defaultHighlighter
|
|
35
|
+
? [rehypeCodeHighlights, pluginOptions]
|
|
36
|
+
: entry;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
} else {
|
|
40
|
+
mdx.rehypePlugins = [
|
|
41
|
+
[rehypeCodeHighlights, mdx.rehypeCodeOptions],
|
|
42
|
+
...(plugins ?? []),
|
|
43
|
+
];
|
|
44
|
+
mdx.rehypeCodeOptions = false;
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
@@ -103,7 +103,7 @@ export const navbarBrand: GeistdocsNavbarBrand = "labs";
|
|
|
103
103
|
|
|
104
104
|
The generated `lib/geistdocs/config.tsx` forwards this export to `defineConfig`. Existing sites can forward it in their adapter or set `navbarBrand: "labs"` directly in `defineConfig`. Private projects use the type from `@vercel/geistdocs-private/config`.
|
|
105
105
|
|
|
106
|
-
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes.
|
|
106
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Set `navbarVariant: "vercel-labs"` in `defineConfig` to use the Labs mark and show the Labs products and experiments menu. The previous `"standard"` value remains supported as an alias for `"vercel"`. The `"oss"` (default) layout keeps your project's `Logo` and `logoHref` separate from the brand and shows the OSS product menu. The `"vercel"` layout shows the selected brand mark, with no separator, project logo, or product menu.
|
|
107
107
|
|
|
108
108
|
For new projects, both CLIs accept `--brand labs`; omitting it or using `--brand vercel` preserves the defaults. See [Create a Labs starter](/docs/getting-started#create-a-labs-starter).
|
|
109
109
|
|
|
@@ -283,6 +283,18 @@ export const docs = defineDocs({
|
|
|
283
283
|
export default defineGeistdocsSourceConfig();
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
+
### Code highlighter (public package)
|
|
287
|
+
|
|
288
|
+
The public package uses [Highlights](https://diffs.com/highlights), which tokenizes code with WebAssembly lexers while keeping the JavaScript MDX compiler. Geist colors, titles, icons, tabs and `[!code ...]` annotations are preserved. Some token colors differ from Shiki, and unsupported languages render as plain text. To use Shiki's TextMate grammars instead, pass `highlighter: "shiki"`:
|
|
289
|
+
|
|
290
|
+
```ts title="source.config.ts"
|
|
291
|
+
export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Set `highlighter: false` or `mdxOptions.rehypeCodeOptions: false` to disable built-in highlighting when providing your own plugin. A `rehypePlugins` callback can also remove or replace Fumadocs' default highlighter without Highlights being added back.
|
|
295
|
+
|
|
296
|
+
The private package retains its existing Shiki pipeline. The `highlighter` option above is available only in the public package.
|
|
297
|
+
|
|
286
298
|
To serve docs from the site root, use `route: "/"` in `content` and `baseUrl: "/"` in `createSource`. Root-mounted docs need explicit `markdownRoutes`; Geistdocs does not infer a broad `/*path` mapping because it can capture homepages and non-docs app routes.
|
|
287
299
|
|
|
288
300
|
## Page URLs
|
package/template/package.json
CHANGED