@stacksjs/bunpress 0.1.21 → 0.2.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.
Files changed (54) hide show
  1. package/dist/bin/cli.d.ts +3 -0
  2. package/dist/bin/cli.js +1 -1
  3. package/dist/{chunk-kxr6zf7e.js → chunk-2ns9va8d.js} +1315 -464
  4. package/dist/{chunk-qdmkac4z.js → chunk-av14gbps.js} +10 -11
  5. package/dist/{chunk-m0g9vk1e.js → chunk-avg4ftb9.js} +159 -194
  6. package/dist/chunk-fyb5bzsp.js +10 -0
  7. package/dist/chunk-n0ebp7d8.js +38 -0
  8. package/dist/{chunk-qrp18ybj.js → chunk-trhgd2dy.js} +1 -1
  9. package/dist/chunk-w615shtf.js +2 -0
  10. package/dist/chunk-x5m3c6jd.js +469 -0
  11. package/dist/src/build-manifest.d.ts +22 -0
  12. package/dist/src/config.d.ts +12 -0
  13. package/dist/src/data-loader.d.ts +6 -3
  14. package/dist/src/highlighter.d.ts +2 -1
  15. package/dist/src/i18n.d.ts +67 -0
  16. package/dist/src/index.d.ts +2 -0
  17. package/dist/src/index.js +1 -1
  18. package/dist/src/page-meta.d.ts +19 -0
  19. package/dist/src/search-index.d.ts +61 -0
  20. package/dist/src/serve.d.ts +20 -5
  21. package/dist/src/toc.d.ts +6 -2
  22. package/dist/src/types.d.ts +80 -8
  23. package/dist/templates/blocks/alerts/caution.stx +2 -2
  24. package/dist/templates/blocks/alerts/important.stx +2 -2
  25. package/dist/templates/blocks/alerts/note.stx +2 -2
  26. package/dist/templates/blocks/alerts/tip.stx +2 -2
  27. package/dist/templates/blocks/alerts/warning.stx +2 -2
  28. package/dist/templates/blocks/containers/danger.stx +2 -2
  29. package/dist/templates/blocks/containers/details.stx +2 -2
  30. package/dist/templates/blocks/containers/info.stx +2 -2
  31. package/dist/templates/blocks/containers/raw.stx +1 -1
  32. package/dist/templates/blocks/containers/tip.stx +2 -2
  33. package/dist/templates/blocks/containers/warning.stx +2 -2
  34. package/dist/templates/copy-page.stx +81 -0
  35. package/dist/templates/doc-footer.stx +51 -0
  36. package/dist/templates/footer.stx +45 -0
  37. package/dist/templates/hero.stx +9 -2
  38. package/dist/templates/layout-doc.stx +8 -125
  39. package/dist/templates/layout-home.stx +7 -14
  40. package/dist/templates/layout-page.stx +7 -14
  41. package/dist/templates/locale-switcher.stx +115 -0
  42. package/dist/templates/navbar.stx +49 -0
  43. package/dist/templates/page-outline.stx +149 -0
  44. package/dist/templates/page-toc.stx +1 -1
  45. package/dist/templates/search-algolia.stx +85 -0
  46. package/dist/templates/search.stx +661 -0
  47. package/dist/templates/sidebar-section.stx +44 -11
  48. package/dist/templates/sidebar.stx +11 -2
  49. package/dist/themes/vitepress/index.ts +558 -165
  50. package/package.json +16 -7
  51. package/dist/chunk-9cm3e4r4.js +0 -688
  52. package/dist/chunk-mjhqecp5.js +0 -467
  53. package/dist/chunk-wmvgjzgh.js +0 -3
  54. package/dist/chunk-zmxtnx2v.js +0 -8
