@stacksjs/bunpress 0.2.8 → 0.2.10
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-m6pshd6t.js → chunk-97v7x3vt.js} +1 -1
- package/dist/{chunk-0qd0ge2f.js → chunk-b3tryv9d.js} +87 -87
- package/dist/chunk-bxyvmqbx.js +32 -0
- package/dist/{chunk-he00q0q4.js → chunk-mp1mg7s9.js} +1 -1
- package/dist/chunk-rpac2va3.js +393 -0
- package/dist/{chunk-cw47386k.js → chunk-vga3fbsp.js} +1 -1
- package/dist/chunk-vyk71xvd.js +38 -0
- package/dist/{chunk-6we3d5xh.js → chunk-xzfh39hg.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/rss.d.ts +1 -1
- package/dist/src/site-url.d.ts +16 -0
- package/dist/src/sitemap.d.ts +1 -1
- package/dist/src/types.d.ts +2 -0
- package/package.json +2 -2
- package/dist/chunk-3f29kjd8.js +0 -38
- package/dist/chunk-5cxb3t2e.js +0 -32
- package/dist/chunk-g76bsga2.js +0 -393
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ba as B}from"./chunk-vyk71xvd.js";var{YAML:R}=globalThis.Bun;import*as X from"fs";import*as T from"path";async function F(H,J,j){let K=B(J),N=j?.title||J.title||J.markdown?.title||"Documentation Feed",O=j?.description||J.description||J.markdown?.meta?.description||"Documentation updates",Q=j?.author||"Documentation Team",Z=j?.email||"",_=j?.language||"en-us",$=j?.maxItems||20,V=j?.fullContent||!1,W=await w(H,K,V);W.sort((Y,z)=>z.pubDate.getTime()-Y.pubDate.getTime());let G=W.slice(0,$);return P({title:N,description:O,link:K,language:_,author:Q,email:Z,items:G})}async function c(H,J,j,K){if(!K?.enabled)return;if(!B(j)){if(j.verbose)console.warn("\u26A0\uFE0F RSS feed generation skipped: baseUrl not configured");return}let N=await F(H,j,K),O=K.filename||"feed.xml",Q=T.join(J,O);if(await X.promises.writeFile(Q,N,"utf-8"),j.verbose){let Z=(N.match(/<item>/g)||[]).length;console.log(`\u2705 RSS feed generated: ${Q} (${Z} items)`)}}async function w(H,J,j){let K=[],N=await k(H);for(let O of N){let Q=await X.promises.readFile(O,"utf-8"),{frontmatter:Z,markdown:_}=x(Q);if(!Z.date||!Z.title)continue;let V=T.relative(H,O).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!V.startsWith("/"))V=`/${V}`;if(V.endsWith("/")&&V!=="/")V=V.slice(0,-1);let W=`${J.replace(/\/$/,"")}${V}`,G=Z.description||U(_),Y=new Date(Z.date),z=Z.author;K.push({title:Z.title,link:W,description:G,pubDate:Y,author:z,content:j?_:void 0})}return K}async function k(H){let J=[];async function j(K){let N=await X.promises.readdir(K,{withFileTypes:!0});for(let O of N){let Q=T.join(K,O.name);if(O.isDirectory()){if(!O.name.startsWith(".")&&O.name!=="node_modules")await j(Q)}else if(O.isFile()&&O.name.endsWith(".md"))J.push(Q)}}return await j(H),J}function x(H){let J=/^---\n([\s\S]*?)\n---\n?/,j=H.match(J);if(!j)return{frontmatter:{},markdown:H};let K=j[1],N=H.slice(j[0].length);try{return{frontmatter:R.parse(K),markdown:N}}catch{return{frontmatter:{},markdown:H}}}function U(H,J=200){let j=H.replace(/^#{1,6}\s+(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"").replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_~]/g,"").trim(),K=j.split(`
|
|
3
|
+
|
|
4
|
+
`)[0]||j;if(K.length>J)return`${K.slice(0,J)}...`;return K}function P(H){let J=new Date,j=H.items.length>0?H.items[0].pubDate:J,K=H.items.map((N)=>{let O=N.content?`
|
|
5
|
+
<content:encoded><![CDATA[${N.content}]]></content:encoded>`:"",Q=N.author?`
|
|
6
|
+
<dc:creator><![CDATA[${N.author}]]></dc:creator>`:"";return` <item>
|
|
7
|
+
<title><![CDATA[${N.title}]]></title>
|
|
8
|
+
<link>${N.link}</link>
|
|
9
|
+
<guid>${N.link}</guid>
|
|
10
|
+
<description><![CDATA[${N.description}]]></description>
|
|
11
|
+
<pubDate>${N.pubDate.toUTCString()}</pubDate>${Q}${O}
|
|
12
|
+
</item>`}).join(`
|
|
13
|
+
`);return['<?xml version="1.0" encoding="UTF-8"?>','<rss version="2.0"',' xmlns:content="http://purl.org/rss/1.0/modules/content/"',' xmlns:dc="http://purl.org/dc/elements/1.1/"',' xmlns:atom="http://www.w3.org/2005/Atom">'," <channel>",` <title><![CDATA[${H.title}]]></title>`,` <description><![CDATA[${H.description}]]></description>`,` <link>${H.link}</link>`,` <language>${H.language}</language>`,` <lastBuildDate>${j.toUTCString()}</lastBuildDate>`,` <atom:link href="${H.link}/feed.xml" rel="self" type="application/rss+xml"/>`,K," </channel>","</rss>"].join(`
|
|
14
|
+
`)}import*as S from"fs";import*as v from"path";async function a(H,J){let j=J.robots;if(j?.enabled===!1)return;let K=j?.filename||"robots.txt",N=b(J),O=v.join(H,K);if(await S.promises.writeFile(O,N,"utf-8"),J.verbose)console.log(`\u2705 Robots.txt generated: ${O}`)}function b(H){let J=H.robots,j=[];if(J?.rules&&J.rules.length>0)for(let K of J.rules)j.push(...D(K)),j.push("");else j.push("User-agent: *"),j.push("Allow: /"),j.push("");if(J?.host)j.push(`Host: ${J.host}`),j.push("");if(J?.sitemaps&&J.sitemaps.length>0){for(let K of J.sitemaps)j.push(`Sitemap: ${K}`);j.push("")}else if(H.sitemap?.enabled!==!1&&B(H)){let K=H.sitemap?.filename||"sitemap.xml",N=`${B(H)}/${K}`;j.push(`Sitemap: ${N}`),j.push("")}if(J?.customContent)j.push(J.customContent),j.push("");return`${j.join(`
|
|
15
|
+
`).trim()}
|
|
16
|
+
`}function D(H){let J=[];if(J.push(`User-agent: ${H.userAgent}`),H.allow&&H.allow.length>0)for(let j of H.allow)J.push(`Allow: ${j}`);if(H.disallow&&H.disallow.length>0)for(let j of H.disallow)J.push(`Disallow: ${j}`);if(H.crawlDelay!==void 0)J.push(`Crawl-delay: ${H.crawlDelay}`);return J}import*as I from"fs";import*as A from"path";async function E(H,J,j){let K=J.sitemap,N=await y(H,j,K?.defaultPriority??0.5,K?.defaultChangefreq||"monthly",K?.exclude||[],K?.priorityMap||{},K?.changefreqMap||{});return K?.transform?N.map((O)=>K.transform(O)).filter(Boolean):N}async function n(H,J){let j=B(J),K=await E(H,J,j);return M(K,j)}async function i(H,J,j){let K=j.sitemap;if(K?.enabled===!1)return;if(!B(j)){if(j.verbose)console.warn("\u26A0\uFE0F Sitemap generation skipped: baseUrl not configured");return}let N=B(j),O=K?.filename||"sitemap.xml",Q=K?.maxUrlsPerFile||50000,Z=K?.useSitemapIndex||!1,_=await E(H,j,N);if(j.verbose)console.log(`\uD83D\uDCC4 Generated ${_.length} sitemap entries`);if(Z&&_.length>Q)await p(_,J,N,O,Q);else{let $=M(_,N),V=A.join(J,O);if(await I.promises.writeFile(V,$,"utf-8"),j.verbose)console.log(`\u2705 Sitemap generated: ${V}`)}}async function y(H,J,j,K,N,O,Q){let Z=[],_=await C(H);for(let $ of _){let W=A.relative(H,$).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!W.startsWith("/"))W=`/${W}`;if(W.endsWith("/")&&W!=="/")W=W.slice(0,-1);if(h(W,N))continue;let G=j;for(let[z,L]of Object.entries(O))if(q(W,z)){G=L;break}let Y=K;for(let[z,L]of Object.entries(Q))if(q(W,z)){Y=L;break}Z.push({url:W,changefreq:Y,priority:G})}return Z.sort(($,V)=>$.url.localeCompare(V.url))}async function C(H){let J=[];async function j(K){let N=await I.promises.readdir(K,{withFileTypes:!0});for(let O of N){let Q=A.join(K,O.name);if(O.isDirectory()){if(!O.name.startsWith(".")&&O.name!=="node_modules")await j(Q)}else if(O.isFile()&&O.name.endsWith(".md"))J.push(Q)}}return await j(H),J}function h(H,J){for(let j of J)if(q(H,j))return!0;return!1}function q(H,J){let j=J.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,".");return new RegExp(`^${j}$`).test(H)}function M(H,J=""){let j=J.replace(/\/$/,"");return`<?xml version="1.0" encoding="UTF-8"?>
|
|
17
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
18
|
+
${H.map((N)=>{let O=/^https?:\/\//.test(N.url)?N.url:`${j}${N.url}`,Q=N.lastmod?`
|
|
19
|
+
<lastmod>${d(N.lastmod)}</lastmod>`:"",Z=N.changefreq?`
|
|
20
|
+
<changefreq>${N.changefreq}</changefreq>`:"",_=N.priority!==void 0?`
|
|
21
|
+
<priority>${N.priority.toFixed(1)}</priority>`:"";return` <url>
|
|
22
|
+
<loc>${O}</loc>${Q}${Z}${_}
|
|
23
|
+
</url>`}).join(`
|
|
24
|
+
`)}
|
|
25
|
+
</urlset>`}async function p(H,J,j,K,N){let O=m(H,N),Q=[];for(let V=0;V<O.length;V++){let W=`sitemap-${V+1}.xml`,G=M(O[V],j),Y=A.join(J,W);await I.promises.writeFile(Y,G,"utf-8"),Q.push(W)}let _=`<?xml version="1.0" encoding="UTF-8"?>
|
|
26
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
27
|
+
${Q.map((V)=>{return` <sitemap>
|
|
28
|
+
<loc>${`${j}/${V}`}</loc>
|
|
29
|
+
</sitemap>`}).join(`
|
|
30
|
+
`)}
|
|
31
|
+
</sitemapindex>`,$=A.join(J,K);await I.promises.writeFile($,_,"utf-8")}function d(H){return(typeof H==="string"?new Date(H):H).toISOString().split("T")[0]}function m(H,J){let j=[];for(let K=0;K<H.length;K+=J)j.push(H.slice(K,K+J));return j}
|
|
32
|
+
export{F as w,c as x,a as y,n as z,i as A};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ca as m,fa as O}from"./chunk-vyk71xvd.js";import{loadConfig as u}from"bunfig";var h={docsDir:"./docs",outDir:"./dist",theme:"vitepress",nav:[{text:"Guide",link:"/install"},{text:"API",link:"/advanced#api-reference"},{text:"Examples",link:"/examples"}],plugins:[],markdown:{title:"BunPress Documentation",meta:{description:"Documentation built with BunPress",generator:"BunPress",viewport:"width=device-width, initial-scale=1.0"},sidebar:{"/":[{text:"Getting Started",items:[{text:"Introduction",link:"/"},{text:"Installation",link:"/install"},{text:"Quick Start",link:"/quick-start"},{text:"Usage",link:"/usage"},{text:"Configuration",link:"/config"}]},{text:"Core Features",items:[{text:"Features Overview",link:"/features"},{text:"Markdown Extensions",link:"/markdown-extensions"},{text:"Syntax Highlighting",link:"/syntax-highlighting"},{text:"Table of Contents",link:"/table-of-contents"},{text:"CLI Commands",link:"/cli"}]},{text:"SEO & Analytics",items:[{text:"SEO Features",link:"/seo"},{text:"Analytics (Fathom)",link:"/config#fathom-analytics-configuration"}]},{text:"Advanced",items:[{text:"Advanced Usage",link:"/advanced"},{text:"Examples",link:"/examples"},{text:"Best Practices",link:"/best-practices"}]},{text:"More",items:[{text:"Showcase",link:"/showcase"},{text:"Partners",link:"/partners"},{text:"License",link:"/license"},{text:"Postcardware",link:"/postcardware"}]}]},css:`
|
|
3
3
|
/* Additional BunPress customizations */
|
|
4
4
|
/* Note: Base styles are provided by the VitePress theme */
|
|
5
5
|
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{A as k4,x as C4,y as v4}from"./chunk-bxyvmqbx.js";import{$ as h4,C as b4,D as O,F as t,I as L4,J as x4,K as E4,Z as P4}from"./chunk-mp1mg7s9.js";import{aa as F,ba as a}from"./chunk-vyk71xvd.js";var{Glob:m4}=globalThis.Bun;import{copyFile as L6,mkdir as g4,readdir as x6,rename as E6,rm as e}from"fs/promises";import{existsSync as S6}from"fs";import{join as D,resolve as F6}from"path";import S from"process";import{CLI as y6}from"@stacksjs/clapp";var d="0.2.10";var{Glob:i4}=globalThis.Bun;import{dirname as s4,relative as r4,resolve as p,sep as Y4}from"path";import{mkdir as o4}from"fs/promises";function N4(K){return Y4==="/"?K:K.split(Y4).join("/")}function t4(K){let Z=new Bun.CryptoHasher("sha256");return Z.update(K),Z.digest("hex")}async function H4(K,Z,Q){let $=p(K),Y=Q?N4(r4($,p(Q))):void 0,X=[],q=new i4("**/*");for await(let R of q.scan({cwd:$,onlyFiles:!0})){let W=N4(R);if(W===Y)continue;X.push(W)}X.sort((R,W)=>R.localeCompare(W));let N=[],_=new Bun.CryptoHasher("sha256");for(let R of X){let W=new Uint8Array(await Bun.file(p($,R)).arrayBuffer()),j=t4(W);N.push({path:R,bytes:W.byteLength,sha256:j}),_.update(`${R}\x00${W.byteLength}\x00${j}
|
|
3
|
+
`)}return{schema_version:1,generator:"bunpress",generator_version:Z,outputs:N,tree_sha256:_.digest("hex")}}async function _4(K,Z,Q){let $=await H4(K,Q,Z);return await o4(s4(p(Z)),{recursive:!0}),await Bun.write(Z,`${JSON.stringify($,null,2)}
|
|
4
|
+
`),$}function q4(K){return new Map(K.outputs.map((Z)=>[Z.path,Z]))}async function W4(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 H4(K,Q,Z);if(JSON.stringify(Y)===JSON.stringify($))return Y;let X=q4($),q=q4(Y),N=Y.outputs.filter((j)=>!X.has(j.path)).map((j)=>j.path),_=$.outputs.filter((j)=>!q.has(j.path)).map((j)=>j.path),R=Y.outputs.filter((j)=>{let G=X.get(j.path);return G&&(G.bytes!==j.bytes||G.sha256!==j.sha256)}).map((j)=>{let G=X.get(j.path);return`${j.path} [bytes ${G.bytes} -> ${j.bytes}; sha256 ${G.sha256} -> ${j.sha256}]`}),W=[$.generator_version!==Y.generator_version?`generator ${$.generator_version} -> ${Y.generator_version}`:"",N.length?`added: ${N.join(", ")}`:"",_.length?`removed: ${_.join(", ")}`:"",R.length?`changed: ${R.join(", ")}`:""].filter(Boolean);throw Error(`BunPress output does not match ${Z}: ${W.join("; ")||"tree hash changed"}`)}import{existsSync as e4}from"fs";import{rm as K6}from"fs/promises";import{join as Q6}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 z(K,Z){return`${L[Z]}${K}${L.reset}`}function T(K){console.log(`${L.green}\u2713${L.reset} ${K}`)}function V(K){console.error(`${L.red}\u2717${L.reset} ${K}`)}function h(K){console.warn(`${L.yellow}\u26A0${L.reset} ${K}`)}function U(K){console.log(`${L.blue}\u2139${L.reset} ${K}`)}function w(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 n(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var R4=!!(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(R4){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(),V(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!R4)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(),Y=new TextDecoder,{value:X}=await $.read(),q=Y.decode(X).trim().toLowerCase();if(!q)return Z;return q==="y"||q==="yes"}function g(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((q)=>String(Y[q]).padEnd(Q[q])).join(" ");console.log(X)}}async function l(K){try{return Bun.file(K).size}catch{return 0}}async function Z6(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}`,q=await l(X);$+=q}return $}catch{return 0}}async function j4(K={}){let Z=await O,Q=K.outdir||Z.outDir||"./dist",$=Q6(Q,".bunpress"),Y=K.force||!1,X=K.verbose||!1;try{if(!e4($))return U(`Directory "${$}" does not exist, nothing to clean`),!0;let N=await Z6($);if(X)U(`Found "${$}" (${w(N)})`);if(!Y){if(!await c(`Delete "${$}" directory? (${w(N)})`,!1))return U("Clean cancelled"),!1}let _=process.env.VITEST==="true"||!1,R=null;if(!_&&!X)R=new v("Cleaning build artifacts..."),R.start();if(await K6($,{recursive:!0,force:!0}),R)R.succeed(`Cleaned ${w(N)} from "${$}"`);else if(X||_)T(`Cleaned ${w(N)} from "${$}"`);return!0}catch(q){return V(`Failed to clean directory: ${q}`),!1}}import{existsSync as i}from"fs";import{join as s}from"path";async function G4(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let Y of Z){let X=s(process.cwd(),Y);if(i(X)){Q=X;break}}if(!Q)return V("No configuration file found"),U('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 V(`Failed to show configuration: ${Z}`),!1}}async function V4(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let _ of Q){let R=s(process.cwd(),_);if(i(R)){$=R;break}}if(!$)return V("No configuration file found"),!1;if(Z)U(`Validating ${$}...`);let X=(await import($)).default;if(!X)return V("Configuration file does not export a default object"),!1;let q=[],N=[];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[_,R]of X.nav.entries())if(!R.text||!R.link)q.push(`nav[${_}] is missing required fields (text, link)`)}if(!a(X))N.push("no `url` set: sitemap, RSS, canonical links and Open Graph tags are all skipped without an absolute base URL");if(q.length>0){V("Configuration validation failed:");for(let _ of q)console.log(` \u2022 ${_}`);return!1}for(let _ of N)h(_);return T("Configuration is valid \u2713"),!0}catch(Q){return V(`Failed to validate configuration: ${Q}`),!1}}async function A4(K={}){let Z=s(process.cwd(),"bunpress.config.ts");if(i(Z))return V("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 V(`Failed to create configuration: ${$}`),!1}}import{existsSync as k}from"fs";import{join as P}from"path";function J4(){let Z=["bunpress","docs"].flatMap(($)=>[`${$}.config`,`.${$}.config`,$,`.${$}`]),Q=[".ts",".js",".mjs",".cjs",".json"];return Z.flatMap(($)=>Q.map((Y)=>`${$}${Y}`))}async function M4(K={}){let Z=K.verbose||!1,Q=[];console.log(z(`
|
|
58
|
+
Running diagnostics...
|
|
59
|
+
`,"bold")),Q.push({name:"Bun Runtime",status:"pass",message:`v${Bun.version}`});let $=J4().find((H)=>k(P(process.cwd(),H)));if($)Q.push({name:"Configuration",status:"pass",message:$});else Q.push({name:"Configuration",status:"pass",message:"using defaults (no config file)",detail:`Looked for: ${J4().join(", ")}`});let Y=K.dir||O.docsDir||"./docs",X=P(process.cwd(),Y);if(k(X)){let{Glob:H}=awaitPromise.resolve(globalThis.Bun),x=new H("**/*.md"),E=0;for await(let J of x.scan(X))E++;Q.push({name:"Documentation",status:E>0?"pass":"warn",message:`${E} markdown files in ${Y}`,fix:E>0?void 0:`Add a .md file under ${Y}, or run "bunpress new index"`})}else Q.push({name:"Documentation",status:"fail",message:`${Y} not found`,fix:'Run "bunpress init" to create the docs directory',detail:`Resolved from ${K.dir?"--dir":O.docsDir?"config docsDir":"the default"}`});let q=P(process.cwd(),"package.json");if(k(q)){let H=await Bun.file(q).json(),x=H.scripts?.dev,E=H.scripts?.build;Q.push({name:"Package Scripts",status:x&&E?"pass":"warn",message:`dev: ${x?"\u2713":"\u2717"}, build: ${E?"\u2713":"\u2717"}`,fix:x&&E?void 0:'Add "dev": "bunpress dev" and "build": "bunpress build" to package.json scripts'});let J=H.dependencies?.["@stacksjs/bunpress"]||H.devDependencies?.["@stacksjs/bunpress"];if(H.name==="@stacksjs/bunpress"||k(P(process.cwd(),"packages","bunpress","package.json")))Q.push({name:"BunPress Package",status:"pass",message:"this is the BunPress source repository"});else Q.push({name:"BunPress Package",status:J?"pass":"warn",message:J||"not declared in package.json",fix:J?void 0:'Run "bun add -d @stacksjs/bunpress"'})}else Q.push({name:"Package.json",status:"warn",message:"Not found",fix:'Run "bun init" to create one'});let N=P(process.cwd(),"node_modules");if(k(N))Q.push({name:"Dependencies",status:"pass",message:"node_modules found"});else Q.push({name:"Dependencies",status:"warn",message:"node_modules not found",fix:'Run "bun install"'});let _=P(process.cwd(),".git");if(k(_))Q.push({name:"Git Repository",status:"pass",message:"Initialized"});else Q.push({name:"Git Repository",status:"warn",message:"Not initialized",fix:'Run "git init" \u2014 without it, "last updated" falls back to file timestamps'});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",fix:"Only needed for a TypeScript config file \u2014 safe to ignore otherwise"});for(let H of Q){let x=H.status==="pass"?"\u2713":H.status==="fail"?"\u2717":"\u26A0",E=H.status==="pass"?"green":H.status==="fail"?"red":"yellow";if(console.log(` ${z(x,E)} ${H.name}: ${z(H.message,"dim")}`),Z&&H.detail)console.log(` ${z(H.detail,"dim")}`)}console.log();let W=Q.filter((H)=>H.status==="pass").length,j=Q.filter((H)=>H.status==="fail").length,G=Q.filter((H)=>H.status==="warn").length,B=Q.filter((H)=>H.status!=="pass"&&H.fix);if(B.length>0){U("Recommended actions:");for(let H of B)console.log(` \u2022 ${H.fix}`);console.log()}if(j>0)return V(`${j} checks failed, ${G} warnings`),!1;if(G>0)return h(`${W} checks passed, ${G} warnings`),!0;return T(`All ${W} checks passed!`),!0}import{mkdir as r}from"fs/promises";var $6=`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
|
+
`,X6=`---
|
|
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
|
+
`,Y6=`# 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
|
+
`,N6=`node_modules/
|
|
172
|
+
dist/
|
|
173
|
+
.DS_Store
|
|
174
|
+
*.log
|
|
175
|
+
.env
|
|
176
|
+
.env.*
|
|
177
|
+
!.env.example
|
|
178
|
+
`,q6=`# 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 U4(K={}){try{if(await Bun.file("./docs").exists()&&!K.force){if(!await c("Documentation directory already exists. Continue?",!1))return U("Initialization cancelled"),!1}let Q=new v("Initializing BunPress project...");Q.start(),await r("./docs",{recursive:!0}),await r("./docs/guide",{recursive:!0}),await r("./docs/public",{recursive:!0}),await Bun.write("./bunpress.config.ts",$6),await Bun.write("./docs/index.md",X6),await Bun.write("./docs/guide/index.md",Y6);let $=await Bun.file("./.gitignore").exists();if(!$)await Bun.write("./.gitignore",N6);let Y=await Bun.file("./README.md").exists();if(!Y)await Bun.write("./README.md",q6);let X="./package.json";if(await Bun.file(X).exists()){let N=await Bun.file(X).json();N.scripts=N.scripts||{},N.scripts.dev=N.scripts.dev||"bunpress dev",N.scripts.build=N.scripts.build||"bunpress build",N.scripts.preview=N.scripts.preview||"bunpress preview",await Bun.write(X,JSON.stringify(N,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(),U("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 V(`Failed to initialize project: ${Z}`),!1}}import{mkdir as H6}from"fs/promises";import{dirname as _6,join as W6}from"path";var B4={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 T4(K,Z={}){try{let Q=K.endsWith(".md")?K:`${K}.md`,$=W6(process.cwd(),"docs",Q);if(await Bun.file($).exists())return V(`File already exists: ${Q}`),!1;let X=Z.title;if(!X)X=(Q.split("/").pop()?.replace(".md","")||"").split("-").map((j)=>j.charAt(0).toUpperCase()+j.slice(1)).join(" ");let q=Z.template||"default",N=B4[q];if(!N)return V(`Unknown template: ${q}`),V(`Available templates: ${Object.keys(B4).join(", ")}`),!1;let _=N(X),R=_6($);return await H6(R,{recursive:!0}),await Bun.write($,_),T(`Created ${Q}`),console.log(),console.log(` Title: ${X}`),console.log(` Template: ${q}`),console.log(` Path: ${$}`),!0}catch(Q){return V(`Failed to create file: ${Q}`),!1}}import{join as z4}from"path";async function O4(K={}){let Z=K.port||3000,Q=await O,$=K.outdir||Q.outDir||"./dist",Y=z4($,".bunpress"),X=K.verbose||!1;try{let{stat:q}=await import("fs/promises");try{if(!(await q(Y)).isDirectory())V(`"${Y}" is not a directory.`),V('Run "bunpress build" first to generate the documentation.'),process.exit(1)}catch{V(`Build directory "${Y}" not found.`),V('Run "bunpress build" first to generate the documentation.'),process.exit(1)}U(`Starting preview server from ${Y}`);try{let N=Bun.serve({port:Z,fetch:async(_)=>{let W=new URL(_.url).pathname;if(W.startsWith("/"))W=W.slice(1);if(W===""||W==="/")W="index.html";let j=z4(Y,W),G=Bun.file(j);if(await G.exists())return new Response(G,{headers:{"Content-Type":R6(W)}});let H=`${j}.html`,x=Bun.file(H);if(await x.exists())return new Response(x,{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(N){if(N.message?.includes("EADDRINUSE")||N.code==="EADDRINUSE")V(`Port ${Z} is already in use.`),V("Try running with a different port: bunpress preview --port <port>"),V(`Or stop any processes using port ${Z}`);else V(`Failed to start server: ${N.message||N}`);process.exit(1)}}catch(q){V(`Failed to start preview server: ${q}`),process.exit(1)}}function R6(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 b from"fs";import*as y from"path";var{YAML:S4}=globalThis.Bun;async function F4(K={}){let Z=await O,Q=K.dir||Z.docsDir||"./docs",$=K.fix||!1;if(U("\uD83D\uDD0D Running SEO checks..."),console.log(""),!b.existsSync(Q))V(`Documentation directory not found: ${Q}`),process.exit(1);let Y={totalPages:0,errors:[],warnings:[],passed:0},X=await A6(Q);Y.totalPages=X.length;for(let q of X)await j6(q,Q,Y,$);if(G6(Z,Q,Y),z6(Y),Y.errors.length>0)process.exit(1)}async function j6(K,Z,Q,$){let Y=await b.promises.readFile(K,"utf-8"),{frontmatter:X,markdown:q}=J6(Y),N=y.relative(Z,K),_=!1,R=$&&Object.keys(X).length>0,W={...X},j=X.layout==="home"?X.hero?.text||X.hero?.name:void 0;if(!X.title&&j);else if(!X.title){let H=M6(q);if(!H)Q.errors.push({type:"error",category:"Title",file:N,message:"Missing title in frontmatter"}),_=!0;else if($)W.title=H,R=!0,U(`\u2713 Added title to ${N}: "${H}"`);else Q.warnings.push({type:"warning",category:"Title",file:N,message:`No title in frontmatter (could extract: "${H}")`}),_=!0}else{let H=X.title.length;if(H>60)Q.warnings.push({type:"warning",category:"Title",file:N,message:`Title too long (${H} chars, recommended <60)`}),_=!0;else if(H<10)Q.warnings.push({type:"warning",category:"Title",file:N,message:`Title too short (${H} chars, recommended >10)`}),_=!0}if(!X.description){let H=U6(q);if($)W.description=H,R=!0,U(`\u2713 Added description to ${N}`);else Q.warnings.push({type:"warning",category:"Description",file:N,message:"Missing description in frontmatter"}),_=!0}else{let H=X.description.length;if(H>160)Q.warnings.push({type:"warning",category:"Description",file:N,message:`Description too long (${H} chars, recommended <160)`}),_=!0;else if(H<50)Q.warnings.push({type:"warning",category:"Description",file:N,message:`Description too short (${H} chars, recommended >50)`}),_=!0}let G=B6(q,Z,K);for(let H of G)Q.errors.push({type:"error",category:"Links",file:N,message:`Broken internal link: ${H}`}),_=!0;let B=T6(q);for(let H of B)Q.warnings.push({type:"warning",category:"Images",file:N,message:`Image missing alt text: ${H}`}),_=!0;if(R){let H=V6(W,q);await b.promises.writeFile(K,H,"utf-8")}if(!_)Q.passed++}function G6(K,Z,Q){let $=new Set,Y=(N,_)=>{if(typeof N!=="string"||!N.startsWith("/"))return;let R=`${_}:${N}`;if($.has(R))return;$.add(R);let[W,j]=N.split("#"),G=y4(y.resolve(Z,`.${W}`));if(!G){Q.errors.push({type:"error",category:"Links",file:_,message:`Broken link: ${N}`});return}if(j&&!o(G).has(j))Q.errors.push({type:"error",category:"Links",file:_,message:`Broken anchor: ${N}`})},X=(N,_)=>{if(!Array.isArray(N))return;for(let R of N){if(!R||typeof R!=="object")continue;let W=R;Y(W.link,_),X(W.items,_)}};X(K.nav,"config nav"),X(K.themeConfig?.nav,"themeConfig nav");let q=[[K.markdown?.sidebar,"config sidebar"],[K.themeConfig?.sidebar,"themeConfig sidebar"]];for(let[N,_]of q)if(Array.isArray(N))X(N,_);else if(N&&typeof N==="object")for(let[R,W]of Object.entries(N))X(W,`${_} ${R}`)}function V6(K,Z){return`---
|
|
285
|
+
${S4.stringify(K,null,2)}
|
|
286
|
+
---
|
|
287
|
+
${Z}`}async function A6(K){let Z=[];async function Q($){let Y=await b.promises.readdir($,{withFileTypes:!0});for(let X of Y){let q=y.join($,X.name);if(X.isDirectory()){if(!X.name.startsWith(".")&&X.name!=="node_modules"&&X.name!=="public")await Q(q)}else if(X.isFile()&&X.name.endsWith(".md"))Z.push(q)}}return await Q(K),Z}function J6(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:S4.parse($),markdown:Y}}catch{return{frontmatter:{},markdown:K}}}function M6(K){let Z=K.match(/^#\s+(.+)$/m);return Z?Z[1].trim():null}function U6(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 B6(K,Z,Q){let $=[],Y=/\[([^\]]+)\]\(([^)]+)\)/g,X=t(K).replace(/`+[^`\n]*`+/g,"").replace(/<!--[\s\S]*?-->/g,""),q;while((q=Y.exec(X))!==null){let N=q[2].trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(N))continue;let _=N.includes("#")?N.slice(N.indexOf("#")+1):"";if(N.startsWith("#")){if(_&&!o(Q).has(_))$.push(N);continue}let R=N.split("#",1)[0].split("?",1)[0];if(!R)continue;let W;try{W=decodeURIComponent(R.replace(/^<|>$/g,""))}catch{$.push(N);continue}let j=W.startsWith("/")?y.resolve(Z,`.${W}`):y.resolve(y.dirname(Q),W),G=y4(j);if(!G){$.push(N);continue}if(_&&!o(G).has(_))$.push(N)}return $}function y4(K){let Z=K.endsWith(".md")?[K]:[K,`${K}.md`,y.join(K,"index.md")];for(let Q of Z)try{if(b.statSync(Q).isFile())return Q}catch{}return null}var I4=new Map;function o(K){let Z=I4.get(K);if(Z)return Z;let Q=new Set;try{let $=t(b.readFileSync(K,"utf8"));for(let Y of $.split(`
|
|
290
|
+
`)){let X=Y.match(/^#{1,6}\s+(.*)$/);if(!X)continue;let q=X[1].trim(),N=q.match(/\{#([\w-]+)\}\s*$/),_=N?N[1]:x4(L4(q));if(!_)continue;E4(_,Q)}}catch{}return I4.set(K,Q),Q}function T6(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 z6(K){if(console.log(""),U("\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){V(`\u2717 ${K.errors.length} errors found:`),console.log("");let Z=K.errors.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g(Z),console.log("")}if(K.warnings.length>0){h(`\u26A0 ${K.warnings.length} warnings found:`),console.log("");let Z=K.warnings.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g(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 O6}from"path";async function I6(K){let Z=await Bun.file(K).text(),Q=Z.split(`
|
|
291
|
+
`),$=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 N=Q.filter((R)=>R.match(/^#{1,6}\s+/)).length,_=(Z.match(/```/g)||[]).length/2;return{path:K,size:await l(K),lines:Q.length,words:$,headings:N,codeBlocks:Math.floor(_)}}async function D4(K={}){let Z=await O,Q=K.dir||Z.docsDir||"./docs",$=K.verbose||!1;try{console.log(z(`
|
|
292
|
+
Analyzing documentation...
|
|
293
|
+
`,"bold"));let{Glob:Y}=awaitPromise.resolve(globalThis.Bun),X=new Y("**/*.md"),q=[];for await(let J of X.scan(Q)){let A=O6(Q,J),u=await I6(A);q.push(u)}if(q.length===0)return V("No markdown files found"),!1;let N=q.reduce((J,A)=>J+A.size,0),_=q.reduce((J,A)=>J+A.lines,0),R=q.reduce((J,A)=>J+A.words,0),W=q.reduce((J,A)=>J+A.headings,0),j=q.reduce((J,A)=>J+A.codeBlocks,0);if(console.log(z("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${q.length}`),console.log(`Total size: ${w(N)}`),console.log(`Total lines: ${_.toLocaleString()}`),console.log(`Total words: ${R.toLocaleString()}`),console.log(`Headings: ${W}`),console.log(`Code blocks: ${j}`),console.log(),$){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let J=q.map((A)=>({File:A.path.replace(`${Q}/`,""),Size:w(A.size),Lines:A.lines,Words:A.words,Headings:A.headings,"Code Blocks":A.codeBlocks}));g(J),console.log()}let G=N/q.length,B=_/q.length,H=R/q.length;console.log(z("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${w(G)}`),console.log(`Lines: ${Math.round(B)}`),console.log(`Words: ${Math.round(H)}`),console.log();let x=[...q].sort((J,A)=>A.size-J.size).slice(0,5);if(x.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let J of x){let A=J.path.replace(`${Q}/`,"");console.log(` ${A.padEnd(40)} ${w(J.size)}`)}console.log()}let E=Math.ceil(R/200);return U(`Estimated reading time: ${E} minutes`),!0}catch(Y){return V(`Failed to generate statistics: ${Y}`),!1}}var I=new y6("bunpress"),M={outdir:O.outDir||"./dist",docsdir:O.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:O.verbose};async function u4(K){let Z=new m4("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(D(K,$));return Q}async function D6(K,Z,Q=!1){let $=`${Z}/public`;try{await x6($);let Y=new m4("**/*");for await(let X of Y.scan($)){let q=D($,X),N=D(K,X);await g4(D(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await L6(q,N)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}function w6(K,Z,Q){let $=Z.replace(/^\.\//,""),Y=(W)=>W.replace(/^\.\//,"").replace($,"").replace(/^\//,"").replace(/\.md$/,"");if(!Q.enabled)return K.map((W)=>({sourceFile:W,relativePath:Y(W),locale:Q.defaultLocale}));let X=Q.locales,q=new Set(X),N=new Map;for(let W of X)N.set(W,new Map);let _=new Set;for(let W of K){let j=Y(W),G=j.split("/");if(G.length>1&&q.has(G[0])&&G[0]!==Q.defaultLocale){let H=G.slice(1).join("/");N.get(G[0]).set(H,W),_.add(H);continue}let B=j.match(/^(.*)\.([A-Za-z-]+)$/);if(B&&q.has(B[2])){N.get(B[2]).set(B[1],W),_.add(B[1]);continue}N.get(Q.defaultLocale).set(j,W),_.add(j)}let R=[];for(let W of X)for(let j of _){let G=N.get(W).get(j)??N.get(Q.defaultLocale).get(j);if(!G)continue;R.push({sourceFile:G,relativePath:j,locale:W})}return R}async function b6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let Y=await h4(K,Q);if(await Bun.write(D(Z,P4.replace(/^\//,"")),JSON.stringify(Y)),$)console.log(`Indexed ${Y.length} sections for search.`)}catch(Y){if($)console.error("Error generating search index:",Y)}}async function C6(K,Z,Q,$){try{if(Q.sitemap?.enabled!==!1&&a(Q))await k4(K,Z,Q);if(Q.robots?.enabled!==!1)await v4(Z,Q);if(Q.rss?.enabled)await C4(K,Z,Q,Q.rss)}catch(Y){if($)console.error("Error generating SEO files:",Y)}}async function v6(K={}){let Z=await O;if(!K.config)return Z;let Q=F6(S.cwd(),K.config);if(!S6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),Y=$.default??$;return b4({...Z,...Y})}async function w4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await v6(K),Q=K.outdir||Z.outDir||M.outdir,$=D(Q,".bunpress"),Y=`${$}.tmp-${S.pid}`,X=K.dir||Z.docsDir||M.docsdir,q=K.verbose??M.verbose,N=K.minify??!1,_=K.sourcemap??!1,R=performance.now(),W=new v("Building documentation...");if(!q)W.start();await e(Y,{recursive:!0,force:!0}),await g4(Y,{recursive:!0});let j=await u4(X);if(j.length===0){if(!q)W.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 ${j.length} markdown files:`),j.forEach((G)=>console.log(`- ${G}`));try{let{markdownToHtml:G,wrapInLayout:B}=await import("./chunk-xzfh39hg.js"),{loadI18nTranslations:H,resolveI18nConfig:x}=await import("./chunk-97v7x3vt.js"),{mkdir:E,writeFile:J}=await import("fs/promises"),A=await H(x(Z),Z);if(q)console.log("Transforming markdown to HTML...");let u=w6(j,X,A);for(let C of u){let f4=await Bun.file(C.sourceFile).text(),{html:d4,frontmatter:Z4}=await G(f4,X),m=C.relativePath,p4=`/${m}`,c4=Z4.layout||"doc",l4=await B(d4,Z,p4,c4,Z4,{i18n:A,locale:C.locale,sourceFile:C.sourceFile,docsDir:X}),a4=m==="index"||m.endsWith("/index"),$4=C.locale&&C.locale!==A.defaultLocale&&A.enabled?D(Y,C.locale):Y,f=a4?D($4,`${m}.html`):D($4,m,"index.html"),X4=f.substring(0,f.lastIndexOf("/"));if(X4)await E(X4,{recursive:!0});if(await J(f,l4),q)console.log(`Generated: ${f}`)}if(q)console.log(`Processed ${j.length} markdown files into ${u.length} pages.`);if(await D6(Y,X,q),await P6(Y),await k6(Y,Z),K.searchIndex!==!1)await b6(X,Y,Z,q||!1);if(await C6(X,Y,Z,q||!1),K.checkManifest)await W4(Y,K.checkManifest,d);if(await e($,{recursive:!0,force:!0}),await E6(Y,$),K.manifest)await _4($,K.manifest,d);let Q4=performance.now()-R;if(!q)W.succeed(`Built ${j.length} pages to HTML in ${n(Q4)}`);else T(`Build completed in ${n(Q4)}`),console.log(`
|
|
294
|
+
Generated ${j.length} HTML files in ${$}`);return!0}catch(G){if(await e(Y,{recursive:!0,force:!0}),!q)W.fail("Build failed");return console.error("Error during build:",G),!1}}async function k6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-xzfh39hg.js"),X=`
|
|
295
|
+
<style>
|
|
296
|
+
.NotFound {
|
|
297
|
+
padding: 64px 24px 96px;
|
|
298
|
+
text-align: center;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
@media (min-width: 768px) {
|
|
302
|
+
.NotFound {
|
|
303
|
+
padding: 96px 32px 168px;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.NotFound .code {
|
|
308
|
+
line-height: 64px;
|
|
309
|
+
font-size: 64px;
|
|
310
|
+
font-weight: 600;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.NotFound .title {
|
|
314
|
+
padding-top: 12px;
|
|
315
|
+
letter-spacing: 2px;
|
|
316
|
+
line-height: 20px;
|
|
317
|
+
font-size: 20px;
|
|
318
|
+
font-weight: 700;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.NotFound .divider {
|
|
322
|
+
margin: 24px auto 18px;
|
|
323
|
+
width: 64px;
|
|
324
|
+
height: 1px;
|
|
325
|
+
background-color: var(--vp-c-divider);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.NotFound .quote {
|
|
329
|
+
margin: 0 auto;
|
|
330
|
+
max-width: 256px;
|
|
331
|
+
font-size: 14px;
|
|
332
|
+
font-weight: 500;
|
|
333
|
+
color: var(--vp-c-text-2);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.NotFound .action {
|
|
337
|
+
padding-top: 20px;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.NotFound .link {
|
|
341
|
+
display: inline-block;
|
|
342
|
+
border: 1px solid var(--vp-c-brand-1);
|
|
343
|
+
border-radius: 16px;
|
|
344
|
+
padding: 3px 16px;
|
|
345
|
+
font-size: 14px;
|
|
346
|
+
font-weight: 500;
|
|
347
|
+
color: var(--vp-c-brand-1);
|
|
348
|
+
transition: border-color 0.25s, color 0.25s;
|
|
349
|
+
text-decoration: none;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.NotFound .link:hover {
|
|
353
|
+
border-color: var(--vp-c-brand-2);
|
|
354
|
+
color: var(--vp-c-brand-2);
|
|
355
|
+
}
|
|
356
|
+
</style>
|
|
357
|
+
|
|
358
|
+
<div class="NotFound">
|
|
359
|
+
<p class="code">404</p>
|
|
360
|
+
<h1 class="title">PAGE NOT FOUND</h1>
|
|
361
|
+
<div class="divider"></div>
|
|
362
|
+
<blockquote class="quote">
|
|
363
|
+
But if you don't change your direction, and if you keep looking, you may end up where you are heading.
|
|
364
|
+
</blockquote>
|
|
365
|
+
<div class="action">
|
|
366
|
+
<a class="link" href="${`${Q(Z)}/`}" aria-label="go to home">
|
|
367
|
+
Take me home
|
|
368
|
+
</a>
|
|
369
|
+
</div>
|
|
370
|
+
</div>
|
|
371
|
+
`,q=await $(X,Z,"/404","doc");await Bun.write(D(K,"404.html"),q)}async function P6(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:M.verbose}).action(async(K)=>{if(!await w4(K))S.exit(1);if(K.watch){let{watch:Q}=await import("fs"),$=await O,Y=K.dir||$.docsDir||"./docs";console.log(`
|
|
372
|
+
Watching for changes...`),Q(Y,{recursive:!0},async(X,q)=>{if(q&&q.endsWith(".md"))console.log(`
|
|
373
|
+
Detected change in ${q}, rebuilding...`),await w4(K)}),await new Promise(()=>{})}});I.command("dev","Build and serve documentation using BunPress server").option("--port <port>","Port to listen on",{default:M.port}).option("--dir <dir>","Documentation directory").option("--watch","Watch for changes",{default:M.watch}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{let Z=await O,Q=K.port||M.port,$=K.dir||Z.docsDir||M.docsdir,Y=K.watch??M.watch,X=K.verbose??M.verbose;if(X)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:Y,verbose:X});let{serveCLI:q}=await import("./chunk-xzfh39hg.js");await q({port:Q,root:$,watch:Y,config:Z})});async function h6(K={}){let Z=await O,Q=K.dir||Z.docsDir||M.docsdir,$=K.output||"./docs.md",Y=K.full??!1,X=K.verbose??M.verbose;if(X)console.log(`Generating LLM markdown from ${Q}`),console.log(`Output file: ${$}`),console.log(`Full content: ${Y}`);let q=await u4(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 N=`# Documentation
|
|
374
|
+
|
|
375
|
+
`;N+=`Generated: ${new Date().toISOString()}
|
|
376
|
+
|
|
377
|
+
`,N+=`Total files: ${q.length}
|
|
378
|
+
|
|
379
|
+
`,N+=`---
|
|
380
|
+
|
|
381
|
+
`;for(let _ of q){let R=_.replace(`${Q}/`,""),W=await Bun.file(_).text();if(X)console.log(`Processing: ${R}`);if(N+=`## File: ${R}
|
|
382
|
+
|
|
383
|
+
`,Y)N+=W,N+=`
|
|
384
|
+
|
|
385
|
+
`;else{let j=W.split(`
|
|
386
|
+
`),G=!1,B="";for(let H of j){if(H.trim()==="---")if(!G){G=!0;continue}else{if(G=!1,B)N+="**Frontmatter:**\n```yaml\n",N+=B,N+="```\n\n",B="";continue}if(G){B+=`${H}
|
|
387
|
+
`;continue}if(H.match(/^#{1,6}\s+/))N+=`${H}
|
|
388
|
+
`}N+=`
|
|
389
|
+
`}N+=`---
|
|
390
|
+
|
|
391
|
+
`}return await Bun.write($,N),console.log(`
|
|
392
|
+
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(N.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:M.verbose}).action(async(K)=>{if(!await h6(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 U4(K))S.exit(1)});I.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:M.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{await O4(K)});I.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:M.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await j4(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:M.verbose}).action(async(K)=>{if(!await M4(K))S.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await G4(K))S.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await V4(K))S.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await A4(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:M.verbose}).action(async(K,Z)=>{if(!await T4(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:M.verbose}).action(async(K)=>{if(!await D4(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 F4(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:M.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-vga3fbsp.js");if(!await Z(K))S.exit(1)});I.help();I.version(d);var K4=Bun.argv[1]||"",m6=K4.endsWith("/bunpress")||K4.endsWith("/cli.ts")||K4.endsWith("/cli.js");if(m6)I.parse();
|
|
393
|
+
export{T as p,V as q,U as r,v as s,u4 as t,v6 as u,w4 as v};
|
|
@@ -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-rpac2va3.js";import"./chunk-bxyvmqbx.js";import{D as _}from"./chunk-mp1mg7s9.js";import"./chunk-vyk71xvd.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(`
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var j=import.meta.require;function X(q){return(q.sitemap?.baseUrl||q.url||"").replace(/\/$/,"")}var Y={"search.placeholder":"Search documentation","toc.title":"On this page","nav.menu":"Menu","search.noResults":"No results for","theme.toggle":"Toggle dark mode"};function O(q){let B=q?.i18n,H=(B?.locales??[]).filter(Boolean),J=B?.defaultLocale||H[0]||"en",K=(B?.enabled??H.length>1)&&H.length>0;return{enabled:K,locales:K?H:[J],defaultLocale:J,fallbackLocale:B?.fallbackLocale??J,localePath:B?.localePath??"./locales",detectLocale:B?.detectLocale===!0,localeNames:B?.localeNames??{},localeConfig:B?.localeConfig??{},translate:(M)=>Y[M]??M}}async function A(q,B){if(!q.enabled)return q;try{let{createTranslator:H,loadTranslations:J}=await import("@stacksjs/ts-i18n"),K=await J({translationsDir:q.localePath,defaultLocale:q.defaultLocale,fallbackLocale:q.fallbackLocale,sources:B?.i18n?.sources??["ts","yaml","json"],optional:!0,verbose:!1}),M=H(K,{defaultLocale:q.defaultLocale,fallbackLocale:q.fallbackLocale}),V=new Set;for(let N of Object.values(K))for(let P of Object.keys(N??{}))V.add(P);let Z=[...V].sort((N,P)=>N==="theme"?-1:P==="theme"?1:N.localeCompare(P));return{...q,translate:(N,P,$)=>{for(let W of[N,...Z.map((Q)=>`${Q}.${N}`)])try{let Q=M(W,P,$);if(typeof Q==="string"&&Q&&Q!==W)return Q}catch{}return Y[N]??N}}}catch(H){return console.warn("[bunpress] i18n translations could not be loaded; falling back to defaults \u2014",H instanceof Error?H.message:H),q}}function E(q,B){if(!q.enabled)return{locale:q.defaultLocale,path:B};let H=B.match(/^\/([^/]+)(\/.*)?$/);if(H&&q.locales.includes(H[1])&&H[1]!==q.defaultLocale)return{locale:H[1],path:H[2]||"/"};return{locale:q.defaultLocale,path:B}}function x(q,B,H){if(!q.enabled||B===q.defaultLocale)return H||"/";return`/${B}${H==="/"?"":H}`||`/${B}`}function I(q,B,H,J){let K=J==="/"?"/index":J,M=[];if(q.enabled&&H!==q.defaultLocale)M.push(`${B}/${H}${K}.md`),M.push(`${B}/${H}${K}/index.md`),M.push(`${B}${K}.${H}.md`);if(M.push(`${B}${K}.md`),M.push(`${B}${K}/index.md`),q.enabled)M.push(`${B}${K}.${q.defaultLocale}.md`);return M}function _(q,B,H){let J=B.localeConfig[H];if(!J)return q;return{...q,...J,themeConfig:J.themeConfig?{...q.themeConfig,...J.themeConfig}:q.themeConfig,markdown:J.markdown?{...q.markdown,...J.markdown}:q.markdown}}function D(q,B){return q.localeNames[B]??B}function F(q,B,H){if(!q.enabled)return"";let J=X(B);if(!J)return"";let K=q.locales.map((M)=>{let V=`${J}${x(q,M,H==="/index"?"/":H)}`;return`<link rel="alternate" hreflang="${M}" href="${V}">`});return K.push(`<link rel="alternate" hreflang="x-default" href="${J}${H==="/index"?"/":H}">`),K.join(`
|
|
3
|
+
`)}function R(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{j as aa,X as ba,O as ca,A as da,E as ea,x as fa,I as ga,_ as ha,D as ia,F as ja,R as ka};
|
|
@@ -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-b3tryv9d.js";import"./chunk-mp1mg7s9.js";import"./chunk-vyk71xvd.js";export{c as wrapInLayout,b as stripConfiguredBasePath,e as startServer,f as serveCLI,d as markdownToHtml,a as getConfiguredBasePath};
|
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-b3tryv9d.js";import{A as w,w as j,x as k,y as q,z as u}from"../chunk-bxyvmqbx.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-mp1mg7s9.js";import{ca as F,da as R,ea as U,fa as m,ga as x,ha as C,ia as l,ja as h,ka as y}from"../chunk-vyk71xvd.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};
|
package/dist/src/rss.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { BunPressConfig } from './types';
|
|
|
4
4
|
* string. Use this to serve a feed dynamically from a request handler; use
|
|
5
5
|
* {@link generateRssFeed} to write it to disk during a static build.
|
|
6
6
|
*
|
|
7
|
-
* `
|
|
7
|
+
* The site's base URL (`url`, or `sitemap.baseUrl`) is the absolute link base, and may include a path
|
|
8
8
|
* prefix (e.g. `https://example.com/blog`).
|
|
9
9
|
*/
|
|
10
10
|
export declare function buildRssFeed(docsDir: string, config: BunPressConfig, rssConfig?: RssFeedConfig): Promise<string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BunPressConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The site's absolute base URL, or `''` when it has none.
|
|
4
|
+
*
|
|
5
|
+
* Five separate features need to turn a page's path into an absolute URL —
|
|
6
|
+
* the sitemap, the RSS feed, robots.txt's `Sitemap:` line, `<link rel="canonical">`
|
|
7
|
+
* and the Open Graph tags — and each of them used to read `config.sitemap.baseUrl`
|
|
8
|
+
* directly. That made a sitemap-shaped key the only way to configure something
|
|
9
|
+
* none of those four other features have to do with, so authors reached for the
|
|
10
|
+
* obvious top-level `url` instead and silently got none of them: no sitemap, no
|
|
11
|
+
* feed, no canonical link, and no link-preview card anywhere the docs were shared.
|
|
12
|
+
*
|
|
13
|
+
* `sitemap.baseUrl` still wins where it is set, so nothing that configured it
|
|
14
|
+
* moves; `url` is the place to say it once.
|
|
15
|
+
*/
|
|
16
|
+
export declare function siteUrl(config: BunPressConfig): string;
|
package/dist/src/sitemap.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { BunPressConfig } from './types';
|
|
|
4
4
|
* Use this to serve a sitemap dynamically from a request handler; use
|
|
5
5
|
* {@link generateSitemap} to write it to disk during a static build.
|
|
6
6
|
*
|
|
7
|
-
* `
|
|
7
|
+
* The site's base URL (`url`, or `sitemap.baseUrl`) is prefixed onto every `<loc>` and may include a
|
|
8
8
|
* path (e.g. `https://example.com/blog`).
|
|
9
9
|
*/
|
|
10
10
|
export declare function buildSitemap(docsDir: string, config: BunPressConfig): Promise<string>;
|