@vercel/geistdocs 1.17.1 → 1.19.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 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.17.1","-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.19.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);
@@ -3,4 +3,16 @@ export declare const createGitLastModified: ({ cwd, gitBinary, }?: {
3
3
  gitBinary?: string;
4
4
  }) => (filePath: string) => Promise<Date | null>;
5
5
  export declare const getGitLastModified: (filePath: string) => Promise<Date | null>;
6
+ /**
7
+ * Resolves a page's last-modified date with a frontmatter-first chain:
8
+ * an explicit `lastModified` frontmatter value wins, then the file's git
9
+ * author time, then nothing (surfaces omit the date). The frontmatter
10
+ * override keeps dates working on shallow clones, where git history for
11
+ * untouched files is unavailable.
12
+ */
13
+ export declare const createLastModified: ({ cwd, gitBinary, }?: {
14
+ cwd?: string;
15
+ gitBinary?: string;
16
+ }) => (filePath: string) => Promise<Date | null>;
17
+ export declare const getLastModified: (filePath: string) => Promise<Date | null>;
6
18
  //# sourceMappingURL=last-modified.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"last-modified.d.ts","sourceRoot":"","sources":["../../src/internal/last-modified.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,GAAI,sBAGnC;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,MAUI,UAAU,MAAM,yBA0BzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,aA5BX,MAAM,yBA4B+B,CAAC"}
1
+ {"version":3,"file":"last-modified.d.ts","sourceRoot":"","sources":["../../src/internal/last-modified.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,qBAAqB,GAAI,sBAGnC;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,MAUI,UAAU,MAAM,yBA0BzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,aA5BX,MAAM,yBA4B+B,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,sBAGhC;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,MAII,UAAU,MAAM,yBAYzB,CAAC;AAEF,eAAO,MAAM,eAAe,aAdR,MAAM,yBAcyB,CAAC"}
@@ -1,7 +1,29 @@
1
1
  import { execFile } from "node:child_process";
2
+ import { readFile } from "node:fs/promises";
2
3
  import path from "node:path";
3
4
  import { promisify } from "node:util";
4
5
  const execFileAsync = promisify(execFile);
6
+ const FRONTMATTER_BLOCK_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---/;
7
+ const LAST_MODIFIED_KEY_PATTERN = /^lastModified:\s*(?:"([^"]*)"|'([^']*)'|([^#\n]+?))\s*$/m;
8
+ const readFrontmatterLastModified = async (filePath) => {
9
+ try {
10
+ const contents = await readFile(filePath, "utf8");
11
+ const block = contents.match(FRONTMATTER_BLOCK_PATTERN)?.[1];
12
+ if (!block) {
13
+ return null;
14
+ }
15
+ const match = block.match(LAST_MODIFIED_KEY_PATTERN);
16
+ if (!match) {
17
+ return null;
18
+ }
19
+ const value = match[1] ?? match[2] ?? match[3];
20
+ const date = new Date(value);
21
+ return Number.isNaN(date.getTime()) ? null : date;
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ };
5
27
  export const createGitLastModified = ({ cwd = process.cwd(), gitBinary = "git", } = {}) => {
6
28
  const cache = new Map();
7
29
  const gitAvailable = execFileAsync(gitBinary, ["rev-parse", "--is-inside-work-tree"], { cwd })
@@ -30,3 +52,24 @@ export const createGitLastModified = ({ cwd = process.cwd(), gitBinary = "git",
30
52
  };
31
53
  };
32
54
  export const getGitLastModified = createGitLastModified();
55
+ /**
56
+ * Resolves a page's last-modified date with a frontmatter-first chain:
57
+ * an explicit `lastModified` frontmatter value wins, then the file's git
58
+ * author time, then nothing (surfaces omit the date). The frontmatter
59
+ * override keeps dates working on shallow clones, where git history for
60
+ * untouched files is unavailable.
61
+ */
62
+ export const createLastModified = ({ cwd, gitBinary, } = {}) => {
63
+ const gitLastModified = createGitLastModified({ cwd, gitBinary });
64
+ const cache = new Map();
65
+ return (filePath) => {
66
+ const cached = cache.get(filePath);
67
+ if (cached) {
68
+ return cached;
69
+ }
70
+ const result = readFrontmatterLastModified(filePath).then((fromFrontmatter) => fromFrontmatter ?? gitLastModified(filePath));
71
+ cache.set(filePath, result);
72
+ return result;
73
+ };
74
+ };
75
+ export const getLastModified = createLastModified();
@@ -1,5 +1,7 @@
1
1
  import { type ReactNode } from "react";
2
- export declare const GeistdocsSidebar: ({ showDesktop, top, }: {
2
+ import { type GeistdocsSidebarMode } from "../sidebar";
3
+ export declare const GeistdocsSidebar: ({ mode, showDesktop, top, }: {
4
+ mode?: GeistdocsSidebarMode;
3
5
  showDesktop?: boolean;
4
6
  top?: ReactNode;
5
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAq3Bf,eAAO,MAAM,gBAAgB,GAAI,uBAG9B;IACD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,4CA8DA,CAAC"}
1
+ {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,KAAK,oBAAoB,EAAuB,MAAM,YAAY,CAAC;AA45B5E,eAAO,MAAM,gBAAgB,GAAI,6BAI9B;IACD,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,4CA+DA,CAAC"}
@@ -223,7 +223,7 @@ const SidebarRootItem = ({ activeSection, activeUrl, item, onSelect, }) => {
223
223
  return (_jsxs("li", { className: cn(separateDisclosure && "flex items-center gap-px"), children: [renderedItem, separateDisclosure ? (_jsx("button", { "aria-label": getRootDisclosureLabel(item.name), className: "grid size-8 flex-none cursor-pointer touch-manipulation place-content-center rounded-md bg-transparent p-0 text-gray-900 hover:bg-gray-alpha-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300 motion-reduce:transition-none", onClick: (event) => onSelect(item, event.currentTarget), type: "button", children: _jsx(IconChevronRight, { size: 16 }) })) : null] }));
224
224
  };
225
225
  const SidebarSectionHeader = ({ buttonRef, onBack, section, }) => (_jsx("div", { className: "mb-2 px-2 pt-1", children: _jsxs("button", { "aria-label": "Back to all documentation sections", className: "flex w-full cursor-pointer touch-manipulation flex-row items-center justify-between gap-1 rounded-md border-0 bg-transparent p-0 text-gray-900 hover:bg-gray-alpha-100 hover:text-gray-1000 focus-visible:bg-gray-alpha-100 focus-visible:text-gray-1000 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300 motion-reduce:transition-none", onClick: onBack, ref: buttonRef, type: "button", children: [_jsx("span", { className: "grid size-9 flex-none place-content-center", children: _jsx(IconChevronRight, { className: "rotate-180", size: 16 }) }), _jsx("span", { className: "flex min-w-0 flex-1 items-center justify-center text-button-14", children: _jsx("span", { className: "truncate", children: section.name }) }), _jsx("span", { className: "size-9 flex-none" })] }) }));
226
- const DesktopSidebar = ({ activeUrl, nodes, rootScope, top, }) => {
226
+ const DesktopSectionsSidebar = ({ activeUrl, nodes, rootScope, top, }) => {
227
227
  const groups = useMemo(() => getSidebarRootGroups(nodes), [nodes]);
228
228
  const currentSection = useMemo(() => findActiveRootSection(nodes, activeUrl), [activeUrl, nodes]);
229
229
  const [selectedSection, setSelectedSection] = useState(null);
@@ -300,8 +300,15 @@ const DesktopSidebar = ({ activeUrl, nodes, rootScope, top, }) => {
300
300
  setView("root");
301
301
  }, section: activeSection }), _jsx("div", { className: "px-2", children: _jsx(SidebarTree, { activeUrl: activeUrl, idScope: sectionScope, nodes: sectionItems, openFirstLevel: true, scrollActive: true, visible: !sectionHidden }) })] })) : null] })] }) }) }));
