@vercel/geistdocs 1.11.4 → 1.13.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/controls.d.ts.map +1 -1
- package/dist/controls.js +7 -5
- package/dist/home-layout.d.ts.map +1 -1
- package/dist/home-layout.js +2 -7
- package/dist/internal/page-actions-client.d.ts +7 -3
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +82 -67
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +1 -1
- package/dist/internal/sidebar-responsive.d.ts +3 -0
- package/dist/internal/sidebar-responsive.d.ts.map +1 -0
- package/dist/internal/sidebar-responsive.js +10 -0
- package/dist/internal/sidebar-tree.d.ts +23 -0
- package/dist/internal/sidebar-tree.d.ts.map +1 -0
- package/dist/internal/sidebar-tree.js +115 -0
- package/dist/internal/sidebar.d.ts +2 -5
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +282 -44
- package/dist/internal/table-of-contents.d.ts +2 -1
- package/dist/internal/table-of-contents.d.ts.map +1 -1
- package/dist/internal/table-of-contents.js +1 -1
- package/dist/internal/ui/button.d.ts.map +1 -1
- package/dist/internal/ui/button.js +4 -4
- package/dist/internal/ui/dropdown-menu.js +4 -4
- package/dist/internal/ui/popover.js +1 -1
- package/dist/internal/ui/sheet.d.ts.map +1 -1
- package/dist/internal/ui/sheet.js +2 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +1 -6
- package/dist/mdx.d.ts +1 -0
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mobile-docs-bar.d.ts.map +1 -1
- package/dist/mobile-docs-bar.js +3 -3
- package/dist/navbar.js +1 -1
- package/dist/pages/docs.d.ts +3 -1
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +16 -10
- package/dist/source-config.d.ts +1 -0
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +1 -0
- package/dist/source.d.ts +1 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +21 -2
- package/dist/versions.d.ts.map +1 -1
- package/dist/versions.js +3 -3
- package/docs/agents.md +2 -2
- package/docs/llms.txt +203 -32
- package/docs/manifest.json +10 -9
- package/docs/pages/configuration.md +9 -2
- package/docs/pages/getting-started.md +2 -0
- package/docs/pages/guides/nested-navigation.md +174 -13
- package/docs/pages/syntax.md +2 -1
- package/docs/sitemap.md +1 -1
- package/package.json +1 -1
- package/source-config.js +1 -0
- package/template/app/styles/geistdocs.css +8 -6
- package/template/content/docs/configuration.mdx +9 -2
- package/template/content/docs/getting-started.mdx +2 -0
- package/template/content/docs/guides/nested-navigation.mdx +174 -12
- package/template/content/docs/syntax.mdx +2 -1
- package/template/package.json +1 -1
- package/theme.css +150 -0
package/dist/cli/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{program as T}from"commander";import{access as ce,copyFile as le}from"fs/promises";import{join as pe}from"path";import{cancel as de,intro as ge,isCancel as ue,log as fe,outro as me,spinner as he,text as we}from"@clack/prompts";import{spawn as te}from"child_process";import{readFileSync as se}from"fs";import{cp as ne,readFile as ae,rename as re,writeFile as ie}from"fs/promises";import{join as $}from"path";import{fileURLToPath as oe}from"url";var g="@vercel/geistdocs",m=(e,t=[],s={})=>new Promise((n,a)=>{let r=te(e,t,{stdio:"inherit",...s});r.on("error",a),r.on("close",i=>{if(i===0){n();return}a(new Error(`Command failed with exit code ${i}: ${[e,...t].join(" ")}`))})}),A=["dependencies","devDependencies","optionalDependencies","peerDependencies"],_=()=>JSON.parse(se(new URL("../../package.json",import.meta.url),"utf8")).version,P=async e=>{let t=$(e,"package.json"),s=await ae(t,"utf8");return JSON.parse(s)},x=async(e,t)=>{let s=$(e,"package.json");await ie(s,`${JSON.stringify(t,null,2)}
|
|
3
|
-
`,"utf8")},R=(e,t)=>{for(let s of A){let n=e[s];if(n&&t in n)return n[t]}},V=(e,t)=>!!R(e,t),b=(e,t,s)=>{let n=!1;for(let a of A){let r=e[a];r&&t in r&&(r[t]=s,n=!0)}return n},j=()=>oe(new URL("../../template",import.meta.url)),F=async e=>{await ne(j(),e,{recursive:!0});let t=$(e,".gitignore"),s=$(e,"_gitignore");try{await re(s,t)}catch{}};var ye=async e=>{await F(e)},Pe=async e=>{try{return await ce(e),!0}catch{return!1}},ve=async()=>{await Pe(".env.example")&&await le(".env.example",".env.local")},Te=async e=>{let t=await P(e),s=_();return b(t,g,s)?(await x(e,t),!0):!1},ke=async e=>{await m("pnpm",["install"],{cwd:e,env:process.env,stdio:"inherit"})},$e=async e=>{await m("git",["init"],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["add","."],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["commit","-m","\u2728 Initial commit"],{cwd:e,env:process.env,stdio:"inherit"})},xe=async()=>{let e=await we({message:"What is your project named?",placeholder:"my-app",validate(t){if(t.length===0)return"Please enter a project name."}});return ue(e)&&(de("Operation cancelled."),process.exit(0)),e.toString()},G=async e=>{try{ge("Let's start a Geistdocs project!");let t=process.cwd(),s=e.name||await xe(),n=he(),a=pe(t,s);n.start("Copying bundled template..."),await ye(s),n.message("Setting up environment variables..."),process.chdir(a),await ve(),n.message("Rewriting package dependency versions..."),await Te(a),n.message("Installing dependencies..."),await ke(a),e.disableGit||(n.message("Initializing Git repository..."),await $e(a)),n.stop("Project initialized successfully!"),me("Run `pnpm dev` to start the development server.")}catch(t){let s=t instanceof Error?t.message:`Failed to initialize project: ${t}`;fe.error(s),process.exit(1)}};import{readFileSync as be,writeFileSync as Fe}from"fs";import{mkdir as De,readFile as N,writeFile as Se}from"fs/promises";import{dirname as Ce,extname as Re,relative as M,resolve as S}from"path";import{intro as je,isCancel as Ee,log as h,multiselect as Ne,outro as D,spinner as Ue}from"@clack/prompts";import{glob as Oe}from"glob";import{Node as v,Project as Ie,SyntaxKind as Je}from"ts-morph";var Le="geistdocs.tsx",Ae="content/docs/**/*.mdx",U=".translation-cache.json",E=8,B=()=>({version:1,entries:{}}),_e=async e=>{let t=await N(e),{createHash:s}=await import("crypto");return s("sha256").update(t).digest("hex")},Ve=e=>{let t=S(process.cwd(),e);return be(t,"utf8")},z=e=>v.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(v.isPropertyAssignment(t)){let s=t.getNameNode();if(v.isIdentifier(s)||v.isStringLiteral(s))return[s.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Ge=e=>{try{let t=new Ie({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),s=Ve(e),r=t.createSourceFile(e,s,{overwrite:!0}).getVariableDeclarations().find(l=>l.getName()==="translations")?.getInitializer();if(!r)return[];if(v.isObjectLiteralExpression(r))return z(r);let i=r.getFirstDescendantByKind(Je.ObjectLiteralExpression);return i?z(i):[]}catch(t){let s=t instanceof Error?t.message:`${t}`;return h.warn(`Failed to read locales from ${e}: ${s}`),[]}},Be=async()=>{let e=await Ne({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ee(e)&&(D("Translation cancelled"),process.exit(0)),e},ze=async e=>(await Oe(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),He=async()=>{let e=S(process.cwd(),U);try{let t=await N(e,"utf8"),s=JSON.parse(t);return s.version!==1||!s.entries?B():{version:1,entries:s.entries}}catch{return B()}},H=e=>{let t=S(process.cwd(),U),s=JSON.stringify(e,null,2);Fe(t,s,"utf8")},Me=async e=>{let t=await Promise.all(e.map(async s=>[s,await _e(s)]));return Object.fromEntries(t)},Ke=(e,t)=>{let s=Re(e);return`${e.slice(0,-s.length)}.${t}${s}`},K=(e,t)=>`${M(process.cwd(),e)}::${t}`,qe=(e,t,s,n,a=!1)=>{let r=[],i=0;for(let l of t){let c=s[l];for(let o of e){let d=Ke(l,o),u=K(l,o),f=n.entries[u];if(!a&&f?.hash===c){i+=1;continue}r.push({locale:o,sourceFile:l,sourceHash:c,targetFile:d})}}return{tasks:r,skippedCount:i}},Xe=async e=>{await De(Ce(e),{recursive:!0})},We=async(e,t,s)=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:s})});if(!n.ok){let r=await n.text();throw new Error(`API request failed (${n.status}): ${r}`)}let a=await n.json();if(!a.translation)throw new Error("API response did not include a translation");return a.translation},Ye=async(e,t,s)=>{let n=await N(e.sourceFile,"utf8"),a=await We(t,n,e.locale);await Xe(e.targetFile),await Se(e.targetFile,a,"utf8"),s.entries[K(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},q=async(e,t)=>{je("Translate MDX content");let s=e??Ae,n=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",a=Ge(t.config??Le),r=await ze(s);r.length===0&&(h.error(`No MDX files found matching pattern: ${s}`),D("Translation cancelled"),process.exit(1)),h.info(`Found ${r.length} MDX file(s) matching pattern`),a.length===0&&(a=await Be());let i=S(process.cwd(),U),l=await He();await H(l),h.info(`Using cache: ${i}`);let c=await Me(r),{tasks:o,skippedCount:d}=qe(a,r,c,l,t.force);if(o.length===0){h.success("All translations are up to date!"),D(`Skipped ${d} file(s) (unchanged)`);return}let u=[];for(let y=0;y<o.length;y+=E)u.push(o.slice(y,y+E));h.info(`Processing ${o.length} translation(s) in ${u.length} batch(es) of up to ${E}`),d>0&&h.info(`Skipped ${d} translation(s) (unchanged)`);let f=Ue();f.start("Translating content...");let k=0;for(let y of u)await Promise.all(y.map(async L=>{await Ye(L,n,l),k+=1,f.message(`Translated ${k}/${o.length}: ${M(process.cwd(),L.targetFile)}`)})),await H(l);f.stop("Translation complete!"),D(`Created/updated ${o.length} file(s)`)};import{access as Ze,copyFile as Qe,mkdir as Z,rm as J}from"fs/promises";import{dirname as et,join as w}from"path";import{intro as tt,log as p,outro as C,spinner as Q}from"@clack/prompts";import{glob as st}from"glob";var nt=["**/*"],at=["content/docs/**"],O=".geistdocs-tmp",rt=async(e,t)=>{let s=w(e,t);await J(s,{recursive:!0,force:!0}),await Z(s,{recursive:!0})},I=async e=>await J(e,{recursive:!0,force:!0}),X=async(e,t,s)=>(await st(e,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),it=async e=>{try{return await Ze(e),!0}catch{return!1}},ot=async(e,t,s)=>{let n=w(t,e),a=w(s,e);return await it(n)?(await Qe(n,a),{success:!0}):{success:!1,error:`Source file not found: ${n}`}},ct=async(e,t)=>{let s=w(t,e);return await J(s,{force:!0}),{success:!0}},W=20,Y=async(e,t,s)=>{let n=[];for(let a=0;a<e.length;a+=s){let r=e.slice(a,a+s),i=await Promise.all(r.map(t));n.push(...i)}return n},lt=async(e,t,s,n,a)=>{let r={success:[],deleted:[],failed:[]},i=[...new Set(e.map(c=>et(w(n,c))))];a.message(`Creating ${i.length} directories...`),await Promise.all(i.map(c=>Z(c,{recursive:!0}))),a.message(`Updating ${e.length} files...`);let l=await Y(e,async c=>{let o=await ot(c,s,n);return{file:c,...o}},W);for(let{file:c,success:o,error:d}of l)o?r.success.push(c):r.failed.push({file:c,error:d??"Unknown error"});if(t.length>0){a.message(`Deleting ${t.length} files...`);let c=await Y(t,async o=>{try{return await ct(o,n),{file:o,success:!0}}catch(d){let u=d instanceof Error?d.message:`${d}`;return{file:o,success:!1,error:u}}},W);for(let o of c)o.success?r.deleted.push(o.file):r.failed.push({file:o.file,error:o.error})}return r},pt=e=>{if(e.success.length>0){p.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)p.info(` \u2713 ${t}`)}if(e.deleted.length>0){p.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)p.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){p.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:s}of e.failed)p.error(` \u2717 ${t}: ${s}`)}},dt=e=>e.includes("canary")?"canary":"latest",gt=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(g)}`);if(!t.ok)throw new Error(`Failed to resolve ${g}@${e}`);let n=(await t.json())["dist-tags"]?.[e];if(!n)throw new Error(`Could not find dist-tag ${e} for ${g}`);return n},ut=async e=>{let t=await P(e),s=R(t,g);if(!s)return{currentVersion:s,nextVersion:void 0,updated:!1};let n=dt(s),a=await gt(n);return s===a?{currentVersion:s,nextVersion:a,updateTag:n,updated:!1}:(b(t,g,a),await x(e,t),{currentVersion:s,nextVersion:a,updateTag:n,updated:!0})},ft=async(e,t,s)=>{let n=await P(e);if(!V(n,g))return!1;t&&t.length>0&&p.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),s?.sync&&p.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:a,nextVersion:r,updateTag:i,updated:l}=await ut(e);if(!l)return p.success(a?`@vercel/geistdocs is already at ${r} (${i}).`:"No package version update was needed."),C("Package-based site is already up to date."),!0;p.info(`Bumping ${g} from ${a} to ${r} (${i})`);let c=Q();return c.start("Installing updated package version..."),await m("pnpm",["install"],{cwd:e}),c.stop("Package update complete!"),C("Please review and test the upgraded package version."),!0},mt=async(e,t,s,n,a)=>{let r=w(e,O),i=Q(),l=a?.sync?r:t;i.start("Preparing template snapshot..."),a?.sync&&(await rt(e,O),await F(r)),i.message("Scanning for files...");let c=await X(s,n,l),o=[];if(a?.sync){i.message("Comparing with local files...");let u=await X(s,n,e),f=new Set(c);o=u.filter(k=>!f.has(k))}if(i.stop(`Found ${c.length} files to update`),c.length===0&&o.length===0){p.warn("No files matched the patterns. Nothing to update."),a?.sync&&await I(r),C("Update cancelled.");return}p.info(`Patterns: ${s.length}`),p.info(`Files to update: ${c.length}`),a?.sync&&p.info(`Files to delete: ${o.length}`),i.start("Updating files...");let d=await lt(c,o,l,e,i);a?.sync&&(i.message("Cleaning up..."),await I(r)),i.stop("Update complete!"),pt(d),C("Please review and test the changes carefully.")},ee=async(e,t)=>{let s=process.cwd(),n=j(),a=e&&e.length>0?e:nt,r=e&&e.length>0?[]:at;try{if(tt("Let's update your Geistdocs project!"),await ft(s,e,t))return;p.info("Template source: bundled package snapshot"),e&&e.length>0&&p.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&p.info("Sync mode enabled: will delete files removed from template"),await mt(s,n,a,r,t)}catch(i){let l=i instanceof Error?i.message:`${i}`;try{await I(w(s,O))}catch{}p.error(`Failed to update project: ${l}`),process.exit(1)}};T.name("geistdocs").description("CLI for Geistdocs projects").version("1.11.4","-v, --version","Output the current version");T.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(G);T.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(ee);T.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(q);T.parse(process.argv);
|
|
3
|
+
`,"utf8")},R=(e,t)=>{for(let s of A){let n=e[s];if(n&&t in n)return n[t]}},V=(e,t)=>!!R(e,t),b=(e,t,s)=>{let n=!1;for(let a of A){let r=e[a];r&&t in r&&(r[t]=s,n=!0)}return n},j=()=>oe(new URL("../../template",import.meta.url)),F=async e=>{await ne(j(),e,{recursive:!0});let t=$(e,".gitignore"),s=$(e,"_gitignore");try{await re(s,t)}catch{}};var ye=async e=>{await F(e)},Pe=async e=>{try{return await ce(e),!0}catch{return!1}},ve=async()=>{await Pe(".env.example")&&await le(".env.example",".env.local")},Te=async e=>{let t=await P(e),s=_();return b(t,g,s)?(await x(e,t),!0):!1},ke=async e=>{await m("pnpm",["install"],{cwd:e,env:process.env,stdio:"inherit"})},$e=async e=>{await m("git",["init"],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["add","."],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["commit","-m","\u2728 Initial commit"],{cwd:e,env:process.env,stdio:"inherit"})},xe=async()=>{let e=await we({message:"What is your project named?",placeholder:"my-app",validate(t){if(t.length===0)return"Please enter a project name."}});return ue(e)&&(de("Operation cancelled."),process.exit(0)),e.toString()},G=async e=>{try{ge("Let's start a Geistdocs project!");let t=process.cwd(),s=e.name||await xe(),n=he(),a=pe(t,s);n.start("Copying bundled template..."),await ye(s),n.message("Setting up environment variables..."),process.chdir(a),await ve(),n.message("Rewriting package dependency versions..."),await Te(a),n.message("Installing dependencies..."),await ke(a),e.disableGit||(n.message("Initializing Git repository..."),await $e(a)),n.stop("Project initialized successfully!"),me("Run `pnpm dev` to start the development server.")}catch(t){let s=t instanceof Error?t.message:`Failed to initialize project: ${t}`;fe.error(s),process.exit(1)}};import{readFileSync as be,writeFileSync as Fe}from"fs";import{mkdir as De,readFile as N,writeFile as Se}from"fs/promises";import{dirname as Ce,extname as Re,relative as M,resolve as S}from"path";import{intro as je,isCancel as Ee,log as h,multiselect as Ne,outro as D,spinner as Ue}from"@clack/prompts";import{glob as Oe}from"glob";import{Node as v,Project as Ie,SyntaxKind as Je}from"ts-morph";var Le="geistdocs.tsx",Ae="content/docs/**/*.mdx",U=".translation-cache.json",E=8,B=()=>({version:1,entries:{}}),_e=async e=>{let t=await N(e),{createHash:s}=await import("crypto");return s("sha256").update(t).digest("hex")},Ve=e=>{let t=S(process.cwd(),e);return be(t,"utf8")},z=e=>v.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(v.isPropertyAssignment(t)){let s=t.getNameNode();if(v.isIdentifier(s)||v.isStringLiteral(s))return[s.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Ge=e=>{try{let t=new Ie({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),s=Ve(e),r=t.createSourceFile(e,s,{overwrite:!0}).getVariableDeclarations().find(l=>l.getName()==="translations")?.getInitializer();if(!r)return[];if(v.isObjectLiteralExpression(r))return z(r);let i=r.getFirstDescendantByKind(Je.ObjectLiteralExpression);return i?z(i):[]}catch(t){let s=t instanceof Error?t.message:`${t}`;return h.warn(`Failed to read locales from ${e}: ${s}`),[]}},Be=async()=>{let e=await Ne({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ee(e)&&(D("Translation cancelled"),process.exit(0)),e},ze=async e=>(await Oe(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),He=async()=>{let e=S(process.cwd(),U);try{let t=await N(e,"utf8"),s=JSON.parse(t);return s.version!==1||!s.entries?B():{version:1,entries:s.entries}}catch{return B()}},H=e=>{let t=S(process.cwd(),U),s=JSON.stringify(e,null,2);Fe(t,s,"utf8")},Me=async e=>{let t=await Promise.all(e.map(async s=>[s,await _e(s)]));return Object.fromEntries(t)},Ke=(e,t)=>{let s=Re(e);return`${e.slice(0,-s.length)}.${t}${s}`},K=(e,t)=>`${M(process.cwd(),e)}::${t}`,qe=(e,t,s,n,a=!1)=>{let r=[],i=0;for(let l of t){let c=s[l];for(let o of e){let d=Ke(l,o),u=K(l,o),f=n.entries[u];if(!a&&f?.hash===c){i+=1;continue}r.push({locale:o,sourceFile:l,sourceHash:c,targetFile:d})}}return{tasks:r,skippedCount:i}},Xe=async e=>{await De(Ce(e),{recursive:!0})},We=async(e,t,s)=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:s})});if(!n.ok){let r=await n.text();throw new Error(`API request failed (${n.status}): ${r}`)}let a=await n.json();if(!a.translation)throw new Error("API response did not include a translation");return a.translation},Ye=async(e,t,s)=>{let n=await N(e.sourceFile,"utf8"),a=await We(t,n,e.locale);await Xe(e.targetFile),await Se(e.targetFile,a,"utf8"),s.entries[K(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},q=async(e,t)=>{je("Translate MDX content");let s=e??Ae,n=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",a=Ge(t.config??Le),r=await ze(s);r.length===0&&(h.error(`No MDX files found matching pattern: ${s}`),D("Translation cancelled"),process.exit(1)),h.info(`Found ${r.length} MDX file(s) matching pattern`),a.length===0&&(a=await Be());let i=S(process.cwd(),U),l=await He();await H(l),h.info(`Using cache: ${i}`);let c=await Me(r),{tasks:o,skippedCount:d}=qe(a,r,c,l,t.force);if(o.length===0){h.success("All translations are up to date!"),D(`Skipped ${d} file(s) (unchanged)`);return}let u=[];for(let y=0;y<o.length;y+=E)u.push(o.slice(y,y+E));h.info(`Processing ${o.length} translation(s) in ${u.length} batch(es) of up to ${E}`),d>0&&h.info(`Skipped ${d} translation(s) (unchanged)`);let f=Ue();f.start("Translating content...");let k=0;for(let y of u)await Promise.all(y.map(async L=>{await Ye(L,n,l),k+=1,f.message(`Translated ${k}/${o.length}: ${M(process.cwd(),L.targetFile)}`)})),await H(l);f.stop("Translation complete!"),D(`Created/updated ${o.length} file(s)`)};import{access as Ze,copyFile as Qe,mkdir as Z,rm as J}from"fs/promises";import{dirname as et,join as w}from"path";import{intro as tt,log as p,outro as C,spinner as Q}from"@clack/prompts";import{glob as st}from"glob";var nt=["**/*"],at=["content/docs/**"],O=".geistdocs-tmp",rt=async(e,t)=>{let s=w(e,t);await J(s,{recursive:!0,force:!0}),await Z(s,{recursive:!0})},I=async e=>await J(e,{recursive:!0,force:!0}),X=async(e,t,s)=>(await st(e,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),it=async e=>{try{return await Ze(e),!0}catch{return!1}},ot=async(e,t,s)=>{let n=w(t,e),a=w(s,e);return await it(n)?(await Qe(n,a),{success:!0}):{success:!1,error:`Source file not found: ${n}`}},ct=async(e,t)=>{let s=w(t,e);return await J(s,{force:!0}),{success:!0}},W=20,Y=async(e,t,s)=>{let n=[];for(let a=0;a<e.length;a+=s){let r=e.slice(a,a+s),i=await Promise.all(r.map(t));n.push(...i)}return n},lt=async(e,t,s,n,a)=>{let r={success:[],deleted:[],failed:[]},i=[...new Set(e.map(c=>et(w(n,c))))];a.message(`Creating ${i.length} directories...`),await Promise.all(i.map(c=>Z(c,{recursive:!0}))),a.message(`Updating ${e.length} files...`);let l=await Y(e,async c=>{let o=await ot(c,s,n);return{file:c,...o}},W);for(let{file:c,success:o,error:d}of l)o?r.success.push(c):r.failed.push({file:c,error:d??"Unknown error"});if(t.length>0){a.message(`Deleting ${t.length} files...`);let c=await Y(t,async o=>{try{return await ct(o,n),{file:o,success:!0}}catch(d){let u=d instanceof Error?d.message:`${d}`;return{file:o,success:!1,error:u}}},W);for(let o of c)o.success?r.deleted.push(o.file):r.failed.push({file:o.file,error:o.error})}return r},pt=e=>{if(e.success.length>0){p.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)p.info(` \u2713 ${t}`)}if(e.deleted.length>0){p.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)p.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){p.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:s}of e.failed)p.error(` \u2717 ${t}: ${s}`)}},dt=e=>e.includes("canary")?"canary":"latest",gt=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(g)}`);if(!t.ok)throw new Error(`Failed to resolve ${g}@${e}`);let n=(await t.json())["dist-tags"]?.[e];if(!n)throw new Error(`Could not find dist-tag ${e} for ${g}`);return n},ut=async e=>{let t=await P(e),s=R(t,g);if(!s)return{currentVersion:s,nextVersion:void 0,updated:!1};let n=dt(s),a=await gt(n);return s===a?{currentVersion:s,nextVersion:a,updateTag:n,updated:!1}:(b(t,g,a),await x(e,t),{currentVersion:s,nextVersion:a,updateTag:n,updated:!0})},ft=async(e,t,s)=>{let n=await P(e);if(!V(n,g))return!1;t&&t.length>0&&p.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),s?.sync&&p.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:a,nextVersion:r,updateTag:i,updated:l}=await ut(e);if(!l)return p.success(a?`@vercel/geistdocs is already at ${r} (${i}).`:"No package version update was needed."),C("Package-based site is already up to date."),!0;p.info(`Bumping ${g} from ${a} to ${r} (${i})`);let c=Q();return c.start("Installing updated package version..."),await m("pnpm",["install"],{cwd:e}),c.stop("Package update complete!"),C("Please review and test the upgraded package version."),!0},mt=async(e,t,s,n,a)=>{let r=w(e,O),i=Q(),l=a?.sync?r:t;i.start("Preparing template snapshot..."),a?.sync&&(await rt(e,O),await F(r)),i.message("Scanning for files...");let c=await X(s,n,l),o=[];if(a?.sync){i.message("Comparing with local files...");let u=await X(s,n,e),f=new Set(c);o=u.filter(k=>!f.has(k))}if(i.stop(`Found ${c.length} files to update`),c.length===0&&o.length===0){p.warn("No files matched the patterns. Nothing to update."),a?.sync&&await I(r),C("Update cancelled.");return}p.info(`Patterns: ${s.length}`),p.info(`Files to update: ${c.length}`),a?.sync&&p.info(`Files to delete: ${o.length}`),i.start("Updating files...");let d=await lt(c,o,l,e,i);a?.sync&&(i.message("Cleaning up..."),await I(r)),i.stop("Update complete!"),pt(d),C("Please review and test the changes carefully.")},ee=async(e,t)=>{let s=process.cwd(),n=j(),a=e&&e.length>0?e:nt,r=e&&e.length>0?[]:at;try{if(tt("Let's update your Geistdocs project!"),await ft(s,e,t))return;p.info("Template source: bundled package snapshot"),e&&e.length>0&&p.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&p.info("Sync mode enabled: will delete files removed from template"),await mt(s,n,a,r,t)}catch(i){let l=i instanceof Error?i.message:`${i}`;try{await I(w(s,O))}catch{}p.error(`Failed to update project: ${l}`),process.exit(1)}};T.name("geistdocs").description("CLI for Geistdocs projects").version("1.13.0","-v, --version","Output the current version");T.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(G);T.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(ee);T.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(q);T.parse(process.argv);
|
package/dist/controls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,GAAI,wBAAwB,iBAAiB,4CAqBrE,CAAC;AAEF,eAAO,MAAM,WAAW,+
|
|
1
|
+
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,GAAI,wBAAwB,iBAAiB,4CAqBrE,CAAC;AAEF,eAAO,MAAM,WAAW,+CAsCvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDA+B5B,CAAC;AAEF,KAAK,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,0DAOzB,gBAAgB,mDA2BlB,CAAC"}
|
package/dist/controls.js
CHANGED
|
@@ -12,10 +12,10 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
|
|
|
12
12
|
import { Kbd } from "./internal/ui/kbd";
|
|
13
13
|
export const SearchButton = ({ className, onClick }) => {
|
|
14
14
|
const { setOpenSearch } = useSearchContext();
|
|
15
|
-
return (_jsxs(Button, { className: cn("justify-between gap-
|
|
15
|
+
return (_jsxs(Button, { className: cn("justify-between gap-2 pr-1.5 text-gray-900 shadow-none", className), onClick: () => {
|
|
16
16
|
setOpenSearch(true);
|
|
17
17
|
onClick?.();
|
|
18
|
-
}, size: "sm", type: "button", variant: "outline", children: [_jsx("span", { children: "Search
|
|
18
|
+
}, size: "sm", type: "button", variant: "outline", children: [_jsx("span", { children: "Search\u2026" }), _jsx(Kbd, { className: "border bg-background-100 font-medium", children: "\u2318\u00A0K" })] }));
|
|
19
19
|
};
|
|
20
20
|
export const ThemeToggle = () => {
|
|
21
21
|
const { resolvedTheme, setTheme } = useTheme();
|
|
@@ -24,17 +24,19 @@ export const ThemeToggle = () => {
|
|
|
24
24
|
setMounted(true);
|
|
25
25
|
}, []);
|
|
26
26
|
if (!mounted) {
|
|
27
|
-
return (_jsx(Button, { size: "icon-sm", type: "button", variant: "ghost", children: _jsx("div", { className: "size-4" }) }));
|
|
27
|
+
return (_jsx(Button, { "aria-label": "Toggle Theme", size: "icon-sm", type: "button", variant: "ghost", children: _jsx("div", { className: "size-4" }) }));
|
|
28
28
|
}
|
|
29
29
|
const Icon = resolvedTheme === "dark" ? MoonIcon : SunIcon;
|
|
30
|
-
return (_jsx(Button, {
|
|
30
|
+
return (_jsx(Button, { "aria-label": resolvedTheme === "dark"
|
|
31
|
+
? "Switch to Light Theme"
|
|
32
|
+
: "Switch to Dark Theme", onClick: () => setTheme(resolvedTheme === "dark" ? "light" : "dark"), size: "icon-sm", type: "button", variant: "ghost", children: _jsx(Icon, { className: "size-4" }) }));
|
|
31
33
|
};
|
|
32
34
|
export const LanguageSelector = () => {
|
|
33
35
|
const { locale, locales, onChange } = useI18n();
|
|
34
36
|
if (!locales) {
|
|
35
37
|
return null;
|
|
36
38
|
}
|
|
37
|
-
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { "aria-label": "Select
|
|
39
|
+
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { "aria-label": "Select Language", className: "flex items-center justify-center rounded-md p-2 hover:bg-gray-alpha-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300", children: [_jsx(LanguagesIcon, { className: "size-4.5" }), _jsx("span", { className: "sr-only", children: "Select Language" })] }), _jsx(DropdownMenuContent, { align: "end", children: locales.map((lang) => (_jsxs(DropdownMenuItem, { className: "flex cursor-pointer items-center justify-between", disabled: locale === lang.locale, onClick: () => onChange?.(lang.locale), children: [lang.name, locale === lang.locale && _jsx(CheckIcon, { className: "size-4" })] }, lang.locale))) })] }));
|
|
38
40
|
};
|
|
39
41
|
export const AskAIButton = ({ children, className, prompt, size = "sm", variant = "outline", ...props }) => {
|
|
40
42
|
const { enabled, isOpen, setIsOpen, setPrompt } = useGeistdocsChat();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"home-layout.d.ts","sourceRoot":"","sources":["../src/home-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"home-layout.d.ts","sourceRoot":"","sources":["../src/home-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,IAAI,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,GAAI,6BAIjC,wBAAwB,4CAgD1B,CAAC"}
|
package/dist/home-layout.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { DocsLayout as FumadocsDocsLayout } from "fumadocs-ui/layouts/docs";
|
|
3
3
|
import { createGeistdocsI18n } from "./internal/i18n";
|
|
4
4
|
import { ScrollState } from "./internal/scroll-state";
|
|
5
|
-
import { GeistdocsSidebar
|
|
5
|
+
import { GeistdocsSidebar } from "./internal/sidebar";
|
|
6
6
|
import { GeistdocsSidebarProvider } from "./sidebar";
|
|
7
7
|
export const GeistdocsHomeLayout = ({ config, tree, children, }) => {
|
|
8
8
|
const { i18n } = createGeistdocsI18n(config);
|
|
@@ -20,12 +20,7 @@ export const GeistdocsHomeLayout = ({ config, tree, children, }) => {
|
|
|
20
20
|
}, sidebar: {
|
|
21
21
|
className: "md:hidden",
|
|
22
22
|
collapsible: false,
|
|
23
|
-
component: _jsx(GeistdocsSidebar, {}),
|
|
24
|
-
components: {
|
|
25
|
-
Folder: GeistdocsSidebarFolder,
|
|
26
|
-
Item: GeistdocsSidebarItem,
|
|
27
|
-
Separator: GeistdocsSidebarSeparator,
|
|
28
|
-
},
|
|
23
|
+
component: _jsx(GeistdocsSidebar, { showDesktop: false }),
|
|
29
24
|
}, tabMode: "auto", themeSwitch: {
|
|
30
25
|
enabled: false,
|
|
31
26
|
}, tree: tree, children: [_jsx("div", { "data-home-route": true, hidden: true }), _jsx(ScrollState, {}), _jsx("div", { className: "@container", children: children })] }) }));
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { GeistdocsConfig } from "../config";
|
|
3
|
-
interface
|
|
3
|
+
interface PageActionsProps {
|
|
4
4
|
config: Pick<GeistdocsConfig, "ai" | "feedback" | "github" | "pageActions" | "siteId">;
|
|
5
|
-
extraActions: ReactNode[];
|
|
6
5
|
page: {
|
|
7
6
|
path?: string;
|
|
8
7
|
url: string;
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
|
-
|
|
10
|
+
interface GeistdocsTableOfContentsActionsProps {
|
|
11
|
+
config: Pick<GeistdocsConfig, "feedback" | "pageActions" | "siteId">;
|
|
12
|
+
extraActions: ReactNode[];
|
|
13
|
+
}
|
|
14
|
+
export declare const GeistdocsPageActions: ({ config, page }: PageActionsProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export declare const GeistdocsTableOfContentsActions: ({ config, extraActions, }: GeistdocsTableOfContentsActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
16
|
export {};
|
|
13
17
|
//# sourceMappingURL=page-actions-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAGL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAmBjD,UAAU,gBAAgB;IACxB,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC,CAAC;IACrE,YAAY,EAAE,SAAS,EAAE,CAAC;CAC3B;AA2aD,eAAO,MAAM,oBAAoB,GAAI,kBAAkB,gBAAgB,mDAoItE,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,2BAG7C,oCAAoC,4CAiBtC,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { SiGithub, SiMarkdown } from "@icons-pack/react-simple-icons";
|
|
3
|
+
import { SiGithub, SiMarkdown, SiV0 } from "@icons-pack/react-simple-icons";
|
|
4
4
|
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
5
|
-
import { ArrowUpCircleIcon, CheckIcon, CopyIcon, ExternalLinkIcon, MessageCircleIcon, ThumbsUpIcon, } from "lucide-react";
|
|
5
|
+
import { ArrowUpCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CopyIcon, ExternalLinkIcon, MessageCircleIcon, ThumbsUpIcon, } from "lucide-react";
|
|
6
6
|
import { usePathname } from "next/navigation";
|
|
7
|
-
import { useEffect, useState, useTransition, } from "react";
|
|
7
|
+
import { useEffect, useRef, useState, useTransition, } from "react";
|
|
8
8
|
import { useGeistdocsChat } from "./chat/context";
|
|
9
9
|
import { sendFeedback } from "./feedback-action";
|
|
10
10
|
import { Button } from "./ui/button";
|
|
11
|
-
import {
|
|
11
|
+
import { ButtonGroup } from "./ui/button-group";
|
|
12
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "./ui/dropdown-menu";
|
|
12
13
|
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
|
|
13
14
|
import { Textarea } from "./ui/textarea";
|
|
14
|
-
|
|
15
|
+
import { useIsMobile } from "./use-mobile";
|
|
16
|
+
const actionClassName = "group flex min-h-8 w-full min-w-0 touch-manipulation items-center gap-2 rounded-md text-left text-gray-900 text-label-14 transition-colors hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-100 motion-reduce:transition-none [&_svg]:size-4 [&_svg]:shrink-0 [&_span]:min-w-0 [&_span]:truncate";
|
|
15
17
|
const DEFAULT_EDIT_PATH = "content/docs/{path}";
|
|
16
18
|
const trimSlashes = (value) => value.replace(/^\/+|\/+$/g, "");
|
|
17
19
|
const resolveEditPath = ({ editPath = DEFAULT_EDIT_PATH, path, }) => {
|
|
@@ -43,16 +45,6 @@ const openInProviders = [
|
|
|
43
45
|
label: "Open in Claude",
|
|
44
46
|
getHref: (query) => `https://claude.ai/new?${new URLSearchParams({ q: query }).toString()}`,
|
|
45
47
|
},
|
|
46
|
-
{
|
|
47
|
-
id: "t3",
|
|
48
|
-
label: "Open in T3 Chat",
|
|
49
|
-
getHref: (query) => `https://t3.chat/new?${new URLSearchParams({ q: query }).toString()}`,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: "scira",
|
|
53
|
-
label: "Open in Scira",
|
|
54
|
-
getHref: (query) => `https://scira.ai/?${new URLSearchParams({ q: query }).toString()}`,
|
|
55
|
-
},
|
|
56
48
|
{
|
|
57
49
|
id: "cursor",
|
|
58
50
|
label: "Open in Cursor",
|
|
@@ -63,52 +55,40 @@ const openInProviders = [
|
|
|
63
55
|
},
|
|
64
56
|
},
|
|
65
57
|
];
|
|
66
|
-
const
|
|
67
|
-
let url;
|
|
58
|
+
const getEditSourceUrl = ({ github, path, }) => {
|
|
68
59
|
if (github?.owner && github?.repo && path) {
|
|
69
60
|
const branch = github.branch ?? "main";
|
|
70
61
|
const editPath = resolveEditPath({ editPath: github.editPath, path });
|
|
71
|
-
|
|
62
|
+
return `https://github.com/${github.owner}/${github.repo}/edit/${branch}/${editPath}`;
|
|
72
63
|
}
|
|
73
|
-
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
return (_jsxs("a", { className: actionClassName, href: url, rel: "noopener noreferrer", target: "_blank", children: [_jsx(SiGithub, { className: "size-3.5" }), _jsx("span", { children: "Edit this page on GitHub" })] }));
|
|
64
|
+
return undefined;
|
|
77
65
|
};
|
|
78
66
|
const getMarkdownUrl = (url) => url === "/docs" ? "/docs.md" : `${url}.md`;
|
|
79
|
-
const
|
|
80
|
-
const pathname = usePathname();
|
|
81
|
-
const [checked, handleCopy] = useCopyButton(async () => {
|
|
82
|
-
const response = await fetch(getMarkdownUrl(pathname || url));
|
|
83
|
-
if (!response.ok) {
|
|
84
|
-
throw new Error(`Failed to fetch markdown for ${url}`);
|
|
85
|
-
}
|
|
86
|
-
await navigator.clipboard.writeText(await response.text());
|
|
87
|
-
});
|
|
88
|
-
const Icon = checked ? CheckIcon : CopyIcon;
|
|
89
|
-
return (_jsxs("button", { className: actionClassName, onClick: handleCopy, type: "button", children: [_jsx(Icon, { className: "size-3.5" }), _jsx("span", { children: "Copy page" })] }));
|
|
90
|
-
};
|
|
91
|
-
const OpenInChatAction = ({ href }) => {
|
|
67
|
+
const getPageQuery = (href, origin) => {
|
|
92
68
|
const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
69
|
+
const productionHost = process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL;
|
|
70
|
+
const baseUrl = origin ?? (productionHost ? `${protocol}://${productionHost}` : undefined);
|
|
71
|
+
const url = baseUrl ? new URL(href, baseUrl).toString() : href;
|
|
72
|
+
return `Read this page, I want to ask questions about it. ${url}`;
|
|
96
73
|
};
|
|
97
|
-
const ScrollTopAction = () => (_jsxs("button", { className: actionClassName, onClick: () =>
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
74
|
+
const ScrollTopAction = () => (_jsxs("button", { className: actionClassName, onClick: () => {
|
|
75
|
+
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
76
|
+
window.scrollTo({ top: 0, behavior: reduceMotion ? "auto" : "smooth" });
|
|
77
|
+
}, type: "button", children: [_jsx(ArrowUpCircleIcon, { className: "size-3.5" }), _jsx("span", { children: "Scroll to top" })] }));
|
|
78
|
+
const PageActionMenuItemContent = ({ description, icon, title, }) => (_jsxs("span", { className: "grid w-full grid-cols-[20px_minmax(0,1fr)] items-center gap-3 text-left", children: [_jsx("span", { className: "flex size-5 items-center justify-center text-gray-900", children: icon }), _jsxs("span", { className: "flex min-w-0 flex-col items-start gap-0.5", children: [_jsx("span", { className: "text-gray-1000 text-label-14", children: title }), _jsx("span", { className: "text-copy-13 text-gray-900", children: description })] })] }));
|
|
79
|
+
const OpenInProviderItems = ({ providers, query, }) => providers.map((provider) => (_jsx(DropdownMenuItem, { asChild: true, children: _jsxs("a", { className: "flex items-center gap-2 text-label-14", href: provider.getHref(query), rel: "noopener noreferrer", target: "_blank", children: [_jsx("span", { className: "flex-1", translate: "no", children: provider.label }), _jsx(ExternalLinkIcon, { className: "size-4 shrink-0" })] }) }, provider.id)));
|
|
80
|
+
const ProviderMenuView = ({ backRef, onBack, providers, query, }) => (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "text-label-14", onSelect: (event) => {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
onBack();
|
|
83
|
+
}, ref: backRef, children: [_jsx(ChevronLeftIcon, { className: "size-4" }), _jsx("span", { children: "Back to page actions" })] }), _jsx(DropdownMenuSeparator, {}), _jsx(OpenInProviderItems, { providers: providers, query: query })] }));
|
|
84
|
+
const PageActionsMainMenu = ({ askAIEnabled, checked, copyEnabled, copyIcon, editSourceEnabled, editSourceUrl, handleCopy, isMobile, markdownUrl, onAskAI, onShowProviders, openInChatEnabled, openInChatRef, otherProviders, query, v0Provider, }) => {
|
|
85
|
+
return (_jsxs(_Fragment, { children: [copyEnabled ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuItem, { asChild: true, className: "h-auto w-full p-2", children: _jsx("button", { onClick: handleCopy, type: "button", children: _jsx(PageActionMenuItemContent, { description: "Copy page as Markdown for LLMs", icon: copyIcon, title: checked ? "Copied" : "Copy page" }) }) }), _jsx(DropdownMenuItem, { asChild: true, className: "h-auto p-2", children: _jsx("a", { href: markdownUrl, rel: "noopener noreferrer", target: "_blank", children: _jsx(PageActionMenuItemContent, { description: "Open this page as plain text", icon: _jsx(SiMarkdown, { "aria-hidden": "true", className: "size-4" }), title: "View as Markdown" }) }) })] })) : null, openInChatEnabled ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuItem, { asChild: true, className: "h-auto p-2", children: _jsx("a", { href: v0Provider.getHref(query), rel: "noopener noreferrer", target: "_blank", children: _jsx(PageActionMenuItemContent, { description: "Ask v0 to help apply this page", icon: _jsx(SiV0, { "aria-hidden": "true", className: "size-4" }), title: v0Provider.label }) }) }), isMobile ? (_jsxs(DropdownMenuItem, { className: "h-auto p-2", onSelect: (event) => {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
onShowProviders();
|
|
88
|
+
}, ref: openInChatRef, children: [_jsx(PageActionMenuItemContent, { description: "Use this page in another AI chat", icon: _jsx(ExternalLinkIcon, { className: "size-4" }), title: "Open in another chat" }), _jsx(ChevronRightIcon, { className: "size-4" })] })) : (_jsxs(DropdownMenuSub, { children: [_jsx(DropdownMenuSubTrigger, { className: "h-auto p-2", children: _jsx(PageActionMenuItemContent, { description: "Use this page in another AI chat", icon: _jsx(ExternalLinkIcon, { className: "size-4" }), title: "Open in another chat" }) }), _jsx(DropdownMenuSubContent, { className: "w-52", sideOffset: 12, children: _jsx(OpenInProviderItems, { providers: otherProviders, query: query }) })] }))] })) : null, askAIEnabled ? (_jsx(DropdownMenuItem, { className: "h-auto p-2", onSelect: onAskAI, children: _jsx(PageActionMenuItemContent, { description: "Chat with this page as context", icon: _jsx(MessageCircleIcon, { className: "size-4" }), title: "Ask AI about this page" }) })) : null, editSourceEnabled ? (_jsx(DropdownMenuItem, { asChild: true, className: "h-auto p-2", children: _jsx("a", { href: editSourceUrl, rel: "noopener noreferrer", target: "_blank", children: _jsx(PageActionMenuItemContent, { description: "Suggest changes to this page", icon: _jsx(SiGithub, { "aria-hidden": "true", className: "size-4" }), title: "Edit this page on GitHub" }) }) })) : null] }));
|
|
110
89
|
};
|
|
111
90
|
const FeedbackAction = ({ siteId }) => {
|
|
91
|
+
const isMobile = useIsMobile();
|
|
112
92
|
const url = usePathname();
|
|
113
93
|
const [submitted, setSubmitted] = useState(false);
|
|
114
94
|
const [emotion, setEmotion] = useState(null);
|
|
@@ -139,33 +119,68 @@ const FeedbackAction = ({ siteId }) => {
|
|
|
139
119
|
});
|
|
140
120
|
});
|
|
141
121
|
};
|
|
142
|
-
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { className: actionClassName, type: "button", children: [_jsx(ThumbsUpIcon, { className: "size-3.5" }), _jsx("span", { children: "Give feedback" })] }) }), _jsx(PopoverContent, { className: "overflow-hidden p-0", children: _jsx("div", { className: "overflow-visible", children: submitted ? (_jsx("div", { className: "flex flex-col items-center gap-3 rounded-xl bg-background-200 px-3 py-6 text-center text-
|
|
122
|
+
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { className: actionClassName, type: "button", children: [_jsx(ThumbsUpIcon, { className: "size-3.5" }), _jsx("span", { children: "Give feedback" })] }) }), _jsx(PopoverContent, { className: "overflow-hidden p-0", children: _jsx("div", { className: "overflow-visible", children: submitted ? (_jsx("div", { className: "flex flex-col items-center gap-3 rounded-xl bg-background-200 px-3 py-6 text-center text-copy-14", role: "status", children: _jsx("p", { children: "Thank you for your feedback!" }) })) : (_jsxs("form", { className: "flex flex-col", onSubmit: submit, children: [_jsx("div", { className: "p-2", children: _jsx(Textarea, { "aria-label": "Feedback", autoComplete: "off", autoFocus: !isMobile, className: "max-h-48 min-h-24 shadow-none", name: "feedback", onChange: (event) => setMessage(event.target.value), onKeyDown: (event) => {
|
|
143
123
|
if (!event.shiftKey && event.key === "Enter") {
|
|
144
124
|
event.currentTarget.form?.requestSubmit();
|
|
145
125
|
}
|
|
146
|
-
}, placeholder: "Leave your feedback
|
|
126
|
+
}, placeholder: "Leave your feedback\u2026", required: true, value: message }) }), _jsxs("div", { className: "flex items-center justify-end gap-1 px-2 text-gray-900", children: [_jsx(SiMarkdown, { "aria-hidden": "true", className: "inline size-3" }), _jsx("p", { className: "text-label-12", children: " supported" })] }), _jsxs("div", { className: "mt-2 flex items-center justify-between border-t bg-background-200 p-2", children: [_jsx("div", { className: "flex items-center gap-px", children: feedbackEmotions.map((entry) => (_jsxs(Button, { className: emotion === entry.name
|
|
147
127
|
? "bg-gray-100 text-gray-1000"
|
|
148
|
-
: "text-gray-
|
|
128
|
+
: "text-gray-900 hover:text-gray-1000", onClick: () => setEmotion(entry.name), size: "sm", type: "button", variant: "ghost", children: [entry.emoji, _jsx("span", { className: "sr-only", children: entry.name })] }, entry.name))) }), _jsx(Button, { disabled: isPending || !emotion || !message, size: "sm", type: "submit", variant: "default", children: "Send" })] })] })) }) })] }));
|
|
149
129
|
};
|
|
150
|
-
export const GeistdocsPageActions = ({ config,
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
130
|
+
export const GeistdocsPageActions = ({ config, page }) => {
|
|
131
|
+
const pathname = usePathname();
|
|
132
|
+
const isMobile = useIsMobile();
|
|
133
|
+
const { enabled: chatEnabled, setIsOpen, setPrompt } = useGeistdocsChat();
|
|
134
|
+
const [menuView, setMenuView] = useState("main");
|
|
135
|
+
const openInChatRef = useRef(null);
|
|
136
|
+
const providersBackRef = useRef(null);
|
|
137
|
+
const markdownUrl = getMarkdownUrl(pathname || page.url);
|
|
138
|
+
const [checked, handleCopy] = useCopyButton(async () => {
|
|
139
|
+
const response = await fetch(markdownUrl);
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
throw new Error(`Failed to fetch markdown from ${markdownUrl}`);
|
|
142
|
+
}
|
|
143
|
+
await navigator.clipboard.writeText(await response.text());
|
|
144
|
+
});
|
|
145
|
+
const editSourceUrl = getEditSourceUrl({
|
|
146
|
+
github: config.github,
|
|
147
|
+
path: page.path,
|
|
148
|
+
});
|
|
149
|
+
const query = getPageQuery(page.url);
|
|
150
|
+
const copyEnabled = config.pageActions?.copyPage !== false;
|
|
151
|
+
const openInChatEnabled = config.pageActions?.openInChat !== false;
|
|
152
|
+
const askAIEnabled = chatEnabled &&
|
|
153
|
+
config.ai?.enabled !== false &&
|
|
154
|
+
config.pageActions?.askAI !== false;
|
|
155
|
+
const editSourceEnabled = config.pageActions?.editSource !== false && Boolean(editSourceUrl);
|
|
156
|
+
if (!(copyEnabled || openInChatEnabled || askAIEnabled || editSourceEnabled)) {
|
|
157
|
+
return null;
|
|
154
158
|
}
|
|
159
|
+
const v0Provider = openInProviders[0];
|
|
160
|
+
const otherProviders = openInProviders.slice(1);
|
|
161
|
+
const CopyStateIcon = checked ? CheckIcon : CopyIcon;
|
|
162
|
+
return (_jsxs("div", { className: "self-end", children: [_jsxs(ButtonGroup, { children: [copyEnabled ? (_jsxs(Button, { "aria-label": "Copy page", className: "touch-manipulation", onClick: handleCopy, size: "sm", type: "button", variant: "outline", children: [_jsx(CopyStateIcon, { className: "size-4" }), _jsxs("span", { className: "relative hidden sm:inline-block", children: [_jsx("span", { className: "invisible", children: "Copy page" }), _jsx("span", { className: "absolute inset-0", children: checked ? "Copied" : "Copy page" })] })] })) : null, _jsxs(DropdownMenu, { onOpenChange: (open) => {
|
|
163
|
+
if (!open) {
|
|
164
|
+
setMenuView("main");
|
|
165
|
+
}
|
|
166
|
+
}, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { "aria-label": copyEnabled ? "Open page actions" : "Page actions", className: copyEnabled ? "touch-manipulation px-2" : undefined, size: "sm", type: "button", variant: "outline", children: [copyEnabled ? null : _jsx("span", { children: "Page actions" }), _jsx(ChevronDownIcon, { className: "size-4" })] }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-80 max-w-[calc(100vw-1rem)]", sideOffset: 8, children: isMobile && menuView === "providers" ? (_jsx(ProviderMenuView, { backRef: providersBackRef, onBack: () => {
|
|
167
|
+
setMenuView("main");
|
|
168
|
+
requestAnimationFrame(() => openInChatRef.current?.focus());
|
|
169
|
+
}, providers: otherProviders, query: query })) : (_jsx(PageActionsMainMenu, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, copyIcon: _jsx(CopyStateIcon, { className: "size-4" }), editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, handleCopy: handleCopy, isMobile: isMobile, markdownUrl: markdownUrl, onAskAI: () => {
|
|
170
|
+
setPrompt(getPageQuery(page.url, window.location.origin));
|
|
171
|
+
setIsOpen(true);
|
|
172
|
+
}, onShowProviders: () => {
|
|
173
|
+
setMenuView("providers");
|
|
174
|
+
requestAnimationFrame(() => providersBackRef.current?.focus());
|
|
175
|
+
}, openInChatEnabled: openInChatEnabled, openInChatRef: openInChatRef, otherProviders: otherProviders, query: query, v0Provider: v0Provider })) })] })] }), _jsx("span", { "aria-live": "polite", className: "sr-only", children: checked ? "Page copied" : "" })] }));
|
|
176
|
+
};
|
|
177
|
+
export const GeistdocsTableOfContentsActions = ({ config, extraActions, }) => {
|
|
178
|
+
const actions = [];
|
|
155
179
|
if (config.pageActions?.scrollTop !== false) {
|
|
156
180
|
actions.push(_jsx(ScrollTopAction, {}, "scroll-top"));
|
|
157
181
|
}
|
|
158
182
|
if (config.feedback?.enabled !== false) {
|
|
159
183
|
actions.push(_jsx(FeedbackAction, { siteId: config.siteId }, "feedback"));
|
|
160
184
|
}
|
|
161
|
-
if (config.pageActions?.copyPage !== false) {
|
|
162
|
-
actions.push(_jsx(CopyPageAction, { url: page.url }, "copy-page"));
|
|
163
|
-
}
|
|
164
|
-
if (config.ai?.enabled !== false && config.pageActions?.askAI !== false) {
|
|
165
|
-
actions.push(_jsx(AskAIAction, { href: page.url }, "ask-ai"));
|
|
166
|
-
}
|
|
167
|
-
if (config.pageActions?.openInChat !== false) {
|
|
168
|
-
actions.push(_jsx(OpenInChatAction, { href: page.url }, "open-in-chat"));
|
|
169
|
-
}
|
|
170
185
|
return (_jsxs(_Fragment, { children: [actions, extraActions] }));
|
|
171
186
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAWjD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAWjD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA2CD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAM9D,CAAC"}
|
|
@@ -16,7 +16,7 @@ const GeistdocsProviderInner = ({ config, search, lang, ...props }) => {
|
|
|
16
16
|
const { enabled, isOpen } = useGeistdocsChat();
|
|
17
17
|
const isMobile = useIsMobile();
|
|
18
18
|
const SearchDialogComponent = useCallback((searchProps) => (_jsx(GeistdocsSearchDialog, { basePath: config.basePath, ...searchProps })), [config.basePath]);
|
|
19
|
-
return (_jsx("div", { className: cn("transition-
|
|
19
|
+
return (_jsx("div", { className: cn("@container transition-[padding-right] duration-150 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] motion-reduce:transition-none", enabled && isOpen && !isMobile ? "pr-96!" : null), "data-geistdocs-container": true, children: _jsxs(TooltipProvider, { children: [_jsx(RootProvider, { i18n: i18nProvider(lang ?? i18n.defaultLanguage), search: {
|
|
20
20
|
SearchDialog: SearchDialogComponent,
|
|
21
21
|
...search,
|
|
22
22
|
}, ...props }), _jsx(Toaster, {}), _jsx(GeistdocsChatShell, {})] }) }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-responsive.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar-responsive.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,eAAO,MAAM,uBAAuB,GAClC,WAAW,OAAO,EAClB,WAAW,MAAM,IAAI,KACpB,CAAC,MAAM,IAAI,CASb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const SIDEBAR_DESKTOP_MIN_WIDTH = 961;
|
|
2
|
+
export const observeSidebarContainer = (container, onDesktop) => {
|
|
3
|
+
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
4
|
+
if (entry && entry.contentRect.width >= SIDEBAR_DESKTOP_MIN_WIDTH) {
|
|
5
|
+
onDesktop();
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
resizeObserver.observe(container);
|
|
9
|
+
return () => resizeObserver.disconnect();
|
|
10
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Folder, Item, Node } from "fumadocs-core/page-tree";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type SidebarSectionNode = Extract<Node, {
|
|
4
|
+
type: "folder" | "page";
|
|
5
|
+
}>;
|
|
6
|
+
export interface SidebarRootGroup {
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
id: string;
|
|
9
|
+
items: SidebarSectionNode[];
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare const getSidebarItemBadge: (item: Item | undefined) => string | undefined;
|
|
13
|
+
export declare const isExternalSidebarItem: (item: Item | undefined) => boolean;
|
|
14
|
+
export declare const isExternalSidebarUrl: (url: string) => boolean;
|
|
15
|
+
export declare const hasSeparateRootDisclosure: (node: SidebarSectionNode) => node is Folder;
|
|
16
|
+
export declare const getSidebarNodeId: (node: Node, path: number[], scope?: string) => string;
|
|
17
|
+
export declare const nodeContainsUrl: (node: Node, url: string) => boolean;
|
|
18
|
+
export declare const findActiveRootSection: (nodes: Node[], activeUrl: string | undefined) => Folder | null;
|
|
19
|
+
export declare const getSidebarSectionItems: (section: Folder | null) => Node[];
|
|
20
|
+
export declare const getSidebarRootGroups: (nodes: Node[]) => SidebarRootGroup[];
|
|
21
|
+
export declare const getInitialOpenFolderIds: (nodes: Node[], activeUrl: string | undefined, openFirstLevel?: boolean, scope?: string) => string[];
|
|
22
|
+
export declare const getDescendantFolderIds: (folder: Folder, folderPath: number[], scope?: string) => string[];
|
|
23
|
+
//# sourceMappingURL=sidebar-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-tree.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAA;CAAE,CAAC,CAAC;AAE5E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,GAC9B,MAAM,IAAI,GAAG,SAAS,KACrB,MAAM,GAAG,SAGX,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,MAAM,IAAI,GAAG,SAAS,KAAG,OACE,CAAC;AAElE,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,OAC3B,CAAC;AAEzB,eAAO,MAAM,yBAAyB,GACpC,MAAM,kBAAkB,KACvB,IAAI,IAAI,MAGwB,CAAC;AAEpC,eAAO,MAAM,gBAAgB,GAC3B,MAAM,IAAI,EACV,MAAM,MAAM,EAAE,EACd,cAAiB,KAChB,MAAuD,CAAC;AAE3D,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,KAAK,MAAM,KAAG,OAczD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,OAAO,IAAI,EAAE,EACb,WAAW,MAAM,GAAG,SAAS,KAC5B,MAAM,GAAG,IAgBX,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,MAAM,GAAG,IAAI,KAAG,IAAI,EAsBnE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO,IAAI,EAAE,KAAG,gBAAgB,EA8BpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,IAAI,EAAE,EACb,WAAW,MAAM,GAAG,SAAS,EAC7B,wBAAsB,EACtB,cAAiB,KAChB,MAAM,EAyBR,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,QAAQ,MAAM,EACd,YAAY,MAAM,EAAE,EACpB,cAAiB,KAChB,MAAM,EAiBR,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const TRAILING_SLASH = /\/$/;
|
|
2
|
+
const EXTERNAL_URL = /^(?:\w+:|\/\/)/;
|
|
3
|
+
export const getSidebarItemBadge = (item) => {
|
|
4
|
+
const badge = item?.badge;
|
|
5
|
+
return typeof badge === "string" && badge.length > 0 ? badge : undefined;
|
|
6
|
+
};
|
|
7
|
+
export const isExternalSidebarItem = (item) => Boolean(item && (item.external || EXTERNAL_URL.test(item.url)));
|
|
8
|
+
export const isExternalSidebarUrl = (url) => EXTERNAL_URL.test(url);
|
|
9
|
+
export const hasSeparateRootDisclosure = (node) => node.type === "folder" &&
|
|
10
|
+
node.children.length > 0 &&
|
|
11
|
+
isExternalSidebarItem(node.index);
|
|
12
|
+
export const getSidebarNodeId = (node, path, scope = "sidebar") => node.$id ?? `${scope}-node-${path.join("-")}`;
|
|
13
|
+
export const nodeContainsUrl = (node, url) => {
|
|
14
|
+
if (node.type === "page") {
|
|
15
|
+
return node.url === url;
|
|
16
|
+
}
|
|
17
|
+
if (node.type === "separator") {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (node.index?.url === url) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return node.children.some((child) => nodeContainsUrl(child, url));
|
|
24
|
+
};
|
|
25
|
+
export const findActiveRootSection = (nodes, activeUrl) => {
|
|
26
|
+
if (!activeUrl) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
for (const node of nodes) {
|
|
30
|
+
if (node.type === "folder" &&
|
|
31
|
+
node.children.length > 0 &&
|
|
32
|
+
nodeContainsUrl(node, activeUrl)) {
|
|
33
|
+
return node;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
export const getSidebarSectionItems = (section) => {
|
|
39
|
+
if (!section) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
if (!section.index) {
|
|
43
|
+
return section.children;
|
|
44
|
+
}
|
|
45
|
+
const homeUrl = section.index.url.replace(TRAILING_SLASH, "");
|
|
46
|
+
const overview = {
|
|
47
|
+
...section.index,
|
|
48
|
+
$id: `${section.$id ?? "section"}-overview`,
|
|
49
|
+
icon: undefined,
|
|
50
|
+
name: "Overview",
|
|
51
|
+
};
|
|
52
|
+
const remaining = section.children.filter((item) => item.type !== "page" || item.url.replace(TRAILING_SLASH, "") !== homeUrl);
|
|
53
|
+
return [overview, ...remaining];
|
|
54
|
+
};
|
|
55
|
+
export const getSidebarRootGroups = (nodes) => {
|
|
56
|
+
const groups = [];
|
|
57
|
+
let current = {
|
|
58
|
+
id: "sidebar-root",
|
|
59
|
+
items: [],
|
|
60
|
+
};
|
|
61
|
+
for (const [index, node] of nodes.entries()) {
|
|
62
|
+
if (node.type === "separator") {
|
|
63
|
+
if (current.items.length > 0) {
|
|
64
|
+
groups.push(current);
|
|
65
|
+
}
|
|
66
|
+
current = {
|
|
67
|
+
icon: node.icon,
|
|
68
|
+
id: getSidebarNodeId(node, [index]),
|
|
69
|
+
items: [],
|
|
70
|
+
label: node.name,
|
|
71
|
+
};
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
current.items.push(node);
|
|
75
|
+
}
|
|
76
|
+
if (current.items.length > 0) {
|
|
77
|
+
groups.push(current);
|
|
78
|
+
}
|
|
79
|
+
return groups;
|
|
80
|
+
};
|
|
81
|
+
export const getInitialOpenFolderIds = (nodes, activeUrl, openFirstLevel = false, scope = "sidebar") => {
|
|
82
|
+
const opened = [];
|
|
83
|
+
const visit = (items, depth, parentPath) => {
|
|
84
|
+
for (const [index, item] of items.entries()) {
|
|
85
|
+
if (item.type !== "folder") {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const path = [...parentPath, index];
|
|
89
|
+
const isOpen = item.defaultOpen ??
|
|
90
|
+
((openFirstLevel && depth === 0) ||
|
|
91
|
+
(activeUrl ? nodeContainsUrl(item, activeUrl) : false));
|
|
92
|
+
if (isOpen) {
|
|
93
|
+
opened.push(getSidebarNodeId(item, path, scope));
|
|
94
|
+
}
|
|
95
|
+
visit(item.children, depth + 1, path);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
visit(nodes, 0, []);
|
|
99
|
+
return opened;
|
|
100
|
+
};
|
|
101
|
+
export const getDescendantFolderIds = (folder, folderPath, scope = "sidebar") => {
|
|
102
|
+
const ids = [];
|
|
103
|
+
const visit = (nodes, parentPath) => {
|
|
104
|
+
for (const [index, node] of nodes.entries()) {
|
|
105
|
+
if (node.type !== "folder") {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const path = [...parentPath, index];
|
|
109
|
+
ids.push(getSidebarNodeId(node, path, scope));
|
|
110
|
+
visit(node.children, path);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
visit(folder.children, folderPath);
|
|
114
|
+
return ids;
|
|
115
|
+
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { SidebarPageTreeComponents } from "fumadocs-ui/components/sidebar/page-tree";
|
|
2
1
|
import { type ReactNode } from "react";
|
|
3
|
-
export declare const GeistdocsSidebar: ({ top }: {
|
|
2
|
+
export declare const GeistdocsSidebar: ({ showDesktop, top, }: {
|
|
3
|
+
showDesktop?: boolean;
|
|
4
4
|
top?: ReactNode;
|
|
5
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export declare const GeistdocsSidebarFolder: SidebarPageTreeComponents["Folder"];
|
|
7
|
-
export declare const GeistdocsSidebarItem: SidebarPageTreeComponents["Item"];
|
|
8
|
-
export declare const GeistdocsSidebarSeparator: SidebarPageTreeComponents["Separator"];
|
|
9
6
|
//# sourceMappingURL=sidebar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AA82Bf,eAAO,MAAM,gBAAgB,GAAI,uBAG9B;IACD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,4CA8DA,CAAC"}
|