@vercel/geistdocs 2.15.0 → 2.15.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 +1 -1
- package/dist/config.d.ts +5 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/internal/navbar/desktop-menu.d.ts +2 -1
- package/dist/internal/navbar/desktop-menu.d.ts.map +1 -1
- package/dist/internal/navbar/desktop-menu.js +8 -8
- package/dist/internal/navbar/navbar-brand.d.ts.map +1 -1
- package/dist/internal/navbar/navbar-brand.js +3 -7
- package/dist/internal/navbar/navbar-logo.d.ts +1 -1
- package/dist/internal/navbar/navbar-logo.d.ts.map +1 -1
- package/dist/internal/navbar/navbar-logo.js +2 -2
- package/dist/internal/search-ranking.d.ts +45 -0
- package/dist/internal/search-ranking.d.ts.map +1 -0
- package/dist/internal/search-ranking.js +186 -0
- package/dist/navbar.d.ts.map +1 -1
- package/dist/navbar.js +3 -2
- package/dist/routes/search.d.ts.map +1 -1
- package/dist/routes/search.js +80 -4
- package/docs/agents.md +1 -1
- package/docs/llms.txt +17 -2
- package/docs/manifest.json +1 -1
- package/docs/pages/configuration.md +1 -1
- package/docs/pages/provider.md +15 -0
- package/package.json +1 -1
- package/template/content/docs/configuration.mdx +1 -1
- package/template/content/docs/provider.mdx +15 -0
- package/template/lib/geistdocs/config.tsx +1 -0
- 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.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});
|
|
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.2","-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
|
@@ -288,7 +288,11 @@ export interface GeistdocsConfig {
|
|
|
288
288
|
*/
|
|
289
289
|
navbarGithub?: GeistdocsFeatureConfig;
|
|
290
290
|
navbarOssProducts?: GeistdocsNavbarOssProduct[];
|
|
291
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Navbar layout. `"standard"` remains accepted as a compatibility alias
|
|
293
|
+
* for `"vercel"`.
|
|
294
|
+
*/
|
|
295
|
+
navbarVariant?: "oss" | "vercel" | "standard";
|
|
292
296
|
pageActions?: GeistdocsPageActionsConfig;
|
|
293
297
|
prompt?: string;
|
|
294
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;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CAAC;IACvB,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,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"}
|
|
@@ -2,6 +2,7 @@ import type { GeistdocsNavDropdown, GeistdocsNavDropdownItem, GeistdocsNavItem }
|
|
|
2
2
|
interface DesktopMenuProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
items: GeistdocsNavItem[];
|
|
5
|
+
variant: "oss" | "vercel";
|
|
5
6
|
}
|
|
6
7
|
interface DropdownSection {
|
|
7
8
|
heading: string;
|
|
@@ -13,6 +14,6 @@ interface DropdownSection {
|
|
|
13
14
|
* sectionless dropdown renders as a single labeled column.
|
|
14
15
|
*/
|
|
15
16
|
export declare function groupDropdownItems(dropdown: GeistdocsNavDropdown): DropdownSection[];
|
|
16
|
-
export declare const DesktopMenu: ({ items, className }: DesktopMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const DesktopMenu: ({ items, className, variant, }: DesktopMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export {};
|
|
18
19
|
//# sourceMappingURL=desktop-menu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktop-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/desktop-menu.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAatB,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"desktop-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/desktop-menu.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAatB,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,OAAO,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC3B;AAkBD,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,wBAAwB,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,oBAAoB,GAC7B,eAAe,EAAE,CAYnB;AAiED,eAAO,MAAM,WAAW,GAAI,gCAIzB,gBAAgB,4CA0ElB,CAAC"}
|
|
@@ -11,11 +11,11 @@ import { useNavActive } from "./use-nav-active";
|
|
|
11
11
|
import { useServerPanelMount } from "./use-server-panel-mount";
|
|
12
12
|
/**
|
|
13
13
|
* Shared styling for top-level nav triggers and links: full-height hit target
|
|
14
|
-
* with a floating focus ring. The
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* with a floating focus ring. The OSS layout adds left padding to clear the
|
|
15
|
+
* project logo trigger; the Vercel layout offsets its first link to match
|
|
16
|
+
* Vercel's Products position. Inter-item spacing stays tight (px-3).
|
|
17
17
|
*/
|
|
18
|
-
const topLevelItemClassName = (first) => cn("relative flex h-full items-center px-3 text-gray-900 text-sm outline-none transition-colors duration-100 before:absolute before:top-1/2 before:right-1 before:left-1 before:h-9 before:-translate-y-1/2 before:rounded-md before:content-[''] hover:text-gray-1000 focus-visible:before:ring-2 focus-visible:before:ring-blue-700 focus-visible:before:ring-inset data-[active]:text-gray-1000", first && "pl-6 before:left-4");
|
|
18
|
+
const topLevelItemClassName = (first, variant) => cn("relative flex h-full items-center px-3 text-gray-900 text-sm outline-none transition-colors duration-100 before:absolute before:top-1/2 before:right-1 before:left-1 before:h-9 before:-translate-y-1/2 before:rounded-md before:content-[''] hover:text-gray-1000 focus-visible:before:ring-2 focus-visible:before:ring-blue-700 focus-visible:before:ring-inset data-[active]:text-gray-1000", first && variant === "oss" && "pl-6 before:left-4", first && variant === "vercel" && "ml-5");
|
|
19
19
|
const isExternal = (item) => item.external ?? item.href.startsWith("http");
|
|
20
20
|
/**
|
|
21
21
|
* Group dropdown items into columns by `section`, preserving first-seen
|
|
@@ -41,15 +41,15 @@ export function groupDropdownItems(dropdown) {
|
|
|
41
41
|
* the vercel.com header pattern with columned sections and plain
|
|
42
42
|
* hover-underline links.
|
|
43
43
|
*/
|
|
44
|
-
const DropdownNavItem = ({ first, item, navItems, }) => {
|
|
44
|
+
const DropdownNavItem = ({ first, item, navItems, variant, }) => {
|
|
45
45
|
const isActive = useNavActive(navItems);
|
|
46
46
|
const hasActiveChild = item.items.some((child) => !isExternal(child) && isActive(child.href));
|
|
47
47
|
const sections = groupDropdownItems(item);
|
|
48
48
|
const forceMount = useServerPanelMount();
|
|
49
|
-
return (_jsxs(NavigationMenuItem, { className: "flex", children: [_jsx(NavigationMenuTrigger, { className: topLevelItemClassName(first), "data-active": hasActiveChild ? "" : undefined, children: item.label }), _jsx(NavigationMenuPrimitive.Content, { className: NAVBAR_PANEL_CLASSNAME, forceMount: forceMount, children: _jsx("div", { className: "mx-auto w-full max-w-[1448px] px-2", children: _jsx("div", { className: "flex flex-nowrap gap-x-10 pt-4 pb-6 pl-4", children: sections.map((section) => (_jsxs("div", { className: "min-w-[180px] shrink-0", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: section.heading }), _jsx("ul", { className: "mt-[5px] flex list-none flex-col", children: section.items.map((child) => (_jsx("li", { className: "flex", children: _jsx(PanelLink, { active: !isExternal(child) && isActive(child.href), product: child }) }, child.href))) })] }, section.heading))) }) }) })] }));
|
|
49
|
+
return (_jsxs(NavigationMenuItem, { className: "flex", children: [_jsx(NavigationMenuTrigger, { className: topLevelItemClassName(first, variant), "data-active": hasActiveChild ? "" : undefined, children: item.label }), _jsx(NavigationMenuPrimitive.Content, { className: NAVBAR_PANEL_CLASSNAME, forceMount: forceMount, children: _jsx("div", { className: "mx-auto w-full max-w-[1448px] px-2", children: _jsx("div", { className: "flex flex-nowrap gap-x-10 pt-4 pb-6 pl-4", children: sections.map((section) => (_jsxs("div", { className: "min-w-[180px] shrink-0", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: section.heading }), _jsx("ul", { className: "mt-[5px] flex list-none flex-col", children: section.items.map((child) => (_jsx("li", { className: "flex", children: _jsx(PanelLink, { active: !isExternal(child) && isActive(child.href), product: child }) }, child.href))) })] }, section.heading))) }) }) })] }));
|
|
50
50
|
};
|
|
51
|
-
export const DesktopMenu = ({ items, className }) => {
|
|
51
|
+
export const DesktopMenu = ({ items, className, variant, }) => {
|
|
52
52
|
const isActive = useNavActive(items);
|
|
53
53
|
const [navOpen, setNavOpen] = useState(false);
|
|
54
|
-
return (_jsxs(_Fragment, { children: [_jsx(NavigationMenu, { "aria-label": "Primary navigation", delayDuration: 0, onValueChange: (value) => setNavOpen(Boolean(value)), skipDelayDuration: 0, viewport: false, children: _jsx(NavigationMenuList, { className: cn("h-16 items-stretch gap-0", className), children: items.map((item, index) => "items" in item ? (_jsx(DropdownNavItem, { first: index === 0, item: item, navItems: items }, item.label)) : (_jsx(NavigationMenuItem, { className: "flex", children: _jsx(NavigationMenuLink, { active: isActive(item.href), asChild: true, className: topLevelItemClassName(index === 0), children: item.href.startsWith("http") ? (_jsxs("a", { className: "flex flex-row items-center gap-1", href: item.href, rel: "noopener", target: "_blank", children: [item.label, _jsx(IconArrowUpRightSmall, { "aria-hidden": "true", className: cn(navOpen && "will-change-transform"), size: 12 })] })) : (_jsx(LocalizedLink, { href: item.href, prefetch: item.prefetch, children: item.label })) }) }, item.href))) }) }), _jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none fixed inset-x-0 top-16 bottom-0 z-0 bg-background-200/60", navOpen ? "opacity-100" : "opacity-0") })] }));
|
|
54
|
+
return (_jsxs(_Fragment, { children: [_jsx(NavigationMenu, { "aria-label": "Primary navigation", delayDuration: 0, onValueChange: (value) => setNavOpen(Boolean(value)), skipDelayDuration: 0, viewport: false, children: _jsx(NavigationMenuList, { className: cn("h-16 items-stretch gap-0", className), children: items.map((item, index) => "items" in item ? (_jsx(DropdownNavItem, { first: index === 0, item: item, navItems: items, variant: variant }, item.label)) : (_jsx(NavigationMenuItem, { className: "flex", children: _jsx(NavigationMenuLink, { active: isActive(item.href), asChild: true, className: topLevelItemClassName(index === 0, variant), children: item.href.startsWith("http") ? (_jsxs("a", { className: "flex flex-row items-center gap-1", href: item.href, rel: "noopener", target: "_blank", children: [item.label, _jsx(IconArrowUpRightSmall, { "aria-hidden": "true", className: cn(navOpen && "will-change-transform"), size: 12 })] })) : (_jsx(LocalizedLink, { href: item.href, prefetch: item.prefetch, children: item.label })) }) }, item.href))) }) }), _jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none fixed inset-x-0 top-16 bottom-0 z-0 bg-background-200/60", navOpen ? "opacity-100" : "opacity-0") })] }));
|
|
55
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navbar-brand.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/navbar-brand.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG1E,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,OAAO,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC5C;AAED,eAAO,MAAM,WAAW,GAAI,qBAGzB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"navbar-brand.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/navbar-brand.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG1E,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,OAAO,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC5C;AAED,eAAO,MAAM,WAAW,GAAI,qBAGzB,gBAAgB,4CAwClB,CAAC"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Link from "next/link";
|
|
3
3
|
import { LogoVercelLabs } from "./logo-vercel-labs";
|
|
4
|
-
export const NavbarBrand = ({ brand = "vercel", variant = "
|
|
5
|
-
let label = "Vercel";
|
|
6
|
-
let href = "https://vercel.com/";
|
|
4
|
+
export const NavbarBrand = ({ brand = "vercel", variant = "oss", }) => {
|
|
5
|
+
let label = variant === "oss" ? "Vercel Open Source" : "Vercel";
|
|
6
|
+
let href = variant === "oss" ? "https://vercel.com/oss" : "https://vercel.com/home";
|
|
7
7
|
let logo = (_jsx("svg", { "aria-hidden": "true", focusable: "false", height: "18", viewBox: "0 0 115 100", width: "21", children: _jsx("g", { children: _jsx("path", { clipRule: "evenodd", d: "M57.5 0 115 100H0z", fill: "currentColor", fillRule: "evenodd" }) }) }));
|
|
8
8
|
if (brand === "labs") {
|
|
9
9
|
label = "Vercel Labs";
|
|
10
10
|
href = "https://vercel.com/labs";
|
|
11
11
|
logo = _jsx(LogoVercelLabs, {});
|
|
12
12
|
}
|
|
13
|
-
else if (variant === "oss") {
|
|
14
|
-
label = "Vercel Open Source";
|
|
15
|
-
href = "https://vercel.com/oss";
|
|
16
|
-
}
|
|
17
13
|
return (_jsx(Link, { "aria-label": label, className: "-mx-2 flex items-center rounded-md p-2 text-gray-1000 outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-inset", href: href, rel: "noopener", target: "_blank", children: logo }));
|
|
18
14
|
};
|
|
@@ -39,7 +39,7 @@ type NavbarLogoProps = {
|
|
|
39
39
|
variant: "oss";
|
|
40
40
|
} | {
|
|
41
41
|
logo: ReactNode;
|
|
42
|
-
variant?: "
|
|
42
|
+
variant?: "vercel";
|
|
43
43
|
});
|
|
44
44
|
export declare function NavbarLogo({ brandMark, className, href, ...props }: NavbarLogoProps): import("react/jsx-runtime").JSX.Element;
|
|
45
45
|
export {};
|
|
@@ -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;AAW9D,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAEjD,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,EAuF3D,CAAC;AAqBF;;;;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,GAChC,yBAAyB,EAAE,CAI7B;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,CAAC;CAChB,GACD;IACE,IAAI,EA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,EACT,EAAE,eAAe,2CAmMjB"}
|
|
@@ -186,7 +186,7 @@ export function NavbarLogo({ brandMark, className, href = "/", ...props }) {
|
|
|
186
186
|
}
|
|
187
187
|
}, [pathname]);
|
|
188
188
|
useEffect(() => () => window.clearTimeout(pointerLeaveTimeoutRef.current), []);
|
|
189
|
-
return (_jsxs("span", { className: cn("flex items-center gap-2.5", className), children: [brandMark, _jsx("div", { className: "w-5 text-center text-gray-alpha-400 text-lg dark:text-gray-600", children: _jsx(IconSlashForward, { size: 20 }) }),
|
|
189
|
+
return (_jsxs("span", { className: cn("flex items-center gap-2.5", className), children: [brandMark, isOss ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "w-5 text-center text-gray-alpha-400 text-lg dark:text-gray-600", children: _jsx(IconSlashForward, { size: 20 }) }), _jsx(Link, { className: "flex @min-[1024px]:hidden items-center text-gray-1000", href: localizedHref, prefetch: true, children: props.logo }), _jsxs("div", { className: "@min-[1024px]:contents hidden", children: [_jsx(NavigationMenu, { "aria-label": "Product navigation", delayDuration: 0, onValueChange: (value) => {
|
|
190
190
|
if (value && suppressLogoHoverRef.current) {
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
@@ -222,5 +222,5 @@ export function NavbarLogo({ brandMark, className, href = "/", ...props }) {
|
|
|
222
222
|
}, onMouseEnter: () => {
|
|
223
223
|
cancelPointerLeave();
|
|
224
224
|
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: "min-w-[180px] shrink-0", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: section.heading }), _jsx("ul", { className: "mt-[5px] flex list-none flex-col", children: section.items.map((product) => (_jsx("li", { className: "flex", children: _jsx(PanelLink, { product: product }) }, product.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") })] })] })) :
|
|
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: "min-w-[180px] shrink-0", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: section.heading }), _jsx("ul", { className: "mt-[5px] flex list-none flex-col", children: section.items.map((product) => (_jsx("li", { className: "flex", children: _jsx(PanelLink, { product: product }) }, product.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
226
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type SortedResult } from "fumadocs-core/search/server";
|
|
2
|
+
export declare const prepareSearchQuery: (query: string, locale: string) => string;
|
|
3
|
+
interface SearchPage {
|
|
4
|
+
breadcrumbs?: string[];
|
|
5
|
+
content: string;
|
|
6
|
+
description: string;
|
|
7
|
+
keywords?: string[];
|
|
8
|
+
title: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
/** Prepare immutable ranking data once, alongside the Orama indexes. */
|
|
12
|
+
export declare const prepareSearchIndex: (pages: SearchPage[], locale: string) => {
|
|
13
|
+
pages: {
|
|
14
|
+
title: string;
|
|
15
|
+
url: string;
|
|
16
|
+
breadcrumbs: string[] | undefined;
|
|
17
|
+
normalizedTitle: string;
|
|
18
|
+
normalizedKeywords: string[];
|
|
19
|
+
searchTitle: string;
|
|
20
|
+
searchKeywords: string[];
|
|
21
|
+
words: string[];
|
|
22
|
+
}[];
|
|
23
|
+
byUrl: Map<string, {
|
|
24
|
+
title: string;
|
|
25
|
+
url: string;
|
|
26
|
+
breadcrumbs: string[] | undefined;
|
|
27
|
+
normalizedTitle: string;
|
|
28
|
+
normalizedKeywords: string[];
|
|
29
|
+
searchTitle: string;
|
|
30
|
+
searchKeywords: string[];
|
|
31
|
+
words: string[];
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
type SearchIndex = ReturnType<typeof prepareSearchIndex>;
|
|
35
|
+
/** Rank pages independently of the incidental snippets displayed beneath them. */
|
|
36
|
+
export declare const rankSearchResults: ({ index, locale, pageResults, query, sectionResults, tagged, }: {
|
|
37
|
+
index: SearchIndex;
|
|
38
|
+
locale: string;
|
|
39
|
+
pageResults: SortedResult[];
|
|
40
|
+
query: string;
|
|
41
|
+
sectionResults: SortedResult[];
|
|
42
|
+
tagged: boolean;
|
|
43
|
+
}) => SortedResult[];
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=search-ranking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-ranking.d.ts","sourceRoot":"","sources":["../../src/internal/search-ranking.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AAqCrC,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,WAY/D,CAAC;AAEF,UAAU,UAAU;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wEAAwE;AACxE,eAAO,MAAM,kBAAkB,GAAI,OAAO,UAAU,EAAE,EAAE,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;CA8BrE,CAAC;AAEF,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AA8DzD,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,GAAI,gEAO/B;IACD,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,YAAY,EAAE,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC;CACjB,KAAG,YAAY,EAgEf,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { createContentHighlighter, } from "fumadocs-core/search/server";
|
|
2
|
+
const PAGE_LIMIT = 20;
|
|
3
|
+
const SNIPPET_LIMIT = 2;
|
|
4
|
+
const PUNCTUATION = /[^\p{L}\p{N}]+/gu;
|
|
5
|
+
const WHITESPACE = /\s+/;
|
|
6
|
+
const ENGLISH_FILLER = new Set([
|
|
7
|
+
"a",
|
|
8
|
+
"an",
|
|
9
|
+
"and",
|
|
10
|
+
"are",
|
|
11
|
+
"as",
|
|
12
|
+
"at",
|
|
13
|
+
"be",
|
|
14
|
+
"by",
|
|
15
|
+
"for",
|
|
16
|
+
"from",
|
|
17
|
+
"how",
|
|
18
|
+
"i",
|
|
19
|
+
"in",
|
|
20
|
+
"is",
|
|
21
|
+
"it",
|
|
22
|
+
"of",
|
|
23
|
+
"on",
|
|
24
|
+
"the",
|
|
25
|
+
"to",
|
|
26
|
+
"use",
|
|
27
|
+
"using",
|
|
28
|
+
"with",
|
|
29
|
+
]);
|
|
30
|
+
const normalize = (value) => value.normalize("NFKC").toLowerCase().replace(PUNCTUATION, " ").trim();
|
|
31
|
+
const isEnglish = (locale) => locale === "en" || locale.startsWith("en-");
|
|
32
|
+
export const prepareSearchQuery = (query, locale) => {
|
|
33
|
+
if (!isEnglish(locale)) {
|
|
34
|
+
return query.trim();
|
|
35
|
+
}
|
|
36
|
+
return (query
|
|
37
|
+
.split(WHITESPACE)
|
|
38
|
+
.filter((word) => !ENGLISH_FILLER.has(word.toLowerCase()))
|
|
39
|
+
.join(" ")
|
|
40
|
+
.trim() || query.trim());
|
|
41
|
+
};
|
|
42
|
+
/** Prepare immutable ranking data once, alongside the Orama indexes. */
|
|
43
|
+
export const prepareSearchIndex = (pages, locale) => {
|
|
44
|
+
const normalizeMatch = (value) => normalize(prepareSearchQuery(value, locale));
|
|
45
|
+
const preparedPages = pages.map((page) => ({
|
|
46
|
+
title: page.title,
|
|
47
|
+
url: page.url,
|
|
48
|
+
breadcrumbs: page.breadcrumbs,
|
|
49
|
+
normalizedTitle: normalize(page.title),
|
|
50
|
+
normalizedKeywords: page.keywords?.map(normalize) ?? [],
|
|
51
|
+
searchTitle: normalizeMatch(page.title),
|
|
52
|
+
searchKeywords: page.keywords?.map(normalizeMatch) ?? [],
|
|
53
|
+
words: isEnglish(locale)
|
|
54
|
+
? Array.from(new Set(normalize([
|
|
55
|
+
page.title,
|
|
56
|
+
...(page.keywords ?? []),
|
|
57
|
+
page.description,
|
|
58
|
+
page.content,
|
|
59
|
+
].join(" ")).split(WHITESPACE))).sort()
|
|
60
|
+
: [],
|
|
61
|
+
}));
|
|
62
|
+
return {
|
|
63
|
+
pages: preparedPages,
|
|
64
|
+
byUrl: new Map(preparedPages.map((page) => [page.url, page])),
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
// A sorted vocabulary lets each query term check coverage without scanning
|
|
68
|
+
// every word of every candidate page. Use the same ordering as Array.sort().
|
|
69
|
+
const hasWordPrefix = (words, term) => {
|
|
70
|
+
let low = 0;
|
|
71
|
+
let high = words.length;
|
|
72
|
+
while (low < high) {
|
|
73
|
+
const middle = Math.floor((low + high) / 2);
|
|
74
|
+
if (words[middle] < term) {
|
|
75
|
+
low = middle + 1;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
high = middle;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return words[low]?.startsWith(term) ?? false;
|
|
82
|
+
};
|
|
83
|
+
const rankMetadataMatches = (pages, query, locale) => {
|
|
84
|
+
const normalizedQuery = normalize(query);
|
|
85
|
+
const normalizedSearchQuery = normalize(prepareSearchQuery(query, locale));
|
|
86
|
+
const highlighter = createContentHighlighter(query);
|
|
87
|
+
const exactTitles = [];
|
|
88
|
+
const exactKeywords = [];
|
|
89
|
+
const relaxedTitles = [];
|
|
90
|
+
const relaxedKeywords = [];
|
|
91
|
+
for (const page of pages) {
|
|
92
|
+
// Preserve every word for exact matches: "use cache" is not "cache".
|
|
93
|
+
let matches;
|
|
94
|
+
if (page.normalizedTitle === normalizedQuery) {
|
|
95
|
+
matches = exactTitles;
|
|
96
|
+
}
|
|
97
|
+
else if (page.normalizedKeywords.includes(normalizedQuery)) {
|
|
98
|
+
matches = exactKeywords;
|
|
99
|
+
}
|
|
100
|
+
else if (page.searchTitle === normalizedSearchQuery) {
|
|
101
|
+
matches = relaxedTitles;
|
|
102
|
+
}
|
|
103
|
+
else if (page.searchKeywords.includes(normalizedSearchQuery)) {
|
|
104
|
+
matches = relaxedKeywords;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
matches.push({
|
|
110
|
+
id: page.url,
|
|
111
|
+
type: "page",
|
|
112
|
+
content: page.title,
|
|
113
|
+
contentWithHighlights: highlighter.highlight(page.title),
|
|
114
|
+
breadcrumbs: page.breadcrumbs,
|
|
115
|
+
url: page.url,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return [
|
|
119
|
+
...exactTitles,
|
|
120
|
+
...exactKeywords,
|
|
121
|
+
...relaxedTitles,
|
|
122
|
+
...relaxedKeywords,
|
|
123
|
+
];
|
|
124
|
+
};
|
|
125
|
+
/** Rank pages independently of the incidental snippets displayed beneath them. */
|
|
126
|
+
export const rankSearchResults = ({ index, locale, pageResults, query, sectionResults, tagged, }) => {
|
|
127
|
+
const normalizedQuery = normalize(prepareSearchQuery(query, locale));
|
|
128
|
+
if (!normalizedQuery) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
const sections = new Map();
|
|
132
|
+
let pageId;
|
|
133
|
+
for (const result of sectionResults) {
|
|
134
|
+
if (result.type === "page") {
|
|
135
|
+
pageId = result.url;
|
|
136
|
+
sections.set(pageId, []);
|
|
137
|
+
}
|
|
138
|
+
else if (pageId) {
|
|
139
|
+
sections.get(pageId)?.push(result);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const terms = normalizedQuery.split(WHITESPACE);
|
|
143
|
+
const matchingPages = pageResults.filter((result) => {
|
|
144
|
+
// Orama counts distinct prefix expansions as separate keyword matches:
|
|
145
|
+
// outputType + outputFormat can satisfy a two-word query by themselves.
|
|
146
|
+
// Check actual term coverage before accepting English page candidates.
|
|
147
|
+
if (!isEnglish(locale)) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
const page = index.byUrl.get(result.url);
|
|
151
|
+
if (!page) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return terms.every((term) => hasWordPrefix(page.words, term));
|
|
155
|
+
});
|
|
156
|
+
const ranked = [
|
|
157
|
+
...rankMetadataMatches(index.pages, query, locale),
|
|
158
|
+
...matchingPages,
|
|
159
|
+
];
|
|
160
|
+
// Keep partial body matches available when no page matches the whole query.
|
|
161
|
+
if (ranked.length === 0) {
|
|
162
|
+
ranked.push(...sectionResults.filter((result) => result.type === "page"));
|
|
163
|
+
}
|
|
164
|
+
const orderedPages = new Map();
|
|
165
|
+
for (const result of ranked) {
|
|
166
|
+
if (!orderedPages.has(result.url) &&
|
|
167
|
+
(!tagged || sections.has(result.url))) {
|
|
168
|
+
orderedPages.set(result.url, result);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const coverage = (result) => {
|
|
172
|
+
const words = normalize(result.content).split(WHITESPACE);
|
|
173
|
+
return terms.filter((term) => words.some((word) => word.startsWith(term)))
|
|
174
|
+
.length;
|
|
175
|
+
};
|
|
176
|
+
return [...orderedPages.values()].slice(0, PAGE_LIMIT).flatMap((page) => {
|
|
177
|
+
const unique = new Map();
|
|
178
|
+
for (const section of sections.get(page.url) ?? []) {
|
|
179
|
+
unique.set(`${section.url}\n${section.content}`, section);
|
|
180
|
+
}
|
|
181
|
+
const snippets = [...unique.values()]
|
|
182
|
+
.sort((left, right) => coverage(right) - coverage(left))
|
|
183
|
+
.slice(0, SNIPPET_LIMIT);
|
|
184
|
+
return [page, ...snippets];
|
|
185
|
+
});
|
|
186
|
+
};
|
package/dist/navbar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../src/navbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAShD,UAAU,WAAW;IACnB,MAAM,EAAE,IAAI,CACV,eAAe,EACb,IAAI,GACJ,QAAQ,GACR,MAAM,GACN,UAAU,GACV,KAAK,GACL,qBAAqB,GACrB,aAAa,GACb,cAAc,GACd,mBAAmB,GACnB,eAAe,CAClB,CAAC;CACH;AAKD,eAAO,MAAM,MAAM,GAAI,YAAY,WAAW,
|
|
1
|
+
{"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../src/navbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAShD,UAAU,WAAW;IACnB,MAAM,EAAE,IAAI,CACV,eAAe,EACb,IAAI,GACJ,QAAQ,GACR,MAAM,GACN,UAAU,GACV,KAAK,GACL,qBAAqB,GACrB,aAAa,GACb,cAAc,GACd,mBAAmB,GACnB,eAAe,CAClB,CAAC;CACH;AAKD,eAAO,MAAM,MAAM,GAAI,YAAY,WAAW,4CAoF7C,CAAC"}
|
package/dist/navbar.js
CHANGED
|
@@ -10,7 +10,8 @@ import { NavbarShell } from "./internal/navbar/navbar-shell";
|
|
|
10
10
|
// "group hidden h-10 justify-between pr-1.5 text-gray-900 @min-[1024px]:flex @min-[1024px]:h-8 @min-[1024px]:w-[150px] [&_[data-slot=kbd]]:transition-colors group-hover:[&_[data-slot=kbd]]:text-gray-1000";
|
|
11
11
|
export const Navbar = ({ config }) => {
|
|
12
12
|
const nav = config.nav ?? [];
|
|
13
|
-
const
|
|
13
|
+
const configuredVariant = config.navbarVariant ?? "oss";
|
|
14
|
+
const variant = configuredVariant === "standard" ? "vercel" : configuredVariant;
|
|
14
15
|
const isOss = variant === "oss";
|
|
15
16
|
const showGithub = config.navbarGithub?.enabled !== false;
|
|
16
17
|
const buttonLabel = config.ai?.buttonLabel?.trim();
|
|
@@ -20,5 +21,5 @@ export const Navbar = ({ config }) => {
|
|
|
20
21
|
// and filtered inside the mobile menu.
|
|
21
22
|
const activeProduct = config.navbarActiveProduct;
|
|
22
23
|
const brandMark = (_jsx(NavbarBrand, { brand: config.navbarBrand, variant: variant }));
|
|
23
|
-
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: [isOss ? (_jsx(NavbarLogo, { activeProduct: activeProduct, brandMark: brandMark, className: "ml-4", href: config.logoHref, logo: config.logo, ossProducts: config.navbarOssProducts, variant: "oss" })) : (_jsx(NavbarLogo, { brandMark: brandMark, className: "ml-4", href: config.logoHref, logo: config.logo, variant: "
|
|
24
|
+
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: [isOss ? (_jsx(NavbarLogo, { activeProduct: activeProduct, brandMark: brandMark, className: "ml-4", href: config.logoHref, logo: config.logo, ossProducts: config.navbarOssProducts, variant: "oss" })) : (_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 })] }), _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, ossProducts: config.navbarOssProducts, showOss: isOss })] })] }) }));
|
|
24
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/routes/search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/routes/search.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAOjD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAEhF,KAAK,YAAY,GAAG,qBAAqB,CAAC;AAC1C,KAAK,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,KAAK,iBAAiB,GAAG,YAAY,GAAG,YAAY,CAAC;AAIrD,UAAU,wBAAwB;IAChC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,UAAU,CAAC,EAAE,mBAAmB,CAC9B,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAC5C,iBAAiB,CAClB,CAAC;IACF,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAiFD,eAAO,MAAM,iBAAiB,GAAI,0CAK/B,wBAAwB,MAqIX,SAAS,OAAO,sBA4B/B,CAAC"}
|
package/dist/routes/search.js
CHANGED
|
@@ -3,6 +3,8 @@ import { createTokenizer as createTokenizerMandarin } from "@orama/tokenizers/ma
|
|
|
3
3
|
import { defineI18n } from "fumadocs-core/i18n";
|
|
4
4
|
import { findPath } from "fumadocs-core/page-tree";
|
|
5
5
|
import { createI18nSearchAPI, } from "fumadocs-core/search/server";
|
|
6
|
+
import { resolveDocumentTitle } from "../internal/document-title";
|
|
7
|
+
import { prepareSearchIndex, prepareSearchQuery, rankSearchResults, } from "../internal/search-ranking";
|
|
6
8
|
import { isPageVisibleForSurface, } from "../page-visibility";
|
|
7
9
|
import { isGeistdocsSourceBundle } from "../source";
|
|
8
10
|
const getLanguages = (config) => {
|
|
@@ -92,8 +94,19 @@ export const createSearchRoute = ({ config, filterPage, source, sources, }) => {
|
|
|
92
94
|
const data = page.data;
|
|
93
95
|
return {
|
|
94
96
|
id: page.url,
|
|
95
|
-
title:
|
|
97
|
+
title: resolveDocumentTitle({
|
|
98
|
+
pageTitle: data.title ?? page.url,
|
|
99
|
+
pageUrl: page.url,
|
|
100
|
+
tree: pageTree,
|
|
101
|
+
}),
|
|
96
102
|
description: data.description ?? "",
|
|
103
|
+
keywords: data.keywords ?? [],
|
|
104
|
+
content: [
|
|
105
|
+
...(data.structuredData?.headings ?? []),
|
|
106
|
+
...(data.structuredData?.contents ?? []),
|
|
107
|
+
]
|
|
108
|
+
.map((section) => section.content)
|
|
109
|
+
.join("\n"),
|
|
97
110
|
breadcrumbs: getBreadcrumbs(pageTree, page.url),
|
|
98
111
|
locale,
|
|
99
112
|
structuredData: data.structuredData ?? {
|
|
@@ -104,9 +117,72 @@ export const createSearchRoute = ({ config, filterPage, source, sources, }) => {
|
|
|
104
117
|
};
|
|
105
118
|
});
|
|
106
119
|
}));
|
|
107
|
-
|
|
120
|
+
const indexes = getIndexes();
|
|
121
|
+
const rankingIndexes = new Map(languages.map((locale) => [
|
|
122
|
+
locale,
|
|
123
|
+
prepareSearchIndex(indexes.filter((page) => page.locale === locale), locale),
|
|
124
|
+
]));
|
|
125
|
+
const sections = createI18nSearchAPI("advanced", {
|
|
108
126
|
i18n,
|
|
109
|
-
indexes
|
|
127
|
+
indexes,
|
|
110
128
|
localeMap,
|
|
111
|
-
})
|
|
129
|
+
});
|
|
130
|
+
const pageSearch = {
|
|
131
|
+
// Page metadata must outweigh incidental mentions in paragraphs/tables.
|
|
132
|
+
boost: { title: 8, keywords: 6, description: 2, content: 1 },
|
|
133
|
+
properties: ["title", "keywords", "description", "content"],
|
|
134
|
+
// Retrieve all candidates; verify English term coverage during ranking.
|
|
135
|
+
threshold: 1,
|
|
136
|
+
tolerance: 0,
|
|
137
|
+
// Apply page limits after verifying query coverage and exact matches.
|
|
138
|
+
limit: indexes.length,
|
|
139
|
+
};
|
|
140
|
+
const pages = createI18nSearchAPI("simple", {
|
|
141
|
+
i18n,
|
|
142
|
+
localeMap: Object.fromEntries(Object.entries(localeMap).map(([locale, options]) => [
|
|
143
|
+
locale,
|
|
144
|
+
typeof options === "object"
|
|
145
|
+
? {
|
|
146
|
+
components: options.components,
|
|
147
|
+
search: {
|
|
148
|
+
...pageSearch,
|
|
149
|
+
threshold: options.search && "threshold" in options.search
|
|
150
|
+
? options.search.threshold
|
|
151
|
+
: pageSearch.threshold,
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
: options,
|
|
155
|
+
])),
|
|
156
|
+
indexes: indexes.map((page) => ({
|
|
157
|
+
...page,
|
|
158
|
+
keywords: page.keywords.join(" "),
|
|
159
|
+
})),
|
|
160
|
+
search: pageSearch,
|
|
161
|
+
});
|
|
162
|
+
return async (request) => {
|
|
163
|
+
const url = new URL(request.url);
|
|
164
|
+
if (url.searchParams.get("mode") === "vector") {
|
|
165
|
+
return sections.GET(request);
|
|
166
|
+
}
|
|
167
|
+
const locale = url.searchParams.get("locale") ?? defaultLanguage;
|
|
168
|
+
const query = url.searchParams.get("query") ?? "";
|
|
169
|
+
const searchQuery = prepareSearchQuery(query, locale);
|
|
170
|
+
const rankingIndex = rankingIndexes.get(locale);
|
|
171
|
+
if (!(searchQuery && rankingIndex)) {
|
|
172
|
+
return Response.json([]);
|
|
173
|
+
}
|
|
174
|
+
const tag = url.searchParams.get("tag")?.split(",");
|
|
175
|
+
const [pageResults, sectionResults] = await Promise.all([
|
|
176
|
+
pages.search(searchQuery, { locale }),
|
|
177
|
+
sections.search(searchQuery, { locale, tag }),
|
|
178
|
+
]);
|
|
179
|
+
return Response.json(rankSearchResults({
|
|
180
|
+
index: rankingIndex,
|
|
181
|
+
pageResults,
|
|
182
|
+
locale,
|
|
183
|
+
query,
|
|
184
|
+
sectionResults,
|
|
185
|
+
tagged: tag !== undefined && tag.length > 0,
|
|
186
|
+
}));
|
|
187
|
+
};
|
|
112
188
|
};
|
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.15.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.15.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
|
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.15.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.15.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
|
|
@@ -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. Brand selection
|
|
1247
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Brand selection is independent of `navbarVariant`, which selects the `"oss"` (default) or `"vercel"` layout; either supports both brands. The previous `"standard"` value remains supported as an alias for `"vercel"`. The OSS layout keeps your project's `Logo` and `logoHref` separate from the brand. The Vercel layout shows only the selected brand mark, with no separator, project logo, or OSS products 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
|
|
|
@@ -2534,6 +2534,21 @@ const Layout = ({ children }: LayoutProps) => (
|
|
|
2534
2534
|
|
|
2535
2535
|
The generated local adapter imports the package provider and passes your site config to it.
|
|
2536
2536
|
|
|
2537
|
+
## Search relevance
|
|
2538
|
+
|
|
2539
|
+
`createSearchRoute` ranks pages before selecting their matching sections. Exact page titles come first, followed by exact `keywords` aliases. These matches retain every query word, so `use cache` ranks ahead of `Cache` for that query. They precede matches with English filler words removed and full-page matches weighted toward titles, keywords, and descriptions. Section overview pages use their navigation folder name instead of the generic “Overview” title. Lower-priority English matching ignores common filler words such as “how to” and “using”; other locales keep their existing tokenizers.
|
|
2540
|
+
|
|
2541
|
+
Add a small set of search phrases to the canonical page's frontmatter:
|
|
2542
|
+
|
|
2543
|
+
```yaml
|
|
2544
|
+
title: Generating Structured Data
|
|
2545
|
+
keywords:
|
|
2546
|
+
- structured output
|
|
2547
|
+
- structured outputs
|
|
2548
|
+
```
|
|
2549
|
+
|
|
2550
|
+
Use phrases readers actually search for, and assign each alias to its canonical page. Avoid copying the same keywords onto every related page. English results must cover the whole query; if no page covers it, partial section matches remain available. Results contain at most 20 pages and two distinct matching snippets per page, retaining section links and breadcrumbs. Locale, visibility, and `filterPage` restrictions still apply.
|
|
2551
|
+
|
|
2537
2552
|
## Search scope
|
|
2538
2553
|
|
|
2539
2554
|
A search index partitioned by version, section, or product usually wants the dialog to answer from the partition the reader is in. Pass that scope as `search.options.tag`:
|
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. Brand selection
|
|
108
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Brand selection is independent of `navbarVariant`, which selects the `"oss"` (default) or `"vercel"` layout; either supports both brands. The previous `"standard"` value remains supported as an alias for `"vercel"`. The OSS layout keeps your project's `Logo` and `logoHref` separate from the brand. The Vercel layout shows only the selected brand mark, with no separator, project logo, or OSS products 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
|
|
package/docs/pages/provider.md
CHANGED
|
@@ -50,6 +50,21 @@ const Layout = ({ children }: LayoutProps) => (
|
|
|
50
50
|
|
|
51
51
|
The generated local adapter imports the package provider and passes your site config to it.
|
|
52
52
|
|
|
53
|
+
## Search relevance
|
|
54
|
+
|
|
55
|
+
`createSearchRoute` ranks pages before selecting their matching sections. Exact page titles come first, followed by exact `keywords` aliases. These matches retain every query word, so `use cache` ranks ahead of `Cache` for that query. They precede matches with English filler words removed and full-page matches weighted toward titles, keywords, and descriptions. Section overview pages use their navigation folder name instead of the generic “Overview” title. Lower-priority English matching ignores common filler words such as “how to” and “using”; other locales keep their existing tokenizers.
|
|
56
|
+
|
|
57
|
+
Add a small set of search phrases to the canonical page's frontmatter:
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
title: Generating Structured Data
|
|
61
|
+
keywords:
|
|
62
|
+
- structured output
|
|
63
|
+
- structured outputs
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Use phrases readers actually search for, and assign each alias to its canonical page. Avoid copying the same keywords onto every related page. English results must cover the whole query; if no page covers it, partial section matches remain available. Results contain at most 20 pages and two distinct matching snippets per page, retaining section links and breadcrumbs. Locale, visibility, and `filterPage` restrictions still apply.
|
|
67
|
+
|
|
53
68
|
## Search scope
|
|
54
69
|
|
|
55
70
|
A search index partitioned by version, section, or product usually wants the dialog to answer from the partition the reader is in. Pass that scope as `search.options.tag`:
|
package/package.json
CHANGED
|
@@ -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. Brand selection
|
|
106
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Brand selection is independent of `navbarVariant`, which selects the `"oss"` (default) or `"vercel"` layout; either supports both brands. The previous `"standard"` value remains supported as an alias for `"vercel"`. The OSS layout keeps your project's `Logo` and `logoHref` separate from the brand. The Vercel layout shows only the selected brand mark, with no separator, project logo, or OSS products 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
|
|
|
@@ -48,6 +48,21 @@ const Layout = ({ children }: LayoutProps) => (
|
|
|
48
48
|
|
|
49
49
|
The generated local adapter imports the package provider and passes your site config to it.
|
|
50
50
|
|
|
51
|
+
## Search relevance
|
|
52
|
+
|
|
53
|
+
`createSearchRoute` ranks pages before selecting their matching sections. Exact page titles come first, followed by exact `keywords` aliases. These matches retain every query word, so `use cache` ranks ahead of `Cache` for that query. They precede matches with English filler words removed and full-page matches weighted toward titles, keywords, and descriptions. Section overview pages use their navigation folder name instead of the generic “Overview” title. Lower-priority English matching ignores common filler words such as “how to” and “using”; other locales keep their existing tokenizers.
|
|
54
|
+
|
|
55
|
+
Add a small set of search phrases to the canonical page's frontmatter:
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
title: Generating Structured Data
|
|
59
|
+
keywords:
|
|
60
|
+
- structured output
|
|
61
|
+
- structured outputs
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Use phrases readers actually search for, and assign each alias to its canonical page. Avoid copying the same keywords onto every related page. English results must cover the whole query; if no page covers it, partial section matches remain available. Results contain at most 20 pages and two distinct matching snippets per page, retaining section links and breadcrumbs. Locale, visibility, and `filterPage` restrictions still apply.
|
|
65
|
+
|
|
51
66
|
## Search scope
|
|
52
67
|
|
|
53
68
|
A search index partitioned by version, section, or product usually wants the dialog to answer from the partition the reader is in. Pass that scope as `search.options.tag`:
|
package/template/package.json
CHANGED