302
302
  };
303
+ const DesktopTreeSidebar = ({ activeUrl, nodes, rootScope, top, }) => (_jsx("div", { className: "pointer-events-none sticky top-(--fd-docs-row-1) z-20 @min-[961px]:block hidden h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] @min-[961px]:layout:[--fd-sidebar-width:300px] [grid-area:sidebar] *:pointer-events-auto", "data-sidebar-mode": "tree", "data-sidebar-placeholder": true, children: _jsx("aside", { className: "h-full w-[300px] pr-3 text-gray-900", children: _jsxs("nav", { "aria-label": "Documentation", className: "geistdocs-sidebar-scroll h-full w-full overflow-auto overflow-x-hidden px-3 pt-14 pb-1 outline-none", "data-geistdocs-sidebar-scroll": true, children: [top ? _jsx("div", { className: "pb-3", children: top }) : null, _jsx(SidebarTree, { activeUrl: activeUrl, idScope: rootScope, nodes: nodes, openFirstLevel: true, scrollActive: true })] }) }) }));
304
+ const DesktopSidebar = ({ mode, ...props }) => {
305
+ if (mode === "tree") {
306
+ return _jsx(DesktopTreeSidebar, { ...props });
307
+ }
308
+ return _jsx(DesktopSectionsSidebar, { ...props });
309
+ };
303
310
  const MobileSidebar = ({ activeUrl, idScope, nodes, onOpenChange, open, top, }) => (_jsx(Sheet, { onOpenChange: onOpenChange, open: open, children: _jsxs(SheetContent, { className: "w-full gap-0 bg-background-200 p-0 sm:max-w-none", "data-geistdocs-mobile-sidebar": true, overlay: false, side: "left", children: [_jsxs(SheetHeader, { className: "h-16 shrink-0 justify-center border-b px-4 py-0", children: [_jsx(SheetTitle, { className: "text-label-16", children: "Browse" }), _jsx(SheetDescription, { className: "sr-only", children: "Navigation for the documentation." })] }), _jsxs("nav", { "aria-label": "Documentation", className: "flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-3 text-gray-900", "data-geistdocs-sidebar-scroll": true, children: [_jsx("div", { className: "pb-4 [&>button]:w-full", children: _jsx(SearchButton, { onClick: () => onOpenChange(false) }) }), top ? _jsx("div", { className: "pb-4", children: top }) : null, _jsx(SidebarTree, { activeUrl: activeUrl, idScope: idScope, nodes: nodes, onNavigate: () => onOpenChange(false), scrollActive: true, visible: open })] })] }) }));