@@ -0,0 +1,38 @@
1
+ // @bun
2
+ var W=import.meta.require;var Q={"search.placeholder":"Search documentation","toc.title":"On this page","nav.menu":"Menu","search.noResults":"No results for","theme.toggle":"Toggle dark mode"};function Z(q){let x=q?.i18n,B=(x?.locales??[]).filter(Boolean),G=x?.defaultLocale||B[0]||"en",H=(x?.enabled??B.length>1)&&B.length>0;return{enabled:H,locales:H?B:[G],defaultLocale:G,fallbackLocale:x?.fallbackLocale??G,localePath:x?.localePath??"./locales",detectLocale:x?.detectLocale===!0,localeNames:x?.localeNames??{},localeConfig:x?.localeConfig??{},translate:(J)=>Q[J]??J}}async function $(q,x){if(!q.enabled)return q;try{let{createTranslator:B,loadTranslations:G}=await import("@stacksjs/ts-i18n"),H=await G({translationsDir:q.localePath,defaultLocale:q.defaultLocale,fallbackLocale:q.fallbackLocale,sources:x?.i18n?.sources??["ts","yaml","json"],optional:!0,verbose:!1}),J=B(H,{defaultLocale:q.defaultLocale,fallbackLocale:q.fallbackLocale}),O=new Set;for(let K of Object.values(H))for(let M of Object.keys(K??{}))O.add(M);let R=[...O].sort((K,M)=>K==="theme"?-1:M==="theme"?1:K.localeCompare(M));return{...q,translate:(K,M,V)=>{for(let P of[K,...R.map((N)=>`${N}.${K}`)])try{let N=J(P,M,V);if(typeof N==="string"&&N&&N!==P)return N}catch{}return Q[K]??K}}}catch(B){return console.warn("[bunpress] i18n translations could not be loaded; falling back to defaults \u2014",B instanceof Error?B.message:B),q}}function j(q,x){if(!q.enabled)return{locale:q.defaultLocale,path:x};let B=x.match(/^\/([^/]+)(\/.*)?$/);if(B&&q.locales.includes(B[1])&&B[1]!==q.defaultLocale)return{locale:B[1],path:B[2]||"/"};return{locale:q.defaultLocale,path:x}}function X(q,x,B){if(!q.enabled||x===q.defaultLocale)return B||"/";return`/${x}${B==="/"?"":B}`||`/${x}`}function z(q,x,B,G){let H=G==="/"?"/index":G,J=[];if(q.enabled&&B!==q.defaultLocale)J.push(`${x}/${B}${H}.md`),J.push(`${x}/${B}${H}/index.md`),J.push(`${x}${H}.${B}.md`);if(J.push(`${x}${H}.md`),J.push(`${x}${H}/index.md`),q.enabled)J.push(`${x}${H}.${q.defaultLocale}.md`);return J}function C(q,x,B){let G=x.localeConfig[B];if(!G)return q;return{...q,...G,themeConfig:G.themeConfig?{...q.themeConfig,...G.themeConfig}:q.themeConfig,markdown:G.markdown?{...q.markdown,...G.markdown}:q.markdown}}function A(q,x){return q.localeNames[x]??x}function E(q,x,B){if(!q.enabled)return"";let G=x.sitemap?.baseUrl?.replace(/\/$/,"");if(!G)return"";let H=q.locales.map((J)=>{let O=`${G}${X(q,J,B==="/index"?"/":B)}`;return`<link rel="alternate" hreflang="${J}" href="${O}">`});return H.push(`<link rel="alternate" hreflang="x-default" href="${G}${B==="/index"?"/":B}">`),H.join(`
3
+ `)}function F(q){if(!q.enabled||!q.detectLocale)return"";return`
4
+ (function () {
5
+ var LOCALES = ${JSON.stringify(q.locales)};
6
+ var DEFAULT = ${JSON.stringify(q.defaultLocale)};
7
+ var KEY = 'bunpress-locale';
8
+
9
+ try {
10
+ var current = location.pathname.split('/')[1];
11
+ if (LOCALES.indexOf(current) !== -1) {
12
+ // Reading a non-default locale is itself a choice; remember it.
13
+ localStorage.setItem(KEY, current);
14
+ return;
15
+ }
16
+ if (localStorage.getItem(KEY)) return;
17
+
18
+ var preferred = (navigator.languages || [navigator.language || ''])
19
+ .map(function (tag) { return String(tag).toLowerCase(); });
20
+
21
+ for (var i = 0; i < preferred.length; i++) {
22
+ var tag = preferred[i];
23
+ var exact = LOCALES.indexOf(tag) !== -1 ? tag : null;
24
+ // 'en-GB' should match an 'en' locale.
25
+ var base = exact || (LOCALES.indexOf(tag.split('-')[0]) !== -1 ? tag.split('-')[0] : null);
26
+ if (base && base !== DEFAULT) {
27
+ localStorage.setItem(KEY, base);
28
+ location.replace(\`/\${base}\${location.pathname}\${location.search}\${location.hash}\`);
29
+ return;
30
+ }
31
+ if (base === DEFAULT) return;
32
+ }
33
+ } catch (_) {
34
+ // Storage or history unavailable: leave the reader where they are.
35
+ }
36
+ })();
37
+ `.trim()}
38
+ export{W as X,Z as Y,$ as Z,j as _,X as $,z as aa,C as ba,A as ca,E as da,F as ea};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{A as c,B as d,C as e,D as f,y as a,z as b}from"./chunk-kxr6zf7e.js";import"./chunk-m0g9vk1e.js";import"./chunk-wmvgjzgh.js";export{c as wrapInLayout,b as stripConfiguredBasePath,e as startServer,f as serveCLI,d as markdownToHtml,a as getConfiguredBasePath};
2
+ import{A as c,B as d,C as e,D as f,y as a,z as b}from"./chunk-2ns9va8d.js";import"./chunk-avg4ftb9.js";import"./chunk-n0ebp7d8.js";export{c as wrapInLayout,b as stripConfiguredBasePath,e as startServer,f as serveCLI,d as markdownToHtml,a as getConfiguredBasePath};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$ as d,Y as a,Z as b,_ as c,aa as e,ba as f,ca as g,da as h,ea as i}from"./chunk-n0ebp7d8.js";export{c as splitLocaleFromPath,a as resolveI18nConfig,d as localizeUrl,g as localeLabel,e as localeContentCandidates,b as loadI18nTranslations,i as generateLocaleDetectionScript,h as generateHreflangTags,f as configForLocale};
@@ -0,0 +1,469 @@
1
+ // @bun
2
+ import{M as I4,N as x4,P as S4}from"./chunk-av14gbps.js";import{R as L4,S as O,U as E4,W as F4}from"./chunk-avg4ftb9.js";import{X as E}from"./chunk-n0ebp7d8.js";var{Glob:b4}=globalThis.Bun;import{copyFile as A6,mkdir as y4,readdir as G6,rename as J6,rm as r}from"fs/promises";import{existsSync as M6}from"fs";import{join as F,resolve as V6}from"path";import S from"process";import{CLI as B6}from"@stacksjs/clapp";var d="0.2.0";var{Glob:g4}=globalThis.Bun;import{dirname as c4,relative as d4,resolve as f,sep as Z4}from"path";import{mkdir as f4}from"fs/promises";function $4(K){return Z4==="/"?K:K.split(Z4).join("/")}function u4(K){let Z=new Bun.CryptoHasher("sha256");return Z.update(K),Z.digest("hex")}async function Y4(K,Z,Q){let $=f(K),Y=Q?$4(d4($,f(Q))):void 0,X=[],N=new g4("**/*");for await(let R of N.scan({cwd:$,onlyFiles:!0})){let _=$4(R);if(_===Y)continue;X.push(_)}X.sort((R,_)=>R.localeCompare(_));let q=[],U=new Bun.CryptoHasher("sha256");for(let R of X){let _=new Uint8Array(await Bun.file(f($,R)).arrayBuffer()),W=u4(_);q.push({path:R,bytes:_.byteLength,sha256:W}),U.update(`${R}\x00${_.byteLength}\x00${W}
3
+ `)}return{schema_version:1,generator:"bunpress",generator_version:Z,outputs:q,tree_sha256:U.digest("hex")}}async function N4(K,Z,Q){let $=await Y4(K,Q,Z);return await f4(c4(f(Z)),{recursive:!0}),await Bun.write(Z,`${JSON.stringify($,null,2)}
4
+ `),$}function X4(K){return new Map(K.outputs.map((Z)=>[Z.path,Z]))}async function q4(K,Z,Q){let $=await Bun.file(Z).json();if($.schema_version!==1||$.generator!=="bunpress"||!Array.isArray($.outputs))throw Error(`Unsupported or malformed BunPress build manifest: ${Z}`);let Y=await Y4(K,Q,Z);if(JSON.stringify(Y)===JSON.stringify($))return Y;let X=X4($),N=X4(Y),q=Y.outputs.filter((W)=>!X.has(W.path)).map((W)=>W.path),U=$.outputs.filter((W)=>!N.has(W.path)).map((W)=>W.path),R=Y.outputs.filter((W)=>{let j=X.get(W.path);return j&&(j.bytes!==W.bytes||j.sha256!==W.sha256)}).map((W)=>{let j=X.get(W.path);return`${W.path} [bytes ${j.bytes} -> ${W.bytes}; sha256 ${j.sha256} -> ${W.sha256}]`}),_=[$.generator_version!==Y.generator_version?`generator ${$.generator_version} -> ${Y.generator_version}`:"",q.length?`added: ${q.join(", ")}`:"",U.length?`removed: ${U.join(", ")}`:"",R.length?`changed: ${R.join(", ")}`:""].filter(Boolean);throw Error(`BunPress output does not match ${Z}: ${_.join("; ")||"tree hash changed"}`)}import{existsSync as p4}from"fs";import{rm as l4}from"fs/promises";import{join as a4}from"path";var x={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m"};function z(K,Z){return`${x[Z]}${K}${x.reset}`}function T(K){console.log(`${x.green}\u2713${x.reset} ${K}`)}function A(K){console.error(`${x.red}\u2717${x.reset} ${K}`)}function u(K){console.warn(`${x.yellow}\u26A0${x.reset} ${K}`)}function M(K){console.log(`${x.blue}\u2139${x.reset} ${K}`)}function b(K){if(K===0)return"0 B";let Z=1024,Q=["B","KB","MB","GB"],$=Math.floor(Math.log(K)/Math.log(Z));return`${Number.parseFloat((K/Z**$).toFixed(2))} ${Q[$]}`}function a(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var H4=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class C{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];index=0;interval=null;text;constructor(K){this.text=K}start(){if(H4){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${x.cyan}${K}${x.reset} ${this.text}`),this.index=(this.index+1)%this.frames.length},80)}succeed(K){this.stop(),T(K||this.text)}fail(K){this.stop(),A(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!H4)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function p(K,Z=!1){let Q=Z?"Y/n":"y/N";process.stdout.write(`${x.cyan}?${x.reset} ${K} ${x.dim}(${Q})${x.reset}: `);let $=Bun.file("/dev/stdin").stream().getReader(),Y=new TextDecoder,{value:X}=await $.read(),N=Y.decode(X).trim().toLowerCase();if(!N)return Z;return N==="y"||N==="yes"}function m(K){if(K.length===0)return;let Z=Object.keys(K[0]),Q={};for(let Y of Z)Q[Y]=Math.max(Y.length,...K.map((X)=>String(X[Y]).length));let $=Z.map((Y)=>Y.padEnd(Q[Y])).join(" ");console.log(z($,"bold")),console.log("\u2500".repeat($.length));for(let Y of K){let X=Z.map((N)=>String(Y[N]).padEnd(Q[N])).join(" ");console.log(X)}}async function l(K){try{return Bun.file(K).size}catch{return 0}}async function n4(K){try{let{Glob:Z}=awaitPromise.resolve(globalThis.Bun),Q=new Z("**/*"),$=0;for await(let Y of Q.scan(K)){let X=`${K}/${Y}`,N=await l(X);$+=N}return $}catch{return 0}}async function _4(K={}){let Z=await O,Q=K.outdir||Z.outDir||"./dist",$=a4(Q,".bunpress"),Y=K.force||!1,X=K.verbose||!1;try{if(!p4($))return M(`Directory "${$}" does not exist, nothing to clean`),!0;let q=await n4($);if(X)M(`Found "${$}" (${b(q)})`);if(!Y){if(!await p(`Delete "${$}" directory? (${b(q)})`,!1))return M("Clean cancelled"),!1}let U=process.env.VITEST==="true"||!1,R=null;if(!U&&!X)R=new C("Cleaning build artifacts..."),R.start();if(await l4($,{recursive:!0,force:!0}),R)R.succeed(`Cleaned ${b(q)} from "${$}"`);else if(X||U)T(`Cleaned ${b(q)} from "${$}"`);return!0}catch(N){return A(`Failed to clean directory: ${N}`),!1}}import{existsSync as n}from"fs";import{join as i}from"path";async function W4(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let Y of Z){let X=i(process.cwd(),Y);if(n(X)){Q=X;break}}if(!Q)return A("No configuration file found"),M('Run "bunpress config init" to create one'),!1;T(`Configuration file: ${Q}`),console.log();let $=await Bun.file(Q).text();return console.log(z("Configuration:","bold")),console.log($),!0}catch(Z){return A(`Failed to show configuration: ${Z}`),!1}}async function U4(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let q of Q){let U=i(process.cwd(),q);if(n(U)){$=U;break}}if(!$)return A("No configuration file found"),!1;if(Z)M(`Validating ${$}...`);let X=(await import($)).default;if(!X)return A("Configuration file does not export a default object"),!1;let N=[];if(X.markdown){if(X.markdown.toc&&typeof X.markdown.toc!=="object"&&typeof X.markdown.toc!=="boolean")N.push("markdown.toc should be an object or boolean");if(X.markdown.features){if(typeof X.markdown.features!=="object")N.push("markdown.features should be an object")}}if(X.nav){if(!Array.isArray(X.nav))N.push("nav should be an array");else for(let[q,U]of X.nav.entries())if(!U.text||!U.link)N.push(`nav[${q}] is missing required fields (text, link)`)}if(X.sitemap){if(!X.sitemap.hostname)N.push("sitemap.hostname is required for SEO")}if(N.length>0){A("Configuration validation failed:");for(let q of N)console.log(` \u2022 ${q}`);return!1}return T("Configuration is valid \u2713"),!0}catch(Q){return A(`Failed to validate configuration: ${Q}`),!1}}async function R4(K={}){let Z=i(process.cwd(),"bunpress.config.ts");if(n(Z))return A("Configuration file already exists"),!1;let Q=`import type { BunPressConfig } from '@stacksjs/bunpress'
5
+
6
+ export default {
7
+ verbose: false,
8
+
9
+ markdown: {
10
+ toc: {
11
+ enabled: true,
12
+ position: 'sidebar',
13
+ minDepth: 2,
14
+ maxDepth: 3,
15
+ },
16
+ features: {
17
+ inlineFormatting: true,
18
+ containers: true,
19
+ githubAlerts: true,
20
+ codeBlocks: {
21
+ lineNumbers: true,
22
+ lineHighlighting: true,
23
+ focus: true,
24
+ diff: true,
25
+ errorWarning: true,
26
+ },
27
+ codeGroups: true,
28
+ codeImports: true,
29
+ inlineToc: true,
30
+ customAnchors: true,
31
+ emoji: true,
32
+ badges: true,
33
+ includes: true,
34
+ externalLinks: {
35
+ enabled: true,
36
+ openInNewTab: true,
37
+ addIcon: true,
38
+ },
39
+ imageLazyLoading: true,
40
+ tables: {
41
+ responsive: true,
42
+ striped: true,
43
+ hover: true,
44
+ },
45
+ },
46
+ },
47
+
48
+ nav: [
49
+ { text: 'Home', link: '/' },
50
+ { text: 'Guide', link: '/guide/' },
51
+ ],
52
+
53
+ sitemap: {
54
+ hostname: 'https://example.com',
55
+ },
56
+ } satisfies BunPressConfig
57
+ `;try{return await Bun.write(Z,Q),T(`Created ${Z}`),!0}catch($){return A(`Failed to create configuration: ${$}`),!1}}import{existsSync as k}from"fs";import{join as P}from"path";async function j4(K={}){let Z=K.verbose||!1,Q=[];console.log(z(`
58
+ Running diagnostics...
59
+ `,"bold"));try{let H=Bun.version;Q.push({name:"Bun Runtime",status:"pass",message:`v${H}`})}catch(H){Q.push({name:"Bun Runtime",status:"fail",message:"Not found"})}let $=["bunpress.config.ts","bunpress.config.js"],Y=!1;for(let H of $)if(k(P(process.cwd(),H))){Y=!0,Q.push({name:"Configuration",status:"pass",message:H});break}if(!Y)Q.push({name:"Configuration",status:"warn",message:"No config file found (using defaults)"});let X=P(process.cwd(),"docs");if(k(X)){let{Glob:H}=awaitPromise.resolve(globalThis.Bun),V=new H("**/*.md"),I=0;for await(let D of V.scan(X))I++;Q.push({name:"Documentation",status:I>0?"pass":"warn",message:`${I} markdown files`})}else Q.push({name:"Documentation",status:"fail",message:"docs/ directory not found"});let N=P(process.cwd(),"package.json");if(k(N)){let H=await Bun.file(N).json(),V=H.scripts?.dev,I=H.scripts?.build;Q.push({name:"Package Scripts",status:V&&I?"pass":"warn",message:`dev: ${V?"\u2713":"\u2717"}, build: ${I?"\u2713":"\u2717"}`});let D=H.dependencies?.["@stacksjs/bunpress"]||H.devDependencies?.["@stacksjs/bunpress"];Q.push({name:"BunPress Package",status:D?"pass":"warn",message:D||"Not installed"})}else Q.push({name:"Package.json",status:"warn",message:"Not found"});let q=P(process.cwd(),"node_modules");if(k(q))Q.push({name:"Dependencies",status:"pass",message:"node_modules found"});else Q.push({name:"Dependencies",status:"warn",message:"node_modules not found (run: bun install)"});let U=P(process.cwd(),".git");if(k(U))Q.push({name:"Git Repository",status:"pass",message:"Initialized"});else Q.push({name:"Git Repository",status:"warn",message:"Not initialized"});let R=P(process.cwd(),"tsconfig.json");if(k(R))Q.push({name:"TypeScript",status:"pass",message:"tsconfig.json found"});else Q.push({name:"TypeScript",status:"warn",message:"tsconfig.json not found"});for(let H of Q){let V=H.status==="pass"?"\u2713":H.status==="fail"?"\u2717":"\u26A0",I=H.status==="pass"?"green":H.status==="fail"?"red":"yellow";console.log(` ${z(V,I)} ${H.name}: ${z(H.message,"dim")}`)}console.log();let _=Q.filter((H)=>H.status==="pass").length,W=Q.filter((H)=>H.status==="fail").length,j=Q.filter((H)=>H.status==="warn").length;if(W>0){if(A(`${W} checks failed, ${j} warnings`),console.log(),M("Recommended actions:"),Q.find((H)=>H.name==="Documentation"&&H.status==="fail"))console.log(' \u2022 Run "bunpress init" to create docs directory');if(Q.find((H)=>H.name==="Dependencies"&&H.status==="warn"))console.log(' \u2022 Run "bun install" to install dependencies');if(Q.find((H)=>H.name==="BunPress Package"&&H.status==="warn"))console.log(' \u2022 Run "bun add @stacksjs/bunpress" to install BunPress');return!1}else if(j>0)return u(`${_} checks passed, ${j} warnings`),!0;else return T(`All ${_} checks passed!`),!0}import{mkdir as s}from"fs/promises";var i4=`import type { BunPressConfig } from '@stacksjs/bunpress'
60
+
61
+ export default {
62
+ verbose: false,
63
+
64
+ markdown: {
65
+ toc: {
66
+ enabled: true,
67
+ position: 'sidebar',
68
+ minDepth: 2,
69
+ maxDepth: 3,
70
+ },
71
+ features: {
72
+ inlineFormatting: true,
73
+ containers: true,
74
+ githubAlerts: true,
75
+ codeBlocks: {
76
+ lineNumbers: true,
77
+ lineHighlighting: true,
78
+ focus: true,
79
+ diff: true,
80
+ errorWarning: true,
81
+ },
82
+ codeGroups: true,
83
+ codeImports: true,
84
+ inlineToc: true,
85
+ customAnchors: true,
86
+ emoji: true,
87
+ badges: true,
88
+ includes: true,
89
+ externalLinks: {
90
+ enabled: true,
91
+ openInNewTab: true,
92
+ addIcon: true,
93
+ },
94
+ imageLazyLoading: true,
95
+ tables: {
96
+ responsive: true,
97
+ striped: true,
98
+ hover: true,
99
+ },
100
+ },
101
+ },
102
+
103
+ nav: [
104
+ { text: 'Home', link: '/' },
105
+ { text: 'Guide', link: '/guide/' },
106
+ { text: 'GitHub', link: 'https://github.com/stacksjs/bunpress' },
107
+ ],
108
+
109
+ sitemap: {
110
+ hostname: 'https://example.com',
111
+ },
112
+ } satisfies BunPressConfig
113
+ `,s4=`---
114
+ layout: home
115
+ title: Welcome to My Documentation
116
+
117
+ hero:
118
+ name: My Project
119
+ text: Modern documentation made easy
120
+ tagline: Fast, flexible, and beautiful documentation powered by BunPress
121
+ actions:
122
+ - theme: brand
123
+ text: Get Started
124
+ link: /guide/
125
+ - theme: alt
126
+ text: View on GitHub
127
+ link: https://github.com/yourusername/your-repo
128
+
129
+ features:
130
+ - icon: \u26A1
131
+ title: Lightning Fast
132
+ details: Powered by Bun runtime for incredible build and dev server performance
133
+ - icon: \uD83C\uDFA8
134
+ title: Beautiful by Default
135
+ details: Clean, modern design with dark mode support out of the box
136
+ - icon: \uD83D\uDCDD
137
+ title: Markdown Enhanced
138
+ details: Extended markdown features including containers, code groups, and more
139
+ ---
140
+
141
+ # Welcome
142
+
143
+ This is your new BunPress documentation site. Start editing files in the \`docs/\` directory to customize your content.
144
+ `,r4=`# Getting Started
145
+
146
+ Welcome to the getting started guide!
147
+
148
+ ## Installation
149
+
150
+ \`\`\`bash
151
+ bun install @stacksjs/bunpress
152
+ \`\`\`
153
+
154
+ ## Quick Start
155
+
156
+ Create your first documentation page:
157
+
158
+ \`\`\`bash
159
+ bunpress new my-page
160
+ \`\`\`
161
+
162
+ ## Next Steps
163
+
164
+ ::: tip
165
+ Check out the [markdown extensions](/guide/markdown) to learn about all the powerful features available.
166
+ :::
167
+
168
+ - Learn about [configuration](/guide/configuration)
169
+ - Explore [advanced features](/guide/advanced)
170
+ - Read the [API reference](/api/)
171
+ `,o4=`node_modules/
172
+ dist/
173
+ .DS_Store
174
+ *.log
175
+ .env
176
+ .env.*
177
+ !.env.example
178
+ `,e4=`# My BunPress Documentation
179
+
180
+ Documentation powered by [BunPress](https://github.com/stacksjs/bunpress).
181
+
182
+ ## Development
183
+
184
+ Start the dev server:
185
+
186
+ \`\`\`bash
187
+ bun run dev
188
+ \`\`\`
189
+
190
+ ## Build
191
+
192
+ Build the documentation:
193
+
194
+ \`\`\`bash
195
+ bun run build
196
+ \`\`\`
197
+
198
+ ## Preview
199
+
200
+ Preview the built site:
201
+
202
+ \`\`\`bash
203
+ bun run preview
204
+ \`\`\`
205
+ `;async function A4(K={}){try{if(await Bun.file("./docs").exists()&&!K.force){if(!await p("Documentation directory already exists. Continue?",!1))return M("Initialization cancelled"),!1}let Q=new C("Initializing BunPress project...");Q.start(),await s("./docs",{recursive:!0}),await s("./docs/guide",{recursive:!0}),await s("./docs/public",{recursive:!0}),await Bun.write("./bunpress.config.ts",i4),await Bun.write("./docs/index.md",s4),await Bun.write("./docs/guide/index.md",r4);let $=await Bun.file("./.gitignore").exists();if(!$)await Bun.write("./.gitignore",o4);let Y=await Bun.file("./README.md").exists();if(!Y)await Bun.write("./README.md",e4);let X="./package.json";if(await Bun.file(X).exists()){let q=await Bun.file(X).json();q.scripts=q.scripts||{},q.scripts.dev=q.scripts.dev||"bunpress dev",q.scripts.build=q.scripts.build||"bunpress build",q.scripts.preview=q.scripts.preview||"bunpress preview",await Bun.write(X,JSON.stringify(q,null,2))}if(Q.succeed("BunPress project initialized successfully!"),console.log(),T("Created files:"),console.log(" \u2022 bunpress.config.ts"),console.log(" \u2022 docs/index.md"),console.log(" \u2022 docs/guide/index.md"),console.log(" \u2022 docs/public/"),!$)console.log(" \u2022 .gitignore");if(!Y)console.log(" \u2022 README.md");return console.log(),M("Next steps:"),console.log(" 1. Install BunPress: bun add @stacksjs/bunpress"),console.log(" 2. Start dev server: bun run dev"),console.log(" 3. Edit docs/index.md to customize your home page"),!0}catch(Z){return A(`Failed to initialize project: ${Z}`),!1}}import{mkdir as t4}from"fs/promises";import{dirname as K6,join as Q6}from"path";var G4={default:(K)=>`---
206
+ title: ${K}
207
+ description:
208
+ ---
209
+
210
+ # ${K}
211
+
212
+ Your content goes here...
213
+ `,guide:(K)=>`---
214
+ title: ${K}
215
+ description: ${K} guide
216
+ ---
217
+
218
+ # ${K}
219
+
220
+ ## Introduction
221
+
222
+ Brief introduction to the topic.
223
+
224
+ ## Getting Started
225
+
226
+ Step-by-step instructions.
227
+
228
+ ## Examples
229
+
230
+ \`\`\`typescript
231
+ // Example code
232
+ \`\`\`
233
+
234
+ ## Next Steps
235
+
236
+ - [ ] Task 1
237
+ - [ ] Task 2
238
+ `,api:(K)=>`---
239
+ title: ${K}
240
+ description: API reference for ${K}
241
+ ---
242
+
243
+ # ${K}
244
+
245
+ ## Overview
246
+
247
+ Brief overview of the API.
248
+
249
+ ## Methods
250
+
251
+ ### \`methodName()\`
252
+
253
+ Description of the method.
254
+
255
+ **Parameters:**
256
+
257
+ - \`param1\` (\`type\`) - Description
258
+
259
+ **Returns:**
260
+
261
+ - \`ReturnType\` - Description
262
+
263
+ **Example:**
264
+
265
+ \`\`\`typescript
266
+ // Example usage
267
+ \`\`\`
268
+ `,blog:(K)=>`---
269
+ title: ${K}
270
+ description:
271
+ date: ${new Date().toISOString().split("T")[0]}
272
+ author:
273
+ tags: []
274
+ ---
275
+
276
+ # ${K}
277
+
278
+ Post content goes here...
279
+
280
+ ## Section 1
281
+
282
+ Content...
283
+ `};async function J4(K,Z={}){try{let Q=K.endsWith(".md")?K:`${K}.md`,$=Q6(process.cwd(),"docs",Q);if(await Bun.file($).exists())return A(`File already exists: ${Q}`),!1;let X=Z.title;if(!X)X=(Q.split("/").pop()?.replace(".md","")||"").split("-").map((W)=>W.charAt(0).toUpperCase()+W.slice(1)).join(" ");let N=Z.template||"default",q=G4[N];if(!q)return A(`Unknown template: ${N}`),A(`Available templates: ${Object.keys(G4).join(", ")}`),!1;let U=q(X),R=K6($);return await t4(R,{recursive:!0}),await Bun.write($,U),T(`Created ${Q}`),console.log(),console.log(` Title: ${X}`),console.log(` Template: ${N}`),console.log(` Path: ${$}`),!0}catch(Q){return A(`Failed to create file: ${Q}`),!1}}import{join as M4}from"path";async function V4(K={}){let Z=K.port||3000,Q=await O,$=K.outdir||Q.outDir||"./dist",Y=M4($,".bunpress"),X=K.verbose||!1;try{let{stat:N}=await import("fs/promises");try{if(!(await N(Y)).isDirectory())A(`"${Y}" is not a directory.`),A('Run "bunpress build" first to generate the documentation.'),process.exit(1)}catch{A(`Build directory "${Y}" not found.`),A('Run "bunpress build" first to generate the documentation.'),process.exit(1)}M(`Starting preview server from ${Y}`);try{let q=Bun.serve({port:Z,fetch:async(U)=>{let _=new URL(U.url).pathname;if(_.startsWith("/"))_=_.slice(1);if(_===""||_==="/")_="index.html";let W=M4(Y,_),j=Bun.file(W);if(await j.exists())return new Response(j,{headers:{"Content-Type":Z6(_)}});let V=`${W}.html`,I=Bun.file(V);if(await I.exists())return new Response(I,{headers:{"Content-Type":"text/html"}});return new Response("404 - Not Found",{status:404})}});T(`Preview server running at http://localhost:${Z}`),console.log(`Press Ctrl+C to stop
284
+ `),await new Promise(()=>{})}catch(q){if(q.message?.includes("EADDRINUSE")||q.code==="EADDRINUSE")A(`Port ${Z} is already in use.`),A("Try running with a different port: bunpress preview --port <port>"),A(`Or stop any processes using port ${Z}`);else A(`Failed to start server: ${q.message||q}`);process.exit(1)}}catch(N){A(`Failed to start preview server: ${N}`),process.exit(1)}}function Z6(K){let Z=K.split(".").pop()?.toLowerCase();return{html:"text/html",css:"text/css",js:"application/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",ico:"image/x-icon",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",eot:"application/vnd.ms-fontobject"}[Z||""]||"text/plain"}import*as v from"fs";import*as y from"path";var{YAML:B4}=globalThis.Bun;async function T4(K={}){let Z=await O,Q=K.dir||Z.docsDir||"./docs",$=K.fix||!1;if(M("\uD83D\uDD0D Running SEO checks..."),console.log(""),!v.existsSync(Q))A(`Documentation directory not found: ${Q}`),process.exit(1);let Y={totalPages:0,errors:[],warnings:[],passed:0},X=await Y6(Q);Y.totalPages=X.length;for(let N of X)await $6(N,Q,Y,$);if(U6(Y),Y.errors.length>0)process.exit(1)}async function $6(K,Z,Q,$){let Y=await v.promises.readFile(K,"utf-8"),{frontmatter:X,markdown:N}=N6(Y),q=y.relative(Z,K),U=!1,R=$&&Object.keys(X).length>0,_={...X};if(!X.title){let H=q6(N);if(!H)Q.errors.push({type:"error",category:"Title",file:q,message:"Missing title in frontmatter"}),U=!0;else if($)_.title=H,R=!0,M(`\u2713 Added title to ${q}: "${H}"`);else Q.warnings.push({type:"warning",category:"Title",file:q,message:`No title in frontmatter (could extract: "${H}")`}),U=!0}else{let H=X.title.length;if(H>60)Q.warnings.push({type:"warning",category:"Title",file:q,message:`Title too long (${H} chars, recommended <60)`}),U=!0;else if(H<10)Q.warnings.push({type:"warning",category:"Title",file:q,message:`Title too short (${H} chars, recommended >10)`}),U=!0}if(!X.description){let H=H6(N);if($)_.description=H,R=!0,M(`\u2713 Added description to ${q}`);else Q.warnings.push({type:"warning",category:"Description",file:q,message:"Missing description in frontmatter"}),U=!0}else{let H=X.description.length;if(H>160)Q.warnings.push({type:"warning",category:"Description",file:q,message:`Description too long (${H} chars, recommended <160)`}),U=!0;else if(H<50)Q.warnings.push({type:"warning",category:"Description",file:q,message:`Description too short (${H} chars, recommended >50)`}),U=!0}let W=_6(N,Z,K);for(let H of W)Q.errors.push({type:"error",category:"Links",file:q,message:`Broken internal link: ${H}`}),U=!0;let j=W6(N);for(let H of j)Q.warnings.push({type:"warning",category:"Images",file:q,message:`Image missing alt text: ${H}`}),U=!0;if(R){let H=X6(_,N);await v.promises.writeFile(K,H,"utf-8")}if(!U)Q.passed++}function X6(K,Z){return`---
285
+ ${B4.stringify(K,null,2)}
286
+ ---
287
+ ${Z}`}async function Y6(K){let Z=[];async function Q($){let Y=await v.promises.readdir($,{withFileTypes:!0});for(let X of Y){let N=y.join($,X.name);if(X.isDirectory()){if(!X.name.startsWith(".")&&X.name!=="node_modules"&&X.name!=="public")await Q(N)}else if(X.isFile()&&X.name.endsWith(".md"))Z.push(N)}}return await Q(K),Z}function N6(K){let Z=/^---\n([\s\S]*?)\n---\n?/,Q=K.match(Z);if(!Q)return{frontmatter:{},markdown:K};let $=Q[1],Y=K.slice(Q[0].length);try{return{frontmatter:B4.parse($),markdown:Y}}catch{return{frontmatter:{},markdown:K}}}function q6(K){let Z=K.match(/^#\s+(.+)$/m);return Z?Z[1].trim():null}function H6(K,Z=155){let Q=K.replace(/^#{1,6}\s+.+$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"").replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_~]/g,"").trim(),$=Q.split(`
288
+
289
+ `)[0]||Q;if($.length>Z)return`${$.slice(0,Z)}...`;return $||"Documentation page"}function _6(K,Z,Q){let $=[],Y=/\[([^\]]+)\]\(([^)]+)\)/g,X=K.replace(/```[\s\S]*?```/g,"").replace(/~~~[\s\S]*?~~~/g,"").replace(/`+[^`\n]*`+/g,"").replace(/<!--[\s\S]*?-->/g,""),N;while((N=Y.exec(X))!==null){let q=N[2].trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(q))continue;if(q.startsWith("#"))continue;let U=q.split("#",1)[0].split("?",1)[0];if(!U)continue;let R;try{R=decodeURIComponent(U.replace(/^<|>$/g,""))}catch{$.push(q);continue}let _=R.startsWith("/")?y.resolve(Z,`.${R}`):y.resolve(y.dirname(Q),R);if(!(_.endsWith(".md")?[_]:[_,`${_}.md`,y.join(_,"index.md")]).some((j)=>v.existsSync(j)))$.push(q)}return $}function W6(K){let Z=[],Q=/!\[([^\]]*)\]\(([^)]+)\)/g,$;while(($=Q.exec(K))!==null){let Y=$[1],X=$[2];if(!Y||Y.trim()==="")Z.push(X)}return Z}function U6(K){if(console.log(""),M("\uD83D\uDCCA SEO Report"),console.log(""),console.log(`Total pages checked: ${z(K.totalPages.toString(),"blue")}`),console.log(`Passed: ${z(K.passed.toString(),"green")}`),console.log(`Errors: ${z(K.errors.length.toString(),K.errors.length>0?"red":"green")}`),console.log(`Warnings: ${z(K.warnings.length.toString(),K.warnings.length>0?"yellow":"green")}`),console.log(""),K.errors.length>0){A(`\u2717 ${K.errors.length} errors found:`),console.log("");let Z=K.errors.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));m(Z),console.log("")}if(K.warnings.length>0){u(`\u26A0 ${K.warnings.length} warnings found:`),console.log("");let Z=K.warnings.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));m(Z),console.log("")}if(K.errors.length===0&&K.warnings.length===0)T("\u2713 All SEO checks passed!");else if(K.errors.length===0)T("\u2713 No errors found (only warnings)")}import{join as R6}from"path";async function j6(K){let Z=await Bun.file(K).text(),Q=Z.split(`
290
+ `),$=0,Y=!1,X=[];for(let R of Q){if(R.trim().startsWith("```")){Y=!Y;continue}if(!Y)X.push(R)}$=X.join(" ").split(/\s+/).filter((R)=>R.length>0).length;let q=Q.filter((R)=>R.match(/^#{1,6}\s+/)).length,U=(Z.match(/```/g)||[]).length/2;return{path:K,size:await l(K),lines:Q.length,words:$,headings:q,codeBlocks:Math.floor(U)}}async function z4(K={}){let Z=await O,Q=K.dir||Z.docsDir||"./docs",$=K.verbose||!1;try{console.log(z(`
291
+ Analyzing documentation...
292
+ `,"bold"));let{Glob:Y}=awaitPromise.resolve(globalThis.Bun),X=new Y("**/*.md"),N=[];for await(let B of X.scan(Q)){let G=R6(Q,B),g=await j6(G);N.push(g)}if(N.length===0)return A("No markdown files found"),!1;let q=N.reduce((B,G)=>B+G.size,0),U=N.reduce((B,G)=>B+G.lines,0),R=N.reduce((B,G)=>B+G.words,0),_=N.reduce((B,G)=>B+G.headings,0),W=N.reduce((B,G)=>B+G.codeBlocks,0);if(console.log(z("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${N.length}`),console.log(`Total size: ${b(q)}`),console.log(`Total lines: ${U.toLocaleString()}`),console.log(`Total words: ${R.toLocaleString()}`),console.log(`Headings: ${_}`),console.log(`Code blocks: ${W}`),console.log(),$){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let B=N.map((G)=>({File:G.path.replace(`${Q}/`,""),Size:b(G.size),Lines:G.lines,Words:G.words,Headings:G.headings,"Code Blocks":G.codeBlocks}));m(B),console.log()}let j=q/N.length,H=U/N.length,V=R/N.length;console.log(z("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${b(j)}`),console.log(`Lines: ${Math.round(H)}`),console.log(`Words: ${Math.round(V)}`),console.log();let I=[...N].sort((B,G)=>G.size-B.size).slice(0,5);if(I.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let B of I){let G=B.path.replace(`${Q}/`,"");console.log(` ${G.padEnd(40)} ${b(B.size)}`)}console.log()}let D=Math.ceil(R/200);return M(`Estimated reading time: ${D} minutes`),!0}catch(Y){return A(`Failed to generate statistics: ${Y}`),!1}}var L=new B6("bunpress"),J={outdir:O.outDir||"./dist",docsdir:O.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:O.verbose};async function D4(K){let Z=new b4("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(F(K,$));return Q}async function T6(K,Z,Q=!1){let $=`${Z}/public`;try{await G6($);let Y=new b4("**/*");for await(let X of Y.scan($)){let N=F($,X),q=F(K,X);await y4(F(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await A6(N,q)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}function z6(K,Z,Q){let $=Z.replace(/^\.\//,""),Y=(_)=>_.replace(/^\.\//,"").replace($,"").replace(/^\//,"").replace(/\.md$/,"");if(!Q.enabled)return K.map((_)=>({sourceFile:_,relativePath:Y(_),locale:Q.defaultLocale}));let X=Q.locales,N=new Set(X),q=new Map;for(let _ of X)q.set(_,new Map);let U=new Set;for(let _ of K){let W=Y(_),j=W.split("/");if(j.length>1&&N.has(j[0])&&j[0]!==Q.defaultLocale){let V=j.slice(1).join("/");q.get(j[0]).set(V,_),U.add(V);continue}let H=W.match(/^(.*)\.([A-Za-z-]+)$/);if(H&&N.has(H[2])){q.get(H[2]).set(H[1],_),U.add(H[1]);continue}q.get(Q.defaultLocale).set(W,_),U.add(W)}let R=[];for(let _ of X)for(let W of U){let j=q.get(_).get(W)??q.get(Q.defaultLocale).get(W);if(!j)continue;R.push({sourceFile:j,relativePath:W,locale:_})}return R}async function O6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let Y=await F4(K,Q);if(await Bun.write(F(Z,E4.replace(/^\//,"")),JSON.stringify(Y)),$)console.log(`Indexed ${Y.length} sections for search.`)}catch(Y){if($)console.error("Error generating search index:",Y)}}async function L6(K,Z,Q){try{let $=await O;if($.sitemap?.enabled!==!1&&$.sitemap?.baseUrl)await S4(K,Z,$);if($.robots?.enabled!==!1)await x4(Z,$);if($.rss?.enabled)await I4(K,Z,$,$.rss)}catch($){if(Q)console.error("Error generating SEO files:",$)}}async function I6(K={}){let Z=await O;if(!K.config)return Z;let Q=V6(S.cwd(),K.config);if(!M6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),Y=$.default??$;return L4({...Z,...Y})}async function O4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await I6(K),Q=K.outdir||Z.outDir||J.outdir,$=F(Q,".bunpress"),Y=`${$}.tmp-${S.pid}`,X=K.dir||Z.docsDir||J.docsdir,N=K.verbose??J.verbose,q=K.minify??!1,U=K.sourcemap??!1,R=performance.now(),_=new C("Building documentation...");if(!N)_.start();await r(Y,{recursive:!0,force:!0}),await y4(Y,{recursive:!0});let W=await D4(X);if(W.length===0){if(!N)_.fail("No markdown files found in docs directory");else console.log("No markdown files found in docs directory");return!1}if(N)console.log(`Found ${W.length} markdown files:`),W.forEach((j)=>console.log(`- ${j}`));try{let{markdownToHtml:j,wrapInLayout:H}=await import("./chunk-trhgd2dy.js"),{loadI18nTranslations:V,resolveI18nConfig:I}=await import("./chunk-w615shtf.js"),{mkdir:D,writeFile:B}=await import("fs/promises"),G=await V(I(Z),Z);if(N)console.log("Transforming markdown to HTML...");let g=z6(W,X,G);for(let w of g){let w4=await Bun.file(w.sourceFile).text(),{html:C4,frontmatter:t}=await j(w4,X),h=w.relativePath,v4=`/${h}`,k4=t.layout||"doc",P4=await H(C4,Z,v4,k4,t,{i18n:G,locale:w.locale,sourceFile:w.sourceFile,docsDir:X}),h4=h==="index"||h.endsWith("/index"),K4=w.locale&&w.locale!==G.defaultLocale&&G.enabled?F(Y,w.locale):Y,c=h4?F(K4,`${h}.html`):F(K4,h,"index.html"),Q4=c.substring(0,c.lastIndexOf("/"));if(Q4)await D(Q4,{recursive:!0});if(await B(c,P4),N)console.log(`Generated: ${c}`)}if(N)console.log(`Processed ${W.length} markdown files into ${g.length} pages.`);if(await T6(Y,X,N),await S6(Y),await x6(Y,Z),K.searchIndex!==!1)await O6(X,Y,Z,N||!1);if(await L6(X,Y,N||!1),K.checkManifest)await q4(Y,K.checkManifest,d);if(await r($,{recursive:!0,force:!0}),await J6(Y,$),K.manifest)await N4($,K.manifest,d);let e=performance.now()-R;if(!N)_.succeed(`Built ${W.length} pages to HTML in ${a(e)}`);else T(`Build completed in ${a(e)}`),console.log(`
293
+ Generated ${W.length} HTML files in ${$}`);return!0}catch(j){if(await r(Y,{recursive:!0,force:!0}),!N)_.fail("Build failed");return console.error("Error during build:",j),!1}}async function x6(K,Z){let{wrapInLayout:Q}=await import("./chunk-trhgd2dy.js"),$=`
294
+ <style>
295
+ .NotFound {
296
+ padding: 64px 24px 96px;
297
+ text-align: center;
298
+ }
299
+
300
+ @media (min-width: 768px) {
301
+ .NotFound {
302
+ padding: 96px 32px 168px;
303
+ }
304
+ }
305
+
306
+ .NotFound .code {
307
+ line-height: 64px;
308
+ font-size: 64px;
309
+ font-weight: 600;
310
+ }
311
+
312
+ .NotFound .title {
313
+ padding-top: 12px;
314
+ letter-spacing: 2px;
315
+ line-height: 20px;
316
+ font-size: 20px;
317
+ font-weight: 700;
318
+ }
319
+
320
+ .NotFound .divider {
321
+ margin: 24px auto 18px;
322
+ width: 64px;
323
+ height: 1px;
324
+ background-color: var(--vp-c-divider);
325
+ }
326
+
327
+ .NotFound .quote {
328
+ margin: 0 auto;
329
+ max-width: 256px;
330
+ font-size: 14px;
331
+ font-weight: 500;
332
+ color: var(--vp-c-text-2);
333
+ }
334
+
335
+ .NotFound .action {
336
+ padding-top: 20px;
337
+ }
338
+
339
+ .NotFound .link {
340
+ display: inline-block;
341
+ border: 1px solid var(--vp-c-brand-1);
342
+ border-radius: 16px;
343
+ padding: 3px 16px;
344
+ font-size: 14px;
345
+ font-weight: 500;
346
+ color: var(--vp-c-brand-1);
347
+ transition: border-color 0.25s, color 0.25s;
348
+ text-decoration: none;
349
+ }
350
+
351
+ .NotFound .link:hover {
352
+ border-color: var(--vp-c-brand-2);
353
+ color: var(--vp-c-brand-2);
354
+ }
355
+ </style>
356
+
357
+ <div class="NotFound">
358
+ <p class="code">404</p>
359
+ <h1 class="title">PAGE NOT FOUND</h1>
360
+ <div class="divider"></div>
361
+ <blockquote class="quote">
362
+ But if you don't change your direction, and if you keep looking, you may end up where you are heading.
363
+ </blockquote>
364
+ <div class="action">
365
+ <a class="link" href="/docs/" aria-label="go to home">
366
+ Take me home
367
+ </a>
368
+ </div>
369
+ </div>
370
+ `,Y=await Q(`
371
+ <style>
372
+ .NotFound {
373
+ padding: 64px 24px 96px;
374
+ text-align: center;
375
+ }
376
+
377
+ @media (min-width: 768px) {
378
+ .NotFound {
379
+ padding: 96px 32px 168px;
380
+ }
381
+ }
382
+
383
+ .NotFound .code {
384
+ line-height: 64px;
385
+ font-size: 64px;
386
+ font-weight: 600;
387
+ }
388
+
389
+ .NotFound .title {
390
+ padding-top: 12px;
391
+ letter-spacing: 2px;
392
+ line-height: 20px;
393
+ font-size: 20px;
394
+ font-weight: 700;
395
+ }
396
+
397
+ .NotFound .divider {
398
+ margin: 24px auto 18px;
399
+ width: 64px;
400
+ height: 1px;
401
+ background-color: var(--vp-c-divider);
402
+ }
403
+
404
+ .NotFound .quote {
405
+ margin: 0 auto;
406
+ max-width: 256px;
407
+ font-size: 14px;
408
+ font-weight: 500;
409
+ color: var(--vp-c-text-2);
410
+ }
411
+
412
+ .NotFound .action {
413
+ padding-top: 20px;
414
+ }
415
+
416
+ .NotFound .link {
417
+ display: inline-block;
418
+ border: 1px solid var(--vp-c-brand-1);
419
+ border-radius: 16px;
420
+ padding: 3px 16px;
421
+ font-size: 14px;
422
+ font-weight: 500;
423
+ color: var(--vp-c-brand-1);
424
+ transition: border-color 0.25s, color 0.25s;
425
+ text-decoration: none;
426
+ }
427
+
428
+ .NotFound .link:hover {
429
+ border-color: var(--vp-c-brand-2);
430
+ color: var(--vp-c-brand-2);
431
+ }
432
+ </style>
433
+
434
+ <div class="NotFound">
435
+ <p class="code">404</p>
436
+ <h1 class="title">PAGE NOT FOUND</h1>
437
+ <div class="divider"></div>
438
+ <blockquote class="quote">
439
+ But if you don't change your direction, and if you keep looking, you may end up where you are heading.
440
+ </blockquote>
441
+ <div class="action">
442
+ <a class="link" href="/docs/" aria-label="go to home">
443
+ Take me home
444
+ </a>
445
+ </div>
446
+ </div>
447
+ `,Z,"/404","doc");await Bun.write(F(K,"404.html"),Y)}async function S6(K){let Z=F(K,"index.html");try{if(!await Bun.file(Z).exists())console.error("Warning: No index.html found at root")}catch(Q){console.error("Error checking root index.html:",Q)}}L.command("build","Build the documentation site").option("--outdir <outdir>","Output directory").option("--dir <dir>","Documentation directory").option("--config <config>","Path to config file").option("--minify","Minify output files",{default:!1}).option("--sourcemap","Generate source maps",{default:!1}).option("--manifest <path>","Write a deterministic rendered-tree manifest").option("--check-manifest <path>","Fail unless the rendered tree matches a checked manifest").option("--search-index","Write the client search index (on by default; --no-search-index skips it)",{default:!0}).option("--watch","Watch for changes and rebuild",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await O4(K))S.exit(1);if(K.watch){let{watch:Q}=await import("fs"),$=await O,Y=K.dir||$.docsDir||"./docs";console.log(`
448
+ Watching for changes...`),Q(Y,{recursive:!0},async(X,N)=>{if(N&&N.endsWith(".md"))console.log(`
449
+ Detected change in ${N}, rebuilding...`),await O4(K)}),await new Promise(()=>{})}});L.command("dev","Build and serve documentation using BunPress server").option("--port <port>","Port to listen on",{default:J.port}).option("--dir <dir>","Documentation directory").option("--watch","Watch for changes",{default:J.watch}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{let Z=await O,Q=K.port||J.port,$=K.dir||Z.docsDir||J.docsdir,Y=K.watch??J.watch,X=K.verbose??J.verbose;if(X)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:Y,verbose:X});let{serveCLI:N}=await import("./chunk-trhgd2dy.js");await N({port:Q,root:$,watch:Y,config:Z})});async function E6(K={}){let Z=await O,Q=K.dir||Z.docsDir||J.docsdir,$=K.output||"./docs.md",Y=K.full??!1,X=K.verbose??J.verbose;if(X)console.log(`Generating LLM markdown from ${Q}`),console.log(`Output file: ${$}`),console.log(`Full content: ${Y}`);let N=await D4(Q);if(N.length===0)return console.log("No markdown files found in docs directory"),!1;if(X)console.log(`Found ${N.length} markdown files`);N.sort();let q=`# Documentation
450
+
451
+ `;q+=`Generated: ${new Date().toISOString()}
452
+
453
+ `,q+=`Total files: ${N.length}
454
+
455
+ `,q+=`---
456
+
457
+ `;for(let U of N){let R=U.replace(`${Q}/`,""),_=await Bun.file(U).text();if(X)console.log(`Processing: ${R}`);if(q+=`## File: ${R}
458
+
459
+ `,Y)q+=_,q+=`
460
+
461
+ `;else{let W=_.split(`
462
+ `),j=!1,H="";for(let V of W){if(V.trim()==="---")if(!j){j=!0;continue}else{if(j=!1,H)q+="**Frontmatter:**\n```yaml\n",q+=H,q+="```\n\n",H="";continue}if(j){H+=`${V}
463
+ `;continue}if(V.match(/^#{1,6}\s+/))q+=`${V}
464
+ `}q+=`
465
+ `}q+=`---
466
+
467
+ `}return await Bun.write($,q),console.log(`
468
+ LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(q.length/1024).toFixed(2)} KB`),!0}L.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory",{default:"./docs"}).option("--output <output>","Output file path",{default:"./docs.md"}).option("--full","Include full content (not just titles and headings)",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await E6(K))S.exit(1)});L.command("init","Initialize a new BunPress project").option("--name <name>","Project name").option("--template <template>","Template to use").option("--force","Overwrite existing files",{default:!1}).action(async(K)=>{if(!await A4(K))S.exit(1)});L.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:J.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{await V4(K)});L.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:J.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await _4(K))S.exit(1)});L.command("doctor","Run diagnostic checks on the project").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await j4(K))S.exit(1)});L.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await W4(K))S.exit(1)});L.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await U4(K))S.exit(1)});L.command("config:init","Initialize configuration file").action(async(K)=>{if(!await R4(K))S.exit(1)});L.command("new <path>","Create a new markdown file").option("--title <title>","Page title").option("--template <template>","Template to use (default, guide, api, blog)",{default:"default"}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K,Z)=>{if(!await J4(K,Z))S.exit(1)});L.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory",{default:"./docs"}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await z4(K))S.exit(1)});L.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory",{default:"./docs"}).option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await T4(K)});L.command("deploy","Deploy documentation to AWS using CloudFormation (S3 + CloudFront + Route53)").option("--region <region>","AWS region for S3 bucket",{default:"us-east-1"}).option("--bucket <bucket>","S3 bucket name (auto-generated if not provided)").option("--domain <domain>","Custom domain (e.g., docs.example.com)").option("--subdomain <subdomain>","Subdomain (used with --base-domain)").option("--base-domain <baseDomain>","Base domain (e.g., example.com) - must have Route53 hosted zone").option("--stack-name <stackName>","CloudFormation stack name").option("--hosted-zone-id <hostedZoneId>","Route53 hosted zone ID (auto-detected from domain)").option("--certificate-arn <certificateArn>","ACM certificate ARN (auto-created if not provided)").option("--dry-run","Show configuration without deploying",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-fyb5bzsp.js");if(!await Z(K))S.exit(1)});L.help();L.version(d);var o=Bun.argv[1]||"",F6=o.endsWith("/bunpress")||o.endsWith("/cli.ts")||o.endsWith("/cli.js");if(F6)L.parse();
469
+ export{T as E,A as F,M as G,C as H,D4 as I,I6 as J,O4 as K};
@@ -0,0 +1,22 @@
1
+ declare function sha256(bytes: Uint8Array | string): string;
2
+ /**
3
+ * Describe the complete rendered tree without incorporating mtimes, traversal
4
+ * order, absolute paths, or the manifest itself. Consumers can check this file
5
+ * into evidence and compare builds made on different hosts.
6
+ */
7
+ export declare function createBuildManifest(outdir: string, generatorVersion: string, manifestPath?: string): Promise<BuildManifest>;
8
+ export declare function writeBuildManifest(outdir: string, manifestPath: string, generatorVersion: string): Promise<BuildManifest>;
9
+ /** Verify the rendered tree and report exact added, removed, or changed files. */
10
+ export declare function verifyBuildManifest(outdir: string, manifestPath: string, generatorVersion: string): Promise<BuildManifest>;
11
+ export declare interface BuildManifestEntry {
12
+ path: string
13
+ bytes: number
14
+ sha256: string
15
+ }
16
+ export declare interface BuildManifest {
17
+ schema_version: 1
18
+ generator: 'bunpress'
19
+ generator_version: string
20
+ outputs: BuildManifestEntry[]
21
+ tree_sha256: string
22
+ }
@@ -1,4 +1,16 @@
1
1
  import type { BunPressConfig } from './types';
2
+ /**
3
+ * Run the config through the plugins it declares.
4
+ *
5
+ * `ConfigPlugin` and its four hooks were a documented, typed interface that
6
+ * nothing ever called — a plugin could be written and registered and would
7
+ * simply never run. Hooks apply in declaration order so a later plugin sees
8
+ * what earlier ones produced.
9
+ *
10
+ * A plugin that throws is reported and skipped rather than taking the whole
11
+ * site down: a broken third-party plugin should not make the docs unbuildable.
12
+ */
13
+ export declare function applyConfigPlugins(loaded: BunPressConfig): BunPressConfig;
2
14
  // Backward compatibility - simple config getter
3
15
  export declare function getConfig(): Promise<BunPressConfig>;
4
16
  // Default configuration
@@ -1,7 +1,10 @@
1
1
  /**
2
- * Load all JSON data files from `<rootDir>/.data` into a single object.
3
- * Results are cached per root directory.
2
+ * Load all JSON data files into a single object.
3
+ *
4
+ * `overrideDir` comes from `config.dataDir` and is resolved against the
5
+ * working directory; without it the convention is `<rootDir>/.data`.
6
+ * Results are cached per resolved directory.
4
7
  */
5
- export declare function loadDataFiles(rootDir: string): Promise<Record<string, unknown>>;
8
+ export declare function loadDataFiles(rootDir: string, overrideDir?: string): Promise<Record<string, unknown>>;
6
9
  /** Clear the data cache (used for dev-server hot reloading). */
7
10
  export declare function clearDataCache(): void;
@@ -4,7 +4,8 @@ import type { Highlighter as TSHighlighter } from 'ts-syntax-highlighter';
4
4
  */
5
5
  export declare function resetHighlighter(): void;
6
6
  /**
7
- * Normalizes a language identifier
7
+ * Normalizes a language identifier to its canonical id.
8
+ * Unknown identifiers are returned as-is so the caller can report them.
8
9
  */
9
10
  export declare function normalizeLanguage(lang: string): string;
10
11
  /**