@stacksjs/bunpress 0.2.5 → 0.2.6
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/bin/cli.js +1 -1
- package/dist/{chunk-z4va3kc6.js → chunk-16x1ym5v.js} +1 -1
- package/dist/{chunk-8shhd6mj.js → chunk-3vgez1xt.js} +5 -5
- package/dist/{chunk-0qsf6fdy.js → chunk-dy4way3t.js} +3 -3
- package/dist/{chunk-tg73rxw0.js → chunk-jkykyxmj.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/templates/page-outline.stx +6 -0
- package/dist/templates/page-toc.stx +40 -6
- package/dist/themes/vitepress/index.ts +1 -1
- package/dist/themes/vitepress/vars.css +1 -1
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{t as a,u as b,v as c}from"../chunk-
|
|
3
|
+
import{t as a,u as b,v as c}from"../chunk-3vgez1xt.js";import"../chunk-5cxb3t2e.js";import"../chunk-he00q0q4.js";import"../chunk-3f29kjd8.js";export{b as resolveConfig,a as findMarkdownFiles,c as buildDocs};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{j as a,k as b,l as c,m as d,n as e,o as f}from"./chunk-
|
|
2
|
+
import{j as a,k as b,l as c,m as d,n as e,o as f}from"./chunk-dy4way3t.js";import"./chunk-he00q0q4.js";import"./chunk-3f29kjd8.js";export{c as wrapInLayout,b as stripConfiguredBasePath,e as startServer,f as serveCLI,d as markdownToHtml,a as getConfiguredBasePath};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{A as v4,x as w4,y as C4}from"./chunk-5cxb3t2e.js";import{$ as P4,C as b4,D as z,F as o,I as I4,J as L4,K as x4,Z as k4}from"./chunk-he00q0q4.js";import{aa as F}from"./chunk-3f29kjd8.js";var{Glob:h4}=globalThis.Bun;import{copyFile as I6,mkdir as m4,readdir as L6,rename as x6,rm as t}from"fs/promises";import{existsSync as E6}from"fs";import{join as D,resolve as S6}from"path";import S from"process";import{CLI as F6}from"@stacksjs/clapp";var f="0.2.
|
|
2
|
+
import{A as v4,x as w4,y as C4}from"./chunk-5cxb3t2e.js";import{$ as P4,C as b4,D as z,F as o,I as I4,J as L4,K as x4,Z as k4}from"./chunk-he00q0q4.js";import{aa as F}from"./chunk-3f29kjd8.js";var{Glob:h4}=globalThis.Bun;import{copyFile as I6,mkdir as m4,readdir as L6,rename as x6,rm as t}from"fs/promises";import{existsSync as E6}from"fs";import{join as D,resolve as S6}from"path";import S from"process";import{CLI as F6}from"@stacksjs/clapp";var f="0.2.6";var{Glob:n4}=globalThis.Bun;import{dirname as i4,relative as s4,resolve as d,sep as X4}from"path";import{mkdir as r4}from"fs/promises";function Y4(K){return X4==="/"?K:K.split(X4).join("/")}function o4(K){let Z=new Bun.CryptoHasher("sha256");return Z.update(K),Z.digest("hex")}async function q4(K,Z,Q){let $=d(K),N=Q?Y4(s4($,d(Q))):void 0,X=[],q=new n4("**/*");for await(let j of q.scan({cwd:$,onlyFiles:!0})){let _=Y4(j);if(_===N)continue;X.push(_)}X.sort((j,_)=>j.localeCompare(_));let Y=[],W=new Bun.CryptoHasher("sha256");for(let j of X){let _=new Uint8Array(await Bun.file(d($,j)).arrayBuffer()),R=o4(_);Y.push({path:j,bytes:_.byteLength,sha256:R}),W.update(`${j}\x00${_.byteLength}\x00${R}
|
|
3
3
|
`)}return{schema_version:1,generator:"bunpress",generator_version:Z,outputs:Y,tree_sha256:W.digest("hex")}}async function H4(K,Z,Q){let $=await q4(K,Q,Z);return await r4(i4(d(Z)),{recursive:!0}),await Bun.write(Z,`${JSON.stringify($,null,2)}
|
|
4
4
|
`),$}function N4(K){return new Map(K.outputs.map((Z)=>[Z.path,Z]))}async function _4(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 N=await q4(K,Q,Z);if(JSON.stringify(N)===JSON.stringify($))return N;let X=N4($),q=N4(N),Y=N.outputs.filter((R)=>!X.has(R.path)).map((R)=>R.path),W=$.outputs.filter((R)=>!q.has(R.path)).map((R)=>R.path),j=N.outputs.filter((R)=>{let G=X.get(R.path);return G&&(G.bytes!==R.bytes||G.sha256!==R.sha256)}).map((R)=>{let G=X.get(R.path);return`${R.path} [bytes ${G.bytes} -> ${R.bytes}; sha256 ${G.sha256} -> ${R.sha256}]`}),_=[$.generator_version!==N.generator_version?`generator ${$.generator_version} -> ${N.generator_version}`:"",Y.length?`added: ${Y.join(", ")}`:"",W.length?`removed: ${W.join(", ")}`:"",j.length?`changed: ${j.join(", ")}`:""].filter(Boolean);throw Error(`BunPress output does not match ${Z}: ${_.join("; ")||"tree hash changed"}`)}import{existsSync as t4}from"fs";import{rm as e4}from"fs/promises";import{join as K6}from"path";var L={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 O(K,Z){return`${L[Z]}${K}${L.reset}`}function T(K){console.log(`${L.green}\u2713${L.reset} ${K}`)}function U(K){console.error(`${L.red}\u2717${L.reset} ${K}`)}function p(K){console.warn(`${L.yellow}\u26A0${L.reset} ${K}`)}function M(K){console.log(`${L.blue}\u2139${L.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 W4=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class v{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];index=0;interval=null;text;constructor(K){this.text=K}start(){if(W4){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${L.cyan}${K}${L.reset} ${this.text}`),this.index=(this.index+1)%this.frames.length},80)}succeed(K){this.stop(),T(K||this.text)}fail(K){this.stop(),U(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!W4)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function c(K,Z=!1){let Q=Z?"Y/n":"y/N";process.stdout.write(`${L.cyan}?${L.reset} ${K} ${L.dim}(${Q})${L.reset}: `);let $=Bun.file("/dev/stdin").stream().getReader(),N=new TextDecoder,{value:X}=await $.read(),q=N.decode(X).trim().toLowerCase();if(!q)return Z;return q==="y"||q==="yes"}function m(K){if(K.length===0)return;let Z=Object.keys(K[0]),Q={};for(let N of Z)Q[N]=Math.max(N.length,...K.map((X)=>String(X[N]).length));let $=Z.map((N)=>N.padEnd(Q[N])).join(" ");console.log(O($,"bold")),console.log("\u2500".repeat($.length));for(let N of K){let X=Z.map((q)=>String(N[q]).padEnd(Q[q])).join(" ");console.log(X)}}async function l(K){try{return Bun.file(K).size}catch{return 0}}async function Q6(K){try{let{Glob:Z}=awaitPromise.resolve(globalThis.Bun),Q=new Z("**/*"),$=0;for await(let N of Q.scan(K)){let X=`${K}/${N}`,q=await l(X);$+=q}return $}catch{return 0}}async function R4(K={}){let Z=await z,Q=K.outdir||Z.outDir||"./dist",$=K6(Q,".bunpress"),N=K.force||!1,X=K.verbose||!1;try{if(!t4($))return M(`Directory "${$}" does not exist, nothing to clean`),!0;let Y=await Q6($);if(X)M(`Found "${$}" (${b(Y)})`);if(!N){if(!await c(`Delete "${$}" directory? (${b(Y)})`,!1))return M("Clean cancelled"),!1}let W=process.env.VITEST==="true"||!1,j=null;if(!W&&!X)j=new v("Cleaning build artifacts..."),j.start();if(await e4($,{recursive:!0,force:!0}),j)j.succeed(`Cleaned ${b(Y)} from "${$}"`);else if(X||W)T(`Cleaned ${b(Y)} from "${$}"`);return!0}catch(q){return U(`Failed to clean directory: ${q}`),!1}}import{existsSync as n}from"fs";import{join as i}from"path";async function j4(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let N of Z){let X=i(process.cwd(),N);if(n(X)){Q=X;break}}if(!Q)return U("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(O("Configuration:","bold")),console.log($),!0}catch(Z){return U(`Failed to show configuration: ${Z}`),!1}}async function G4(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let Y of Q){let W=i(process.cwd(),Y);if(n(W)){$=W;break}}if(!$)return U("No configuration file found"),!1;if(Z)M(`Validating ${$}...`);let X=(await import($)).default;if(!X)return U("Configuration file does not export a default object"),!1;let q=[];if(X.markdown){if(X.markdown.toc&&typeof X.markdown.toc!=="object"&&typeof X.markdown.toc!=="boolean")q.push("markdown.toc should be an object or boolean");if(X.markdown.features){if(typeof X.markdown.features!=="object")q.push("markdown.features should be an object")}}if(X.nav){if(!Array.isArray(X.nav))q.push("nav should be an array");else for(let[Y,W]of X.nav.entries())if(!W.text||!W.link)q.push(`nav[${Y}] is missing required fields (text, link)`)}if(X.sitemap){if(!X.sitemap.hostname)q.push("sitemap.hostname is required for SEO")}if(q.length>0){U("Configuration validation failed:");for(let Y of q)console.log(` \u2022 ${Y}`);return!1}return T("Configuration is valid \u2713"),!0}catch(Q){return U(`Failed to validate configuration: ${Q}`),!1}}async function U4(K={}){let Z=i(process.cwd(),"bunpress.config.ts");if(n(Z))return U("Configuration file already exists"),!1;let Q=`import type { BunPressConfig } from '@stacksjs/bunpress'
|
|
5
5
|
|
|
@@ -290,8 +290,8 @@ ${Z}`}async function U6(K){let Z=[];async function Q($){let N=await w.promises.r
|
|
|
290
290
|
`)){let X=N.match(/^#{1,6}\s+(.*)$/);if(!X)continue;let q=X[1].trim(),Y=q.match(/\{#([\w-]+)\}\s*$/),W=Y?Y[1]:L4(I4(q));if(!W)continue;x4(W,Q)}}catch{}return O4.set(K,Q),Q}function B6(K){let Z=[],Q=/!\[([^\]]*)\]\(([^)]+)\)/g,$;while(($=Q.exec(K))!==null){let N=$[1],X=$[2];if(!N||N.trim()==="")Z.push(X)}return Z}function T6(K){if(console.log(""),M("\uD83D\uDCCA SEO Report"),console.log(""),console.log(`Total pages checked: ${O(K.totalPages.toString(),"blue")}`),console.log(`Passed: ${O(K.passed.toString(),"green")}`),console.log(`Errors: ${O(K.errors.length.toString(),K.errors.length>0?"red":"green")}`),console.log(`Warnings: ${O(K.warnings.length.toString(),K.warnings.length>0?"yellow":"green")}`),console.log(""),K.errors.length>0){U(`\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){p(`\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 z6}from"path";async function O6(K){let Z=await Bun.file(K).text(),Q=Z.split(`
|
|
291
291
|
`),$=0,N=!1,X=[];for(let j of Q){if(j.trim().startsWith("```")){N=!N;continue}if(!N)X.push(j)}$=X.join(" ").split(/\s+/).filter((j)=>j.length>0).length;let Y=Q.filter((j)=>j.match(/^#{1,6}\s+/)).length,W=(Z.match(/```/g)||[]).length/2;return{path:K,size:await l(K),lines:Q.length,words:$,headings:Y,codeBlocks:Math.floor(W)}}async function y4(K={}){let Z=await z,Q=K.dir||Z.docsDir||"./docs",$=K.verbose||!1;try{console.log(O(`
|
|
292
292
|
Analyzing documentation...
|
|
293
|
-
`,"bold"));let{Glob:N}=awaitPromise.resolve(globalThis.Bun),X=new N("**/*.md"),q=[];for await(let A of X.scan(Q)){let V=z6(Q,A),g=await O6(V);q.push(g)}if(q.length===0)return U("No markdown files found"),!1;let Y=q.reduce((A,V)=>A+V.size,0),W=q.reduce((A,V)=>A+V.lines,0),j=q.reduce((A,V)=>A+V.words,0),_=q.reduce((A,V)=>A+V.headings,0),R=q.reduce((A,V)=>A+V.codeBlocks,0);if(console.log(O("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${q.length}`),console.log(`Total size: ${b(Y)}`),console.log(`Total lines: ${W.toLocaleString()}`),console.log(`Total words: ${j.toLocaleString()}`),console.log(`Headings: ${_}`),console.log(`Code blocks: ${R}`),console.log(),$){console.log(O("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let A=q.map((V)=>({File:V.path.replace(`${Q}/`,""),Size:b(V.size),Lines:V.lines,Words:V.words,Headings:V.headings,"Code Blocks":V.codeBlocks}));m(A),console.log()}let G=Y/q.length,B=W/q.length,H=j/q.length;console.log(O("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${b(G)}`),console.log(`Lines: ${Math.round(B)}`),console.log(`Words: ${Math.round(H)}`),console.log();let x=[...q].sort((A,V)=>V.size-A.size).slice(0,5);if(x.length>0){console.log(O("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let A of x){let V=A.path.replace(`${Q}/`,"");console.log(` ${V.padEnd(40)} ${b(A.size)}`)}console.log()}let E=Math.ceil(j/200);return M(`Estimated reading time: ${E} minutes`),!0}catch(N){return U(`Failed to generate statistics: ${N}`),!1}}var I=new F6("bunpress"),J={outdir:z.outDir||"./dist",docsdir:z.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:z.verbose};async function g4(K){let Z=new h4("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(D(K,$));return Q}async function y6(K,Z,Q=!1){let $=`${Z}/public`;try{await L6($);let N=new h4("**/*");for await(let X of N.scan($)){let q=D($,X),Y=D(K,X);await m4(D(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await I6(q,Y)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}function D6(K,Z,Q){let $=Z.replace(/^\.\//,""),N=(_)=>_.replace(/^\.\//,"").replace($,"").replace(/^\//,"").replace(/\.md$/,"");if(!Q.enabled)return K.map((_)=>({sourceFile:_,relativePath:N(_),locale:Q.defaultLocale}));let X=Q.locales,q=new Set(X),Y=new Map;for(let _ of X)Y.set(_,new Map);let W=new Set;for(let _ of K){let R=N(_),G=R.split("/");if(G.length>1&&q.has(G[0])&&G[0]!==Q.defaultLocale){let H=G.slice(1).join("/");Y.get(G[0]).set(H,_),W.add(H);continue}let B=R.match(/^(.*)\.([A-Za-z-]+)$/);if(B&&q.has(B[2])){Y.get(B[2]).set(B[1],_),W.add(B[1]);continue}Y.get(Q.defaultLocale).set(R,_),W.add(R)}let j=[];for(let _ of X)for(let R of W){let G=Y.get(_).get(R)??Y.get(Q.defaultLocale).get(R);if(!G)continue;j.push({sourceFile:G,relativePath:R,locale:_})}return j}async function b6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let N=await P4(K,Q);if(await Bun.write(D(Z,k4.replace(/^\//,"")),JSON.stringify(N)),$)console.log(`Indexed ${N.length} sections for search.`)}catch(N){if($)console.error("Error generating search index:",N)}}async function w6(K,Z,Q){try{let $=await z;if($.sitemap?.enabled!==!1&&$.sitemap?.baseUrl)await v4(K,Z,$);if($.robots?.enabled!==!1)await C4(Z,$);if($.rss?.enabled)await w4(K,Z,$,$.rss)}catch($){if(Q)console.error("Error generating SEO files:",$)}}async function C6(K={}){let Z=await z;if(!K.config)return Z;let Q=S6(S.cwd(),K.config);if(!E6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),N=$.default??$;return b4({...Z,...N})}async function D4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await C6(K),Q=K.outdir||Z.outDir||J.outdir,$=D(Q,".bunpress"),N=`${$}.tmp-${S.pid}`,X=K.dir||Z.docsDir||J.docsdir,q=K.verbose??J.verbose,Y=K.minify??!1,W=K.sourcemap??!1,j=performance.now(),_=new v("Building documentation...");if(!q)_.start();await t(N,{recursive:!0,force:!0}),await m4(N,{recursive:!0});let R=await g4(X);if(R.length===0){if(!q)_.fail("No markdown files found in docs directory");else console.log("No markdown files found in docs directory");return!1}if(q)console.log(`Found ${R.length} markdown files:`),R.forEach((G)=>console.log(`- ${G}`));try{let{markdownToHtml:G,wrapInLayout:B}=await import("./chunk-
|
|
294
|
-
Generated ${R.length} HTML files in ${$}`);return!0}catch(G){if(await t(N,{recursive:!0,force:!0}),!q)_.fail("Build failed");return console.error("Error during build:",G),!1}}async function v6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-
|
|
293
|
+
`,"bold"));let{Glob:N}=awaitPromise.resolve(globalThis.Bun),X=new N("**/*.md"),q=[];for await(let A of X.scan(Q)){let V=z6(Q,A),g=await O6(V);q.push(g)}if(q.length===0)return U("No markdown files found"),!1;let Y=q.reduce((A,V)=>A+V.size,0),W=q.reduce((A,V)=>A+V.lines,0),j=q.reduce((A,V)=>A+V.words,0),_=q.reduce((A,V)=>A+V.headings,0),R=q.reduce((A,V)=>A+V.codeBlocks,0);if(console.log(O("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${q.length}`),console.log(`Total size: ${b(Y)}`),console.log(`Total lines: ${W.toLocaleString()}`),console.log(`Total words: ${j.toLocaleString()}`),console.log(`Headings: ${_}`),console.log(`Code blocks: ${R}`),console.log(),$){console.log(O("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let A=q.map((V)=>({File:V.path.replace(`${Q}/`,""),Size:b(V.size),Lines:V.lines,Words:V.words,Headings:V.headings,"Code Blocks":V.codeBlocks}));m(A),console.log()}let G=Y/q.length,B=W/q.length,H=j/q.length;console.log(O("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${b(G)}`),console.log(`Lines: ${Math.round(B)}`),console.log(`Words: ${Math.round(H)}`),console.log();let x=[...q].sort((A,V)=>V.size-A.size).slice(0,5);if(x.length>0){console.log(O("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let A of x){let V=A.path.replace(`${Q}/`,"");console.log(` ${V.padEnd(40)} ${b(A.size)}`)}console.log()}let E=Math.ceil(j/200);return M(`Estimated reading time: ${E} minutes`),!0}catch(N){return U(`Failed to generate statistics: ${N}`),!1}}var I=new F6("bunpress"),J={outdir:z.outDir||"./dist",docsdir:z.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:z.verbose};async function g4(K){let Z=new h4("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(D(K,$));return Q}async function y6(K,Z,Q=!1){let $=`${Z}/public`;try{await L6($);let N=new h4("**/*");for await(let X of N.scan($)){let q=D($,X),Y=D(K,X);await m4(D(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await I6(q,Y)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}function D6(K,Z,Q){let $=Z.replace(/^\.\//,""),N=(_)=>_.replace(/^\.\//,"").replace($,"").replace(/^\//,"").replace(/\.md$/,"");if(!Q.enabled)return K.map((_)=>({sourceFile:_,relativePath:N(_),locale:Q.defaultLocale}));let X=Q.locales,q=new Set(X),Y=new Map;for(let _ of X)Y.set(_,new Map);let W=new Set;for(let _ of K){let R=N(_),G=R.split("/");if(G.length>1&&q.has(G[0])&&G[0]!==Q.defaultLocale){let H=G.slice(1).join("/");Y.get(G[0]).set(H,_),W.add(H);continue}let B=R.match(/^(.*)\.([A-Za-z-]+)$/);if(B&&q.has(B[2])){Y.get(B[2]).set(B[1],_),W.add(B[1]);continue}Y.get(Q.defaultLocale).set(R,_),W.add(R)}let j=[];for(let _ of X)for(let R of W){let G=Y.get(_).get(R)??Y.get(Q.defaultLocale).get(R);if(!G)continue;j.push({sourceFile:G,relativePath:R,locale:_})}return j}async function b6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let N=await P4(K,Q);if(await Bun.write(D(Z,k4.replace(/^\//,"")),JSON.stringify(N)),$)console.log(`Indexed ${N.length} sections for search.`)}catch(N){if($)console.error("Error generating search index:",N)}}async function w6(K,Z,Q){try{let $=await z;if($.sitemap?.enabled!==!1&&$.sitemap?.baseUrl)await v4(K,Z,$);if($.robots?.enabled!==!1)await C4(Z,$);if($.rss?.enabled)await w4(K,Z,$,$.rss)}catch($){if(Q)console.error("Error generating SEO files:",$)}}async function C6(K={}){let Z=await z;if(!K.config)return Z;let Q=S6(S.cwd(),K.config);if(!E6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),N=$.default??$;return b4({...Z,...N})}async function D4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await C6(K),Q=K.outdir||Z.outDir||J.outdir,$=D(Q,".bunpress"),N=`${$}.tmp-${S.pid}`,X=K.dir||Z.docsDir||J.docsdir,q=K.verbose??J.verbose,Y=K.minify??!1,W=K.sourcemap??!1,j=performance.now(),_=new v("Building documentation...");if(!q)_.start();await t(N,{recursive:!0,force:!0}),await m4(N,{recursive:!0});let R=await g4(X);if(R.length===0){if(!q)_.fail("No markdown files found in docs directory");else console.log("No markdown files found in docs directory");return!1}if(q)console.log(`Found ${R.length} markdown files:`),R.forEach((G)=>console.log(`- ${G}`));try{let{markdownToHtml:G,wrapInLayout:B}=await import("./chunk-16x1ym5v.js"),{loadI18nTranslations:H,resolveI18nConfig:x}=await import("./chunk-m6pshd6t.js"),{mkdir:E,writeFile:A}=await import("fs/promises"),V=await H(x(Z),Z);if(q)console.log("Transforming markdown to HTML...");let g=D6(R,X,V);for(let C of g){let u4=await Bun.file(C.sourceFile).text(),{html:f4,frontmatter:Q4}=await G(u4,X),h=C.relativePath,d4=`/${h}`,p4=Q4.layout||"doc",c4=await B(f4,Z,d4,p4,Q4,{i18n:V,locale:C.locale,sourceFile:C.sourceFile,docsDir:X}),l4=h==="index"||h.endsWith("/index"),Z4=C.locale&&C.locale!==V.defaultLocale&&V.enabled?D(N,C.locale):N,u=l4?D(Z4,`${h}.html`):D(Z4,h,"index.html"),$4=u.substring(0,u.lastIndexOf("/"));if($4)await E($4,{recursive:!0});if(await A(u,c4),q)console.log(`Generated: ${u}`)}if(q)console.log(`Processed ${R.length} markdown files into ${g.length} pages.`);if(await y6(N,X,q),await k6(N),await v6(N,Z),K.searchIndex!==!1)await b6(X,N,Z,q||!1);if(await w6(X,N,q||!1),K.checkManifest)await _4(N,K.checkManifest,f);if(await t($,{recursive:!0,force:!0}),await x6(N,$),K.manifest)await H4($,K.manifest,f);let K4=performance.now()-j;if(!q)_.succeed(`Built ${R.length} pages to HTML in ${a(K4)}`);else T(`Build completed in ${a(K4)}`),console.log(`
|
|
294
|
+
Generated ${R.length} HTML files in ${$}`);return!0}catch(G){if(await t(N,{recursive:!0,force:!0}),!q)_.fail("Build failed");return console.error("Error during build:",G),!1}}async function v6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-16x1ym5v.js"),X=`
|
|
295
295
|
<style>
|
|
296
296
|
.NotFound {
|
|
297
297
|
padding: 64px 24px 96px;
|
|
@@ -370,7 +370,7 @@ Generated ${R.length} HTML files in ${$}`);return!0}catch(G){if(await t(N,{recur
|
|
|
370
370
|
</div>
|
|
371
371
|
`,q=await $(X,Z,"/404","doc");await Bun.write(D(K,"404.html"),q)}async function k6(K){let Z=D(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)}}I.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 D4(K))S.exit(1);if(K.watch){let{watch:Q}=await import("fs"),$=await z,N=K.dir||$.docsDir||"./docs";console.log(`
|
|
372
372
|
Watching for changes...`),Q(N,{recursive:!0},async(X,q)=>{if(q&&q.endsWith(".md"))console.log(`
|
|
373
|
-
Detected change in ${q}, rebuilding...`),await D4(K)}),await new Promise(()=>{})}});I.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 z,Q=K.port||J.port,$=K.dir||Z.docsDir||J.docsdir,N=K.watch??J.watch,X=K.verbose??J.verbose;if(X)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:N,verbose:X});let{serveCLI:q}=await import("./chunk-
|
|
373
|
+
Detected change in ${q}, rebuilding...`),await D4(K)}),await new Promise(()=>{})}});I.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 z,Q=K.port||J.port,$=K.dir||Z.docsDir||J.docsdir,N=K.watch??J.watch,X=K.verbose??J.verbose;if(X)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:N,verbose:X});let{serveCLI:q}=await import("./chunk-16x1ym5v.js");await q({port:Q,root:$,watch:N,config:Z})});async function P6(K={}){let Z=await z,Q=K.dir||Z.docsDir||J.docsdir,$=K.output||"./docs.md",N=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: ${N}`);let q=await g4(Q);if(q.length===0)return console.log("No markdown files found in docs directory"),!1;if(X)console.log(`Found ${q.length} markdown files`);q.sort();let Y=`# Documentation
|
|
374
374
|
|
|
375
375
|
`;Y+=`Generated: ${new Date().toISOString()}
|
|
376
376
|
|
|
@@ -389,5 +389,5 @@ Detected change in ${q}, rebuilding...`),await D4(K)}),await new Promise(()=>{})
|
|
|
389
389
|
`}Y+=`---
|
|
390
390
|
|
|
391
391
|
`}return await Bun.write($,Y),console.log(`
|
|
392
|
-
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(Y.length/1024).toFixed(2)} KB`),!0}I.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory (defaults to config docsDir)").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 P6(K))S.exit(1)});I.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 J4(K))S.exit(1)});I.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 z4(K)});I.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 R4(K))S.exit(1)});I.command("doctor","Run diagnostic checks on the project").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await A4(K))S.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await j4(K))S.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await G4(K))S.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await U4(K))S.exit(1)});I.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 B4(K,Z))S.exit(1)});I.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await y4(K))S.exit(1)});I.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await S4(K)});I.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-
|
|
392
|
+
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(Y.length/1024).toFixed(2)} KB`),!0}I.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory (defaults to config docsDir)").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 P6(K))S.exit(1)});I.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 J4(K))S.exit(1)});I.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 z4(K)});I.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 R4(K))S.exit(1)});I.command("doctor","Run diagnostic checks on the project").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await A4(K))S.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await j4(K))S.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await G4(K))S.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await U4(K))S.exit(1)});I.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 B4(K,Z))S.exit(1)});I.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await y4(K))S.exit(1)});I.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await S4(K)});I.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-jkykyxmj.js");if(!await Z(K))S.exit(1)});I.help();I.version(f);var e=Bun.argv[1]||"",h6=e.endsWith("/bunpress")||e.endsWith("/cli.ts")||e.endsWith("/cli.js");if(h6)I.parse();
|
|
393
393
|
export{T as p,U as q,M as r,v as s,g4 as t,C6 as u,D4 as v};
|
|
@@ -1788,7 +1788,7 @@ ${`/**
|
|
|
1788
1788
|
--bp-code-tab-text-color: var(--bp-c-text-2);
|
|
1789
1789
|
--bp-code-tab-bg: var(--bp-code-block-bg);
|
|
1790
1790
|
--bp-code-tab-hover-text-color: var(--bp-c-text-1);
|
|
1791
|
-
--bp-code-tab-active-text-color: var(--bp-c-
|
|
1791
|
+
--bp-code-tab-active-text-color: var(--bp-c-brand-1);
|
|
1792
1792
|
--bp-code-tab-active-bar-color: var(--bp-c-brand-1);
|
|
1793
1793
|
}
|
|
1794
1794
|
|
|
@@ -5232,7 +5232,7 @@ ${`/**
|
|
|
5232
5232
|
--bp-code-tab-text-color: var(--bp-c-text-2);
|
|
5233
5233
|
--bp-code-tab-bg: var(--bp-code-block-bg);
|
|
5234
5234
|
--bp-code-tab-hover-text-color: var(--bp-c-text-1);
|
|
5235
|
-
--bp-code-tab-active-text-color: var(--bp-c-
|
|
5235
|
+
--bp-code-tab-active-text-color: var(--bp-c-brand-1);
|
|
5236
5236
|
--bp-code-tab-active-bar-color: var(--bp-c-brand-1);
|
|
5237
5237
|
}
|
|
5238
5238
|
|
|
@@ -7397,7 +7397,7 @@ mjx-container > svg {
|
|
|
7397
7397
|
--bp-code-tab-text-color: var(--bp-c-text-2);
|
|
7398
7398
|
--bp-code-tab-bg: var(--bp-code-block-bg);
|
|
7399
7399
|
--bp-code-tab-hover-text-color: var(--bp-c-text-1);
|
|
7400
|
-
--bp-code-tab-active-text-color: var(--bp-c-
|
|
7400
|
+
--bp-code-tab-active-text-color: var(--bp-c-brand-1);
|
|
7401
7401
|
--bp-code-tab-active-bar-color: var(--bp-c-brand-1);
|
|
7402
7402
|
}
|
|
7403
7403
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p as $,q as I,r as f,s as h,v as x}from"./chunk-
|
|
2
|
+
import{p as $,q as I,r as f,s as h,v as x}from"./chunk-3vgez1xt.js";import"./chunk-5cxb3t2e.js";import{D as _}from"./chunk-he00q0q4.js";import"./chunk-3f29kjd8.js";import{join as D}from"path";var E="@stacksjs/ts-cloud";async function Y(){try{return await import(E)}catch(j){throw Error(`Deploying requires @stacksjs/ts-cloud, which is an optional dependency.
|
|
3
3
|
Install it with: bun add -d @stacksjs/ts-cloud
|
|
4
4
|
Original error: ${j instanceof Error?j.message:String(j)}`)}}function W(j,A){let k=A||j?.provider;if(!k||k==="route53")return null;if(k==="porkbun"){let m=j?.apiKey||process.env.PORKBUN_API_KEY,w=j?.secretKey||process.env.PORKBUN_SECRET_KEY;if(!m||!w)throw Error("Porkbun API credentials not found. Set PORKBUN_API_KEY and PORKBUN_SECRET_KEY environment variables, or configure them in bunpress.config.ts under cloud.dnsProvider");return{provider:"porkbun",apiKey:m,secretKey:w}}if(k==="godaddy"){let m=j?.apiKey||process.env.GODADDY_API_KEY,w=j?.secretKey||process.env.GODADDY_API_SECRET,J=j?.environment||process.env.GODADDY_ENVIRONMENT;if(!m||!w)throw Error("GoDaddy API credentials not found. Set GODADDY_API_KEY and GODADDY_API_SECRET environment variables, or configure them in bunpress.config.ts under cloud.dnsProvider");return{provider:"godaddy",apiKey:m,apiSecret:w,environment:J}}throw Error(`Unknown DNS provider: ${k}. Supported: porkbun, godaddy, route53`)}async function F(j={}){let A=await _,k=A.cloud||{},m=j.verbose??A.verbose??!1,w=j.region||k.region||"us-east-1",J=j.domain||k.domain,M=j.subdomain||k.subdomain,N=j.baseDomain||k.baseDomain,O=j.bucket||k.bucket,P=j.stackName||k.stackName,U=j.hostedZoneId||k.hostedZoneId,Q=j.certificateArn||k.certificateArn,V=k.cacheControl||"max-age=31536000, public",B;if(J)B=J;else if(M&&N)B=`${M}.${N}`;let K=B?.replace(/\./g,"-")||"bunpress-site",G=null;try{G=W(k.dnsProvider,j.dnsProvider)}catch(H){return I(H.message),!1}let L=G!==null;if(j.dryRun){if(f("Dry run mode - no changes will be made"),console.log(`
|
|
5
5
|
Configuration:`),console.log(` Region: ${w}`),console.log(` Site Name: ${K}`),console.log(` Bucket: ${O||"auto-generated"}`),console.log(` Domain: ${B||"not specified"}`),console.log(` Stack Name: ${P||`${K}-static-site`}`),console.log(` DNS Provider: ${G?.provider||"route53 (AWS)"}`),!L)console.log(` Hosted Zone ID: ${U||"auto-detected"}`);return console.log(` Certificate ARN: ${Q||"auto-created"}`),!0}if(!process.env.AWS_ACCESS_KEY_ID||!process.env.AWS_SECRET_ACCESS_KEY)return I("AWS credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables."),!1;let z=new h("Building documentation...");try{if(!m)z.start();if(!await x({verbose:m})){if(!m)z.fail("Build failed");return!1}if(!m)z.succeed("Documentation built successfully");let C=A.outDir||"./dist",X=D(C,".bunpress");if(!m)z.text="Deploying infrastructure with CloudFormation...",z.start();else if(console.log(`
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as W,b as X,c as Y,d as Z,e as _,f as $,g as b,h as v,i as A,j as zj,k as Bj,l as Dj,m as Ej,n as Gj,o as Hj}from"../chunk-
|
|
2
|
+
import{a as W,b as X,c as Y,d as Z,e as _,f as $,g as b,h as v,i as A,j as zj,k as Bj,l as Dj,m as Ej,n as Gj,o as Hj}from"../chunk-dy4way3t.js";import{A as w,w as j,x as k,y as q,z as u}from"../chunk-5cxb3t2e.js";import{$ as D,B as Q,C as S,D as T,E as V,H as p,I as f,J as c,K as d,L as g,M as a,N as n,O as o,P as r,Q as t,R as i,S as s,T as e,U as jj,V as kj,W as qj,X as uj,Y as wj,Z as z,_ as B}from"../chunk-he00q0q4.js";import{ba as F,ca as R,da as U,ea as m,fa as x,ga as C,ha as l,ia as h,ja as y}from"../chunk-3f29kjd8.js";export{Dj as wrapInLayout,Bj as stripConfiguredBasePath,Gj as startServer,U as splitLocaleFromPath,X as setLanguageAliases,Hj as serveCLI,F as resolveI18nConfig,W as resetHighlighter,d as reserveUniqueSlug,kj as processInlineTocSyntax,v as prewarmHighlighter,Y as normalizeLanguage,Ej as markdownToHtml,f as markdownHeadingText,m as localizeUrl,l as localeLabel,x as localeContentCandidates,R as loadI18nTranslations,Z as isLanguageSupported,$ as highlightCodeSync,_ as highlightCode,b as getSyntaxHighlightingStyles,A as getHighlighterInstance,zj as getConfiguredBasePath,V as getConfig,g as generateUniqueSlug,uj as generateTocStyles,wj as generateTocScripts,jj as generateTocPositions,r as generateTocHtml,e as generateTocData,c as generateSlug,w as generateSitemap,i as generateSidebarTocHtml,k as generateRssFeed,q as generateRobotsTxt,y as generateLocaleDetectionScript,t as generateInlineTocHtml,h as generateHreflangTags,s as generateFloatingTocHtml,o as filterHeadings,a as extractHeadings,qj as enhanceHeadingsWithAnchors,p as defaultTocConfig,Q as defaultConfig,C as configForLocale,T as config,n as buildTocHierarchy,u as buildSitemap,B as buildSearchRuntimeConfig,D as buildSearchIndex,j as buildRssFeed,S as applyConfigPlugins,z as SEARCH_INDEX_PATH};
|
|
@@ -117,6 +117,12 @@
|
|
|
117
117
|
background-color: var(--bp-c-default-soft, var(--bp-c-gray-soft));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
.bp-local-outline-items a.active {
|
|
121
|
+
color: var(--bp-c-brand-1);
|
|
122
|
+
background-color: var(--bp-c-brand-soft);
|
|
123
|
+
border-left-color: var(--bp-c-brand-1);
|
|
124
|
+
}
|
|
125
|
+
|
|
120
126
|
.bp-local-outline-items a:focus-visible {
|
|
121
127
|
outline: 2px solid var(--bp-c-brand-1);
|
|
122
128
|
outline-offset: -2px;
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
function initPageTOC() {
|
|
117
117
|
const tocContainer = document.querySelector('.page-toc');
|
|
118
118
|
const marker = document.querySelector('.outline-marker');
|
|
119
|
-
const tocLinks = document.querySelectorAll('.page-toc a');
|
|
119
|
+
const tocLinks = document.querySelectorAll('.page-toc a, .bp-local-outline-items a');
|
|
120
120
|
const headings = Array.from(document.querySelectorAll('h2[id], h3[id], h4[id], h5[id], h6[id]'));
|
|
121
121
|
const scrollContainer = document.querySelector('.BPContent');
|
|
122
122
|
|
|
@@ -144,18 +144,42 @@ function initPageTOC() {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
//
|
|
147
|
+
// Keep the active entry inside whichever outline is currently visible. On
|
|
148
|
+
// long pages the marker used to continue moving below the fixed aside while
|
|
149
|
+
// the aside itself remained at scrollTop 0, making a working scrollspy look
|
|
150
|
+
// completely dead once the reader passed the first screen of headings.
|
|
151
|
+
function keepActiveLinkVisible(activeLink) {
|
|
152
|
+
const outlineViewport = activeLink.closest('.BPDocAside') || activeLink.closest('.bp-local-outline-items');
|
|
153
|
+
if (!outlineViewport || outlineViewport.clientHeight === 0) return;
|
|
154
|
+
|
|
155
|
+
const linkRect = activeLink.getBoundingClientRect();
|
|
156
|
+
const viewportRect = outlineViewport.getBoundingClientRect();
|
|
157
|
+
const inset = 24;
|
|
158
|
+
|
|
159
|
+
if (linkRect.top < viewportRect.top + inset) {
|
|
160
|
+
outlineViewport.scrollTop += linkRect.top - viewportRect.top - inset;
|
|
161
|
+
} else if (linkRect.bottom > viewportRect.bottom - inset) {
|
|
162
|
+
outlineViewport.scrollTop += linkRect.bottom - viewportRect.bottom + inset;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Activate matching links in both the fixed desktop outline and the
|
|
167
|
+
// collapsible in-content outline used at narrower widths.
|
|
148
168
|
function activateLink(hash) {
|
|
149
169
|
// Remove previous active class
|
|
150
170
|
tocLinks.forEach(link => link.classList.remove('active'));
|
|
151
171
|
|
|
152
172
|
if (hash) {
|
|
153
|
-
|
|
154
|
-
const
|
|
173
|
+
const decodedHash = decodeURIComponent(hash);
|
|
174
|
+
const activeLinks = Array.from(tocLinks).filter(link => link.getAttribute('href') === decodedHash);
|
|
175
|
+
const activeLink = tocContainer.querySelector('a[href="' + decodedHash + '"]');
|
|
155
176
|
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
activeLinks.forEach(link => {
|
|
178
|
+
link.classList.add('active');
|
|
179
|
+
keepActiveLinkVisible(link);
|
|
180
|
+
});
|
|
158
181
|
|
|
182
|
+
if (activeLink) {
|
|
159
183
|
// Position the marker at the active link
|
|
160
184
|
const linkRect = activeLink.getBoundingClientRect();
|
|
161
185
|
const containerRect = tocContainer.getBoundingClientRect();
|
|
@@ -329,6 +353,16 @@ function initPageTOC() {
|
|
|
329
353
|
window.__bpTocHashChange = settleActiveLink;
|
|
330
354
|
window.addEventListener('hashchange', settleActiveLink);
|
|
331
355
|
|
|
356
|
+
// Opening the responsive outline does not move the page and therefore does
|
|
357
|
+
// not emit a scroll event. Re-run once it becomes visible so its active
|
|
358
|
+
// entry and internal scroll position immediately match the current section.
|
|
359
|
+
const inlineOutline = document.querySelector('.bp-local-outline');
|
|
360
|
+
if (inlineOutline) {
|
|
361
|
+
inlineOutline.addEventListener('toggle', () => {
|
|
362
|
+
if (inlineOutline.open) requestAnimationFrame(setActiveLink);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
332
366
|
// Initial update
|
|
333
367
|
requestAnimationFrame(setActiveLink);
|
|
334
368
|
}
|
|
@@ -304,7 +304,7 @@ const varsCSS = `/**
|
|
|
304
304
|
--bp-code-tab-text-color: var(--bp-c-text-2);
|
|
305
305
|
--bp-code-tab-bg: var(--bp-code-block-bg);
|
|
306
306
|
--bp-code-tab-hover-text-color: var(--bp-c-text-1);
|
|
307
|
-
--bp-code-tab-active-text-color: var(--bp-c-
|
|
307
|
+
--bp-code-tab-active-text-color: var(--bp-c-brand-1);
|
|
308
308
|
--bp-code-tab-active-bar-color: var(--bp-c-brand-1);
|
|
309
309
|
}
|
|
310
310
|
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
--vp-code-tab-text-color: var(--vp-c-text-2);
|
|
286
286
|
--vp-code-tab-bg: var(--vp-code-block-bg);
|
|
287
287
|
--vp-code-tab-hover-text-color: var(--vp-c-text-1);
|
|
288
|
-
--vp-code-tab-active-text-color: var(--vp-c-
|
|
288
|
+
--vp-code-tab-active-text-color: var(--vp-c-brand-1);
|
|
289
289
|
--vp-code-tab-active-bar-color: var(--vp-c-brand-1);
|
|
290
290
|
}
|
|
291
291
|
|