304
- export const GeistdocsSidebar = ({ showDesktop = true, top, }) => {
311
+ export const GeistdocsSidebar = ({ mode = "sections", showDesktop = true, top, }) => {
305
312
  const { root, full } = useTreeContext();
306
313
  const { isOpen, setIsOpen } = useGeistdocsSidebar();
307
314
  const containerMarkerRef = useRef(null);
@@ -327,5 +334,5 @@ export const GeistdocsSidebar = ({ showDesktop = true, top, }) => {
327
334
  }
328
335
  return observeSidebarContainer(container, () => setIsOpen(false));
329
336
  }, [setIsOpen]);
330
- return (_jsxs(_Fragment, { children: [_jsx("span", { hidden: true, ref: containerMarkerRef }), showDesktop ? (_jsx(DesktopSidebar, { activeUrl: activeUrl, nodes: root.children, rootScope: rootScope, top: top }, root.$id)) : null, _jsx(MobileSidebar, { activeUrl: activeUrl, idScope: rootScope, nodes: root.children, onOpenChange: setIsOpen, open: isOpen, top: top })] }));
337
+ return (_jsxs(_Fragment, { children: [_jsx("span", { hidden: true, ref: containerMarkerRef }), showDesktop ? (_jsx(DesktopSidebar, { activeUrl: activeUrl, mode: mode, nodes: root.children, rootScope: rootScope, top: top }, root.$id)) : null, _jsx(MobileSidebar, { activeUrl: activeUrl, idScope: rootScope, nodes: root.children, onOpenChange: setIsOpen, open: isOpen, top: top })] }));
331
338
  };
package/dist/layout.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  import { DocsLayout as FumadocsDocsLayout } from "fumadocs-ui/layouts/docs";
2
2
  import type { ComponentProps, ReactNode } from "react";
3
3
  import type { GeistdocsConfig } from "./config";
4
+ import { type GeistdocsSidebarMode } from "./sidebar";
4
5
  export declare const GeistdocsProvider: (props: import("./internal/provider-client").GeistdocsProviderProps) => import("react/jsx-runtime").JSX.Element;
5
6
  interface GeistdocsDocsLayoutProps {
6
7
  children: ReactNode;
7
8
  config: Pick<GeistdocsConfig, "defaultLanguage" | "translations">;
8
9
  containerProps?: ComponentProps<typeof FumadocsDocsLayout>["containerProps"];
10
+ sidebarMode?: GeistdocsSidebarMode;
9
11
  sidebarTop?: ReactNode;
10
12
  tree: ComponentProps<typeof FumadocsDocsLayout>["tree"];
11
13
  }
12
- export declare const GeistdocsDocsLayout: ({ config, containerProps, sidebarTop, tree, children, }: GeistdocsDocsLayoutProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const GeistdocsDocsLayout: ({ config, containerProps, sidebarMode, sidebarTop, tree, children, }: GeistdocsDocsLayoutProps) => import("react/jsx-runtime").JSX.Element;
13
15
  export {};
14
16
  //# sourceMappingURL=layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,eAAO,MAAM,iBAAiB,iHAA0B,CAAC;AAEzD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7E,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,IAAI,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,GAAI,yDAMjC,wBAAwB,4CAkC1B,CAAC"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhD,OAAO,EAAE,KAAK,oBAAoB,EAA4B,MAAM,WAAW,CAAC;AAEhF,eAAO,MAAM,iBAAiB,iHAA0B,CAAC;AAEzD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7E,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,IAAI,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,GAAI,sEAOjC,wBAAwB,4CAkC1B,CAAC"}
package/dist/layout.js CHANGED
@@ -5,7 +5,7 @@ import { GeistdocsProvider as GeistdocsProviderClient } from "./internal/provide
5
5
  import { GeistdocsSidebar } from "./internal/sidebar";
6
6
  import { GeistdocsSidebarProvider } from "./sidebar";
7
7
  export const GeistdocsProvider = GeistdocsProviderClient;
8
- export const GeistdocsDocsLayout = ({ config, containerProps, sidebarTop, tree, children, }) => {
8
+ export const GeistdocsDocsLayout = ({ config, containerProps, sidebarMode, sidebarTop, tree, children, }) => {
9
9
  const { i18n } = createGeistdocsI18n(config);
10
10
  return (_jsx(GeistdocsSidebarProvider, { children: _jsx(FumadocsDocsLayout, { containerProps: {
11
11
  ...containerProps,
@@ -19,7 +19,7 @@ export const GeistdocsDocsLayout = ({ config, containerProps, sidebarTop, tree,
19
19
  enabled: false,
20
20
  }, sidebar: {
21
21
  collapsible: false,
22
- component: _jsx(GeistdocsSidebar, { top: sidebarTop }),
22
+ component: _jsx(GeistdocsSidebar, { mode: sidebarMode, top: sidebarTop }),
23
23
  }, tabMode: "auto", themeSwitch: {
24
24
  enabled: false,
25
25
  }, tree: tree, children: children }) }));
package/dist/mdx.d.ts CHANGED
@@ -21,6 +21,7 @@ export declare const geistdocsFrontmatterSchema: import("zod").ZodObject<{
21
21
  prerequisites: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
22
22
  related: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
23
23
  summary: import("zod").ZodOptional<import("zod").ZodString>;
24
+ lastModified: import("zod").ZodOptional<import("zod").ZodCoercedDate<unknown>>;
24
25
  internal: import("zod").ZodOptional<import("zod").ZodBoolean>;
25
26
  noindex: import("zod").ZodOptional<import("zod").ZodBoolean>;
26
27
  tags: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
package/dist/mdx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAkB/C,OAAO,EAGL,KAAK,4BAA4B,IAAI,mBAAmB,EAGzD,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,2BAA2B,8EAAe,CAAC;AACxD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAoB,CAAC;AAC5D,eAAO,MAAM,mBAAmB;;;;;;;gCAAa,CAAC;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAAa,CAAC;AAC1C,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,eAAO,MAAM,yBAAyB,GACpC,aAAa,sBAAsB,KAClC,sBA8BD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,sBAAsB,KAClC,sBAA+D,CAAC;AAEnE,eAAO,MAAM,2BAA2B,GACtC,GAAG,eAAe,KAAK,CAAC,sBAAsB,GAAG,SAAS,CAAC,KAC1D,sBACkD,CAAC"}
1
+ {"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAkB/C,OAAO,EAGL,KAAK,4BAA4B,IAAI,mBAAmB,EAGzD,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,2BAA2B,8EAAe,CAAC;AACxD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAoB,CAAC;AAC5D,eAAO,MAAM,mBAAmB;;;;;;;gCAAa,CAAC;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAAa,CAAC;AAC1C,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,eAAO,MAAM,yBAAyB,GACpC,aAAa,sBAAsB,KAClC,sBA8BD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,sBAAsB,KAClC,sBAA+D,CAAC;AAEnE,eAAO,MAAM,2BAA2B,GACtC,GAAG,eAAe,KAAK,CAAC,sBAAsB,GAAG,SAAS,CAAC,KAC1D,sBACkD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../src/routes/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,WAAW,CAAC;AAChE,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAKhF,UAAU,WAAW;IACnB,IAAI,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,IAAI,CAAC;KACrB,GAAG,2BAA2B,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,UAAU,aAAa;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;CACvC;AAED,KAAK,kBAAkB,GAAG,qBAAqB,GAAG,aAAa,CAAC;AAEhE,UAAU,cAAc;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,iCAAiC;IACzC,MAAM,EAAE,IAAI,CACV,eAAe,EACf,UAAU,GAAG,iBAAiB,GAAG,cAAc,CAChD,CAAC;IACF,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,CACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KACtB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC/B;AAoMD,eAAO,MAAM,0BAA0B,GAAI,gDAMxC,iCAAiC;gBAK1B,WAAW,cACL;QAAE,MAAM,EAAE,OAAO,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE;;;;;;CA4DpD,CAAC"}
1
+ {"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../src/routes/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,WAAW,CAAC;AAChE,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAKhF,UAAU,WAAW;IACnB,IAAI,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,IAAI,CAAC;KACrB,GAAG,2BAA2B,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,UAAU,aAAa;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;CACvC;AAED,KAAK,kBAAkB,GAAG,qBAAqB,GAAG,aAAa,CAAC;AAEhE,UAAU,cAAc;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,iCAAiC;IACzC,MAAM,EAAE,IAAI,CACV,eAAe,EACf,UAAU,GAAG,iBAAiB,GAAG,cAAc,CAChD,CAAC;IACF,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,CACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KACtB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC/B;AAuMD,eAAO,MAAM,0BAA0B,GAAI,gDAMxC,iCAAiC;gBAK1B,WAAW,cACL;QAAE,MAAM,EAAE,OAAO,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE;;;;;;CA4DpD,CAAC"}
@@ -86,7 +86,7 @@ function truncateToWords(text, maxWords) {
86
86
  }
87
87
  return `${words.slice(0, maxWords).join(" ")}...`;
88
88
  }
89
- function renderNode(node, indent, parentTitle) {
89
+ function renderNode(node, indent, parentPath) {
90
90
  const prefix = " ".repeat(indent);
91
91
  const lines = [];
92
92
  const segments = [];
@@ -98,9 +98,12 @@ function renderNode(node, indent, parentTitle) {
98
98
  if (summary) {
99
99
  segments.push(`Summary: ${truncateToWords(summary, 100)}`);
100
100
  }
101
+ // Explicit frontmatter prerequisites are public paths; the fallback for
102
+ // pages without them is the parent page's public path so the field keeps
103
+ // one vocabulary (paths, never titles) across sites.
101
104
  const prereqs = node.prerequisites && node.prerequisites.length > 0
102
105
  ? node.prerequisites.join(", ")
103
- : parentTitle;
106
+ : parentPath;
104
107
  if (prereqs) {
105
108
  segments.push(`Prerequisites: ${prereqs}`);
106
109
  }
@@ -111,7 +114,7 @@ function renderNode(node, indent, parentTitle) {
111
114
  lines.push(`${prefix}- [${node.title}](${node.url}) | ${segments.join(" | ")}`);
112
115
  for (const child of node.children) {
113
116
  lines.push("");
114
- lines.push(renderNode(child, indent + 1, node.title));
117
+ lines.push(renderNode(child, indent + 1, node.url));
115
118
  }
116
119
  return lines.join("\n");
117
120
  }
package/dist/sidebar.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type Dispatch, type ReactNode, type SetStateAction } from "react";
2
+ export type GeistdocsSidebarMode = "sections" | "tree";
2
3
  interface GeistdocsSidebarContextValue {
3
4
  isOpen: boolean;
4
5
  setIsOpen: Dispatch<SetStateAction<boolean>>;
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../src/sidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,UAAU,4BAA4B;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CAC9C;AAKD,eAAO,MAAM,wBAAwB,GAAI,eAEtC;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,4CASA,CAAC;AAEF,eAAO,MAAM,mBAAmB,oCAU/B,CAAC"}
1
+ {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../src/sidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,MAAM,CAAC;AAEvD,UAAU,4BAA4B;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CAC9C;AAKD,eAAO,MAAM,wBAAwB,GAAI,eAEtC;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,4CASA,CAAC;AAEF,eAAO,MAAM,mBAAmB,oCAU/B,CAAC"}
@@ -44,6 +44,7 @@ export declare const geistdocsFrontmatterSchema: z.ZodObject<{
44
44
  prerequisites: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
45
  related: z.ZodOptional<z.ZodArray<z.ZodString>>;
46
46
  summary: z.ZodOptional<z.ZodString>;
47
+ lastModified: z.ZodOptional<z.ZodCoercedDate<unknown>>;
47
48
  internal: z.ZodOptional<z.ZodBoolean>;
48
49
  noindex: z.ZodOptional<z.ZodBoolean>;
49
50
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1 +1 @@
1
- {"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAsG3B,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAAa,CAAC;AAE9C,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CAuB1C,CAAC"}
1
+ {"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAsG3B,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuCrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAAa,CAAC;AAE9C,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CAuB1C,CAAC"}
@@ -2,7 +2,7 @@ import { remarkMdxMermaid } from "fumadocs-core/mdx-plugins";
2
2
  import { defineConfig as defineFumadocsConfig, frontmatterSchema, metaSchema, } from "fumadocs-mdx/config";
3
3
  import lastModified from "fumadocs-mdx/plugins/last-modified";
4
4
  import { z } from "zod";
5
- import { getGitLastModified } from "./internal/last-modified.js";
5
+ import { getLastModified } from "./internal/last-modified.js";
6
6
  export const geistShikiTheme = {
7
7
  name: "geist",
8
8
  type: "dark",
@@ -132,6 +132,7 @@ export const geistdocsFrontmatterSchema = frontmatterSchema.extend({
132
132
  .array(z.string().regex(/^\/.*/, { message: "related must start with a slash" }))
133
133
  .optional(),
134
134
  summary: z.string().optional(),
135
+ lastModified: z.coerce.date().optional(),
135
136
  internal: z.boolean().optional(),
136
137
  noindex: z.boolean().optional(),
137
138
  tags: z.array(z.string()).optional(),
@@ -159,7 +160,7 @@ export const defineGeistdocsSourceConfig = (config = {}) => {
159
160
  },
160
161
  },
161
162
  plugins: [
162
- lastModified({ versionControl: getGitLastModified }),
163
+ lastModified({ versionControl: getLastModified }),
163
164
  ...existingPlugins,
164
165
  ],
165
166
  });
package/docs/agents.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Geistdocs Package Docs
2
2
 
3
- These docs are bundled with `@vercel/geistdocs` 1.17.1 so agents can understand the installed package without web access.
3
+ These docs are bundled with `@vercel/geistdocs` 1.19.0 so agents can understand the installed package without web access.
4
4
  They are generated from `apps/template/content/docs` during the package build.
5
5
 
6
6
  ## How to use these files
package/docs/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Geistdocs Package Documentation
2
2
 
3
- These docs are bundled with `@vercel/geistdocs` 1.17.1.
3
+ These docs are bundled with `@vercel/geistdocs` 1.19.0.
4
4
  They describe how to build package-backed Geistdocs sites and how to use the package APIs from generated project adapters.
5
5
 
6
6
  ## Documentation Index
@@ -1018,6 +1018,26 @@ excludeFrom:
1018
1018
 
1019
1019
  Optional `tags`, `keywords`, and `canonical` frontmatter are also recognized by the package runtime.
1020
1020
 
1021
+ ## Last modified dates
1022
+
1023
+ `sitemap.md` entries include a `Lastmod` field and RSS items carry a publish date when a page has a last-modified date. Geistdocs resolves the date for each page in this order:
1024
+
1025
+ 1. The page's `lastModified` frontmatter value.
1026
+ 2. The file's most recent git commit date.
1027
+ 3. No date. The sitemap entry omits `Lastmod` and the RSS item falls back to the build date.
1028
+
1029
+ Set `lastModified` in frontmatter when a page needs a stable, editor-controlled date:
1030
+
1031
+ ```mdx title="content/docs/example.mdx"
1032
+ ---
1033
+ title: Example page
1034
+ description: An example documentation page
1035
+ lastModified: 2026-07-01
1036
+ ---
1037
+ ```
1038
+
1039
+ Git-based dates require full git history at build time. Vercel builds use a shallow clone by default, so pages that were not changed in the cloned history have no reachable commit date and their entries omit `Lastmod`. To make git-based dates work on Vercel, set the `VERCEL_DEEP_CLONE=true` environment variable on your project so builds clone the full history.
1040
+
1021
1041
  ## User-owned adapters
1022
1042
 
1023
1043
  Adapter files are safe to edit. Package updates do not overwrite them.
@@ -2623,7 +2643,21 @@ This configuration produces three labeled groups after the two introductory page
2623
2643
 
2624
2644
  The `...` entry inserts every page or folder that is not named elsewhere in the array. Place it where the remaining items should appear. Without `...`, unnamed items do not appear in that folder's sidebar navigation.
2625
2645
 
2626
- On desktop, top-level folders open as dedicated sidebar sections. On mobile, Geistdocs renders the same page tree as expandable nested navigation. Both layouts use the same `meta.json` files.
2646
+ By default, top-level folders open as dedicated sidebar sections on desktop. To keep every folder in one expandable tree instead, set `sidebarMode="tree"` on the package layout in `components/geistdocs/docs-layout.tsx`:
2647
+
2648
+ ```tsx title="components/geistdocs/docs-layout.tsx"
2649
+ <PackageDocsLayout
2650
+ config={config}
2651
+ sidebarMode="tree"
2652
+ tree={tree}
2653
+ >
2654
+ {children}
2655
+ </PackageDocsLayout>
2656
+ ```
2657
+
2658
+ Tree mode starts first-level folders expanded unless their `meta.json` explicitly sets `"defaultOpen": false`. Readers can collapse any open folder. Nested folders follow their `defaultOpen` setting and automatically open when they contain the active page.
2659
+
2660
+ On mobile, Geistdocs always renders the same page tree as expandable nested navigation. Both desktop modes and the mobile sidebar use the same `meta.json` files.
2627
2661
 
2628
2662
  ## Add a folder landing page
2629
2663
 
@@ -3318,7 +3352,7 @@ The feed automatically includes:
3318
3352
 
3319
3353
  ### Last Modified Dates
3320
3354
 
3321
- Pages use their `lastModified` frontmatter field or fall back to the current date:
3355
+ Pages use their `lastModified` frontmatter field, then the file's most recent git commit date, and fall back to the current date:
3322
3356
 
3323
3357
  ```mdx title="content/docs/example.mdx"
3324
3358
  ---
@@ -3328,6 +3362,8 @@ lastModified: 2025-11-12
3328
3362
  ---
3329
3363
  ```
3330
3364
 
3365
+ Git commit dates require full git history at build time. On Vercel, set the `VERCEL_DEEP_CLONE=true` environment variable so builds clone the full history. Read [Last modified dates](/docs/configuration#last-modified-dates) for the full resolution order.
3366
+
3331
3367
 
3332
3368
  ---
3333
3369
 
@@ -208,5 +208,5 @@
208
208
  }
209
209
  ],
210
210
  "source": "apps/template/content/docs",
211
- "version": "1.17.1"
211
+ "version": "1.19.0"
212
212
  }
@@ -254,6 +254,26 @@ excludeFrom:
254
254
 
255
255
  Optional `tags`, `keywords`, and `canonical` frontmatter are also recognized by the package runtime.
256
256
 
257
+ ## Last modified dates
258
+
259
+ `sitemap.md` entries include a `Lastmod` field and RSS items carry a publish date when a page has a last-modified date. Geistdocs resolves the date for each page in this order:
260
+
261
+ 1. The page's `lastModified` frontmatter value.
262
+ 2. The file's most recent git commit date.
263
+ 3. No date. The sitemap entry omits `Lastmod` and the RSS item falls back to the build date.
264
+
265
+ Set `lastModified` in frontmatter when a page needs a stable, editor-controlled date:
266
+
267
+ ```mdx title="content/docs/example.mdx"
268
+ ---
269
+ title: Example page
270
+ description: An example documentation page
271
+ lastModified: 2026-07-01
272
+ ---
273
+ ```
274
+
275
+ Git-based dates require full git history at build time. Vercel builds use a shallow clone by default, so pages that were not changed in the cloned history have no reachable commit date and their entries omit `Lastmod`. To make git-based dates work on Vercel, set the `VERCEL_DEEP_CLONE=true` environment variable on your project so builds clone the full history.
276
+
257
277
  ## User-owned adapters
258
278
 
259
279
  Adapter files are safe to edit. Package updates do not overwrite them.
@@ -75,7 +75,21 @@ This configuration produces three labeled groups after the two introductory page
75
75
 
76
76
  The `...` entry inserts every page or folder that is not named elsewhere in the array. Place it where the remaining items should appear. Without `...`, unnamed items do not appear in that folder's sidebar navigation.
77
77
 
78
- On desktop, top-level folders open as dedicated sidebar sections. On mobile, Geistdocs renders the same page tree as expandable nested navigation. Both layouts use the same `meta.json` files.
78
+ By default, top-level folders open as dedicated sidebar sections on desktop. To keep every folder in one expandable tree instead, set `sidebarMode="tree"` on the package layout in `components/geistdocs/docs-layout.tsx`:
79
+
80
+ ```tsx title="components/geistdocs/docs-layout.tsx"
81
+ <PackageDocsLayout
82
+ config={config}
83
+ sidebarMode="tree"
84
+ tree={tree}
85
+ >
86
+ {children}
87
+ </PackageDocsLayout>
88
+ ```
89
+
90
+ Tree mode starts first-level folders expanded unless their `meta.json` explicitly sets `"defaultOpen": false`. Readers can collapse any open folder. Nested folders follow their `defaultOpen` setting and automatically open when they contain the active page.
91
+
92
+ On mobile, Geistdocs always renders the same page tree as expandable nested navigation. Both desktop modes and the mobile sidebar use the same `meta.json` files.
79
93
 
80
94
  ## Add a folder landing page
81
95
 
package/docs/pages/rss.md CHANGED
@@ -101,7 +101,7 @@ The feed automatically includes:
101
101
 
102
102
  ### Last Modified Dates
103
103
 
104
- Pages use their `lastModified` frontmatter field or fall back to the current date:
104
+ Pages use their `lastModified` frontmatter field, then the file's most recent git commit date, and fall back to the current date:
105
105
 
106
106
  ```mdx title="content/docs/example.mdx"
107
107
  ---
@@ -110,3 +110,5 @@ description: An example documentation page
110
110
  lastModified: 2025-11-12
111
111
  ---
112
112
  ```
113
+
114
+ Git commit dates require full git history at build time. On Vercel, set the `VERCEL_DEEP_CLONE=true` environment variable so builds clone the full history. Read [Last modified dates](/docs/configuration#last-modified-dates) for the full resolution order.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vercel/geistdocs",
3
3
  "description": "Runtime and CLI for Geistdocs projects.",
4
- "version": "1.17.1",
4
+ "version": "1.19.0",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -296,7 +296,7 @@
296
296
  "zod": "^4.1.13"
297
297
  },
298
298
  "peerDependencies": {
299
- "next": "16.2.6",
299
+ "next": "^16.2.11",
300
300
  "react": "^19.2.3",
301
301
  "react-dom": "^19.2.3",
302
302
  "tailwindcss": "^4.1.17"
@@ -310,7 +310,7 @@
310
310
  "@types/react": "^19.2.7",
311
311
  "@types/react-dom": "^19.2.3",
312
312
  "mdast-util-mdx-jsx": "^3.2.0",
313
- "next": "16.2.6",
313
+ "next": "16.2.12",
314
314
  "react": "^19.2.3",
315
315
  "react-dom": "^19.2.3",
316
316
  "tsup": "^8.5.1",
package/source-config.js CHANGED
@@ -1,3 +1,7 @@
1
+ import { execFile } from "node:child_process";
2
+ import { readFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { promisify } from "node:util";
1
5
  import { remarkMdxMermaid } from "fumadocs-core/mdx-plugins";
2
6
  import {
3
7
  defineConfig as defineFumadocsConfig,
@@ -7,6 +11,83 @@ import {
7
11
  import lastModified from "fumadocs-mdx/plugins/last-modified";
8
12
  import { z } from "zod";
9
13
 
14
+ // Mirrors src/internal/last-modified.ts. This file must stay dependency-free
15
+ // on dist so source.config.ts can load it before the package is built.
16
+ const execFileAsync = promisify(execFile);
17
+
18
+ const FRONTMATTER_BLOCK_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---/;
19
+ const LAST_MODIFIED_KEY_PATTERN =
20
+ /^lastModified:\s*(?:"([^"]*)"|'([^']*)'|([^#\n]+?))\s*$/m;
21
+
22
+ const readFrontmatterLastModified = async (filePath) => {
23
+ try {
24
+ const contents = await readFile(filePath, "utf8");
25
+ const block = contents.match(FRONTMATTER_BLOCK_PATTERN)?.[1];
26
+ if (!block) {
27
+ return null;
28
+ }
29
+ const match = block.match(LAST_MODIFIED_KEY_PATTERN);
30
+ if (!match) {
31
+ return null;
32
+ }
33
+ const value = match[1] ?? match[2] ?? match[3];
34
+ const date = new Date(value);
35
+ return Number.isNaN(date.getTime()) ? null : date;
36
+ } catch {
37
+ return null;
38
+ }
39
+ };
40
+
41
+ // Resolves a page's last-modified date frontmatter-first, then the file's
42
+ // git author time, then null so surfaces omit the date. The frontmatter
43
+ // override keeps dates working on shallow clones, where git history for
44
+ // untouched files is unavailable.
45
+ const createLastModified = ({
46
+ cwd = process.cwd(),
47
+ gitBinary = "git",
48
+ } = {}) => {
49
+ const cache = new Map();
50
+ const gitAvailable = execFileAsync(
51
+ gitBinary,
52
+ ["rev-parse", "--is-inside-work-tree"],
53
+ { cwd }
54
+ )
55
+ .then(({ stdout }) => stdout.trim() === "true")
56
+ .catch(() => false);
57
+
58
+ const gitLastModified = async (filePath) => {
59
+ if (!(await gitAvailable)) {
60
+ return null;
61
+ }
62
+ try {
63
+ const { stdout } = await execFileAsync(
64
+ gitBinary,
65
+ ["log", "-1", "--pretty=%aI", "--", path.relative(cwd, filePath)],
66
+ { cwd }
67
+ );
68
+ const date = new Date(stdout.trim());
69
+ return Number.isNaN(date.getTime()) ? null : date;
70
+ } catch {
71
+ return null;
72
+ }
73
+ };
74
+
75
+ return (filePath) => {
76
+ const cached = cache.get(filePath);
77
+ if (cached) {
78
+ return cached;
79
+ }
80
+
81
+ const result = readFrontmatterLastModified(filePath).then(
82
+ (fromFrontmatter) => fromFrontmatter ?? gitLastModified(filePath)
83
+ );
84
+ cache.set(filePath, result);
85
+ return result;
86
+ };
87
+ };
88
+
89
+ const getLastModified = createLastModified();
90
+
10
91
  export const geistShikiTheme = {
11
92
  name: "geist",
12
93
  type: "dark",
@@ -141,6 +222,7 @@ export const geistdocsFrontmatterSchema = frontmatterSchema.extend({
141
222
  )
142
223
  .optional(),
143
224
  summary: z.string().optional(),
225
+ lastModified: z.coerce.date().optional(),
144
226
  internal: z.boolean().optional(),
145
227
  noindex: z.boolean().optional(),
146
228
  tags: z.array(z.string()).optional(),
@@ -170,6 +252,9 @@ export const defineGeistdocsSourceConfig = (config = {}) => {
170
252
  defaultColor: "light",
171
253
  },
172
254
  },
173
- plugins: [lastModified(), ...existingPlugins],
255
+ plugins: [
256
+ lastModified({ versionControl: getLastModified }),
257
+ ...existingPlugins,
258
+ ],
174
259
  });
175
260
  };
@@ -252,6 +252,26 @@ excludeFrom:
252
252
 
253
253
  Optional `tags`, `keywords`, and `canonical` frontmatter are also recognized by the package runtime.
254
254
 
255
+ ## Last modified dates
256
+
257
+ `sitemap.md` entries include a `Lastmod` field and RSS items carry a publish date when a page has a last-modified date. Geistdocs resolves the date for each page in this order:
258
+
259
+ 1. The page's `lastModified` frontmatter value.
260
+ 2. The file's most recent git commit date.
261
+ 3. No date. The sitemap entry omits `Lastmod` and the RSS item falls back to the build date.
262
+
263
+ Set `lastModified` in frontmatter when a page needs a stable, editor-controlled date:
264
+
265
+ ```mdx title="content/docs/example.mdx"
266
+ ---
267
+ title: Example page
268
+ description: An example documentation page
269
+ lastModified: 2026-07-01
270
+ ---
271
+ ```
272
+
273
+ Git-based dates require full git history at build time. Vercel builds use a shallow clone by default, so pages that were not changed in the cloned history have no reachable commit date and their entries omit `Lastmod`. To make git-based dates work on Vercel, set the `VERCEL_DEEP_CLONE=true` environment variable on your project so builds clone the full history.
274
+
255
275
  ## User-owned adapters
256
276
 
257
277
  Adapter files are safe to edit. Package updates do not overwrite them.
@@ -72,7 +72,21 @@ This configuration produces three labeled groups after the two introductory page
72
72
 
73
73
  The `...` entry inserts every page or folder that is not named elsewhere in the array. Place it where the remaining items should appear. Without `...`, unnamed items do not appear in that folder's sidebar navigation.
74
74
 
75
- On desktop, top-level folders open as dedicated sidebar sections. On mobile, Geistdocs renders the same page tree as expandable nested navigation. Both layouts use the same `meta.json` files.
75
+ By default, top-level folders open as dedicated sidebar sections on desktop. To keep every folder in one expandable tree instead, set `sidebarMode="tree"` on the package layout in `components/geistdocs/docs-layout.tsx`:
76
+
77
+ ```tsx title="components/geistdocs/docs-layout.tsx"
78
+ <PackageDocsLayout
79
+ config={config}
80
+ sidebarMode="tree"
81
+ tree={tree}
82
+ >
83
+ {children}
84
+ </PackageDocsLayout>
85
+ ```
86
+
87
+ Tree mode starts first-level folders expanded unless their `meta.json` explicitly sets `"defaultOpen": false`. Readers can collapse any open folder. Nested folders follow their `defaultOpen` setting and automatically open when they contain the active page.
88
+
89
+ On mobile, Geistdocs always renders the same page tree as expandable nested navigation. Both desktop modes and the mobile sidebar use the same `meta.json` files.
76
90
 
77
91
  ## Add a folder landing page
78
92
 
@@ -99,7 +99,7 @@ The feed automatically includes:
99
99
 
100
100
  ### Last Modified Dates
101
101
 
102
- Pages use their `lastModified` frontmatter field or fall back to the current date:
102
+ Pages use their `lastModified` frontmatter field, then the file's most recent git commit date, and fall back to the current date:
103
103
 
104
104
  ```mdx title="content/docs/example.mdx"
105
105
  ---
@@ -108,3 +108,5 @@ description: An example documentation page
108
108
  lastModified: 2025-11-12
109
109
  ---
110
110
  ```
111
+
112
+ Git commit dates require full git history at build time. On Vercel, set the `VERCEL_DEEP_CLONE=true` environment variable so builds clone the full history. Read [Last modified dates](/docs/configuration#last-modified-dates) for the full resolution order.
@@ -18,7 +18,7 @@
18
18
  "@streamdown/code": "^1.0.1",
19
19
  "@vercel/agent-readability": "^0.2.1",
20
20
  "@vercel/analytics": "^1.6.1",
21
- "@vercel/geistdocs": "1.17.1",
21
+ "@vercel/geistdocs": "1.19.0",
22
22
  "@vercel/speed-insights": "^1.3.1",
23
23
  "ai": "^6.0.132",
24
24
  "class-variance-authority": "^0.7.1",
@@ -36,7 +36,7 @@
36
36
  "mermaid": "^11.12.2",
37
37
  "motion": "^12.23.25",
38
38
  "nanoid": "^5.1.6",
39
- "next": "16.2.6",
39
+ "next": "16.2.12",
40
40
  "next-themes": "^0.4.6",
41
41
  "radix-ui": "1.6.4",
42
42
  "react": "^19.2.3",