boltdocs 2.6.0 → 2.6.1
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/client/index.cjs +1 -1
- package/dist/client/index.d.cts +12 -24
- package/dist/client/index.d.ts +12 -24
- package/dist/client/index.js +1 -1
- package/dist/node/cli-entry.cjs +1 -1
- package/dist/node/cli-entry.mjs +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +19 -1
- package/dist/node/index.d.mts +19 -1
- package/dist/node/index.mjs +1 -1
- package/dist/node-CWN8U_p8.mjs +88 -0
- package/dist/{node-vkbb0MK7.cjs → node-D5iosYXv.cjs} +3 -4
- package/dist/{package-CR0HF9x3.mjs → package-DukYeKmD.mjs} +1 -1
- package/dist/{package-Dgmsc_l5.cjs → package-c99Cs7mD.cjs} +1 -1
- package/package.json +3 -2
- package/src/client/index.ts +1 -3
- package/src/shared/config-utils.ts +12 -0
- package/src/shared/types.ts +171 -0
- package/dist/node-BgvNl2Ay.mjs +0 -89
- package/src/client/components/default-layout.tsx +0 -89
|
@@ -81,9 +81,8 @@ export const createRoot = ViteReactSSG(
|
|
|
81
81
|
})();
|
|
82
82
|
<\/script>
|
|
83
83
|
</head>`),!e.includes(`src/main`)&&!e.includes(`virtual:boltdocs-entry`)&&(e=e.replace(`</body>`,` <script type="module">import "virtual:boltdocs-entry";<\/script>
|
|
84
|
-
</body>`)),e}function pt(e){let t=[];for(let n of e)if(t.push({id:n.path,title:n.title,content:n._content||``,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version});return t}const mt={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains`};function ht(e){let t=process.env.NODE_ENV===`development`,n={"default-src":[`'self'`],"script-src":[`'self'`,`'unsafe-inline'`],"style-src":[`'self'`,`'unsafe-inline'`],"img-src":[`'self'`,`data:`,`https:`],"font-src":[`'self'`],"connect-src":[`'self'`]};return t&&(n[`script-src`]=[`'self'`,`'unsafe-eval'`,`'unsafe-inline'`],n[`style-src`]=[`'self'`,`'unsafe-inline'`]),Object.entries(n).map(([e,t])=>`${e} ${t.join(` `)}`).join(`; `)}var Y=class e extends Error{pluginName;constructor(t,n){super(`[plugin:${t}] ${n}`),this.name=`PluginError`,this.pluginName=t,Object.setPrototypeOf(this,e.prototype)}},X=class e extends Y{constructor(t,n){super(t,`Validation failed: ${n}`),this.name=`PluginValidationError`,Object.setPrototypeOf(this,e.prototype)}},gt=class e extends Y{constructor(t,n){super(t,`Compatibility error: ${n}`),this.name=`PluginCompatibilityError`,Object.setPrototypeOf(this,e.prototype)}},_t=class e extends Y{constructor(t,n){super(t,`Missing required permission: '${n}'`),this.name=`PluginPermissionError`,Object.setPrototypeOf(this,e.prototype)}},vt=class e extends Y{hookName;constructor(t,n,r){super(t,`Error in hook '${n}': ${r.message}`),this.name=`PluginHookError`,this.hookName=n,this.stack=r.stack,Object.setPrototypeOf(this,e.prototype)}},yt=class{data=new Map;getNamespaceKey(e,t){return`${e}:${t}`}get(e,t){let n=this.getNamespaceKey(e,t),r=this.data.get(n);if(r!==void 0)return typeof r==`object`&&r?JSON.parse(JSON.stringify(r)):r}set(e,t,n){let r=this.getNamespaceKey(e,t),i=typeof n==`object`&&n?JSON.parse(JSON.stringify(n)):n;this.data.set(r,i)}has(e,t){let n=this.getNamespaceKey(e,t);return this.data.has(n)}};const bt=Qe.extend({version:g.z.string().optional(),boltdocsVersion:g.z.string().optional(),permissions:g.z.array(g.z.string()).optional(),hooks:g.z.object({beforeBuild:g.z.function().optional(),afterBuild:g.z.function().optional(),beforeDev:g.z.function().optional(),afterDev:g.z.function().optional(),configResolved:g.z.function().optional(),buildEnd:g.z.function().optional()}).optional()});function xt(e,t){let n=[],r=new Set;for(let i of e){let e=bt.safeParse(i);if(!e.success)throw new X(i.name||`unknown`,e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `));let a=e.data;if(r.has(a.name))throw new X(a.name,`Duplicate plugin name detected`);if(r.add(a.name),a.boltdocsVersion&&!C.default.satisfies(t,a.boltdocsVersion))throw new gt(a.name,`Plugin expects Boltdocs version ${a.boltdocsVersion}, but current is ${t}`);if(a.components){for(let[e,t]of Object.entries(a.components))if((t.includes(`..`)||_.default.isAbsolute(t))&&t.includes(`..`))throw new X(a.name,`Component '${e}' has an invalid path: traversal sequences are not allowed.`)}n.push(a)}return n}function Z(e,t){return e.permissions?e.permissions.includes(t):!1}var Q=class{static checkPermission(e,t){if(!Z(e,t))throw new _t(e.name,t)}static getSanitizedCapabilities(e){return{remarkPlugins:Z(e,`mdx:remark`)?e.remarkPlugins:[],rehypePlugins:Z(e,`mdx:rehype`)?e.rehypePlugins:[],vitePlugins:Z(e,`vite:config`)?e.vitePlugins:[],components:Z(e,`components`)?e.components:{}}}static async executeWithIsolation(e,t,n,r){try{return this.checkPermission(e,t),await r()}catch(t){if(t instanceof _t){console.warn(`[boltdocs] Skipping hook '${n}' for plugin '${e.name}': ${t.message}`);return}throw t}}},St=class{plugins;config;store;constructor(e,t){this.plugins=e,this.config=t,this.store=new yt}async runHook(e,...t){let n=this.getSortedPlugins();for(let r of n){if(!r.hooks?.[e])continue;let n=this.createContext(r),i=e.toLowerCase().includes(`build`),a=e.toLowerCase().includes(`dev`),o=i?`hooks:build`:a?`hooks:dev`:void 0;try{o?await Q.executeWithIsolation(r,o,e,()=>r.hooks[e](n,...t)):await r.hooks[e](n,...t)}catch(t){let i=new vt(r.name,e,t instanceof Error?t:Error(String(t)));n.logger.error(i)}}}getSortedPlugins(){let e=this.plugins.filter(e=>e.enforce===`pre`),t=this.plugins.filter(e=>!e.enforce),n=this.plugins.filter(e=>e.enforce===`post`);return[...e,...t,...n]}createContext(e){return{config:Object.freeze({...this.config}),meta:{name:e.name,version:e.version,boltdocsVersion:e.boltdocsVersion},store:{get:(e,t)=>this.store.get(e,t),set:(e,t,n)=>this.store.set(e,t,n),has:(e,t)=>this.store.has(e,t)},logger:this.createLogger(e.name)}}createLogger(e){let t=`[plugin:${e}]`;return{info:e=>console.log(`${t} INFO: ${e}`),warn:e=>console.warn(`${t} WARN: ${e}`),error:e=>{let n=e instanceof Error?e.message:e;console.error(`${t} ERROR: ${n}`)},debug:e=>console.debug(`${t} DEBUG: ${e}`)}}};function Ct(e){return e}function wt(e={},t){let n=x.default.resolve(process.cwd(),e.docsDir||`docs`),r=R(n),i=t,a,o=!1,s,c=[];return[{name:`vite-plugin-boltdocs`,enforce:`pre`,async config(t,r){o=r.command===`build`;let a=t.envDir||process.cwd(),l=(0,d.loadEnv)(r.mode,a,``);Object.assign(process.env,l),i||=await J(n);let u=(await Promise.resolve().then(()=>require(`./package-Dgmsc_l5.cjs`))).version,f=xt(i.plugins||[],u);return i.plugins=f,s=new St(f,i),c=f.flatMap(e=>Q.getSanitizedCapabilities(e).vitePlugins||[]),o&&await s.runHook(`beforeBuild`),{ssgOptions:{entry:`boltdocs/entry`,htmlEntry:`index.html`,dirStyle:`nested`,includeAllRoutes:!0,mock:!0,script:`async`,beastiesOptions:{preload:`media`},onFinished:async e=>{let t=ct(Je(await Ge(n,i)),i);t&&S.default.writeFileSync(x.default.join(e,`sitemap.xml`),t);let r=lt(i);S.default.writeFileSync(x.default.join(e,`robots.txt`),r)}},build:{ssrManifest:o},async config(){let t=__dirname;for(;t!==x.default.parse(t).root&&!S.default.existsSync(x.default.join(t,`package.json`));)t=x.default.dirname(t);if(S.default.existsSync(x.default.join(t,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(t,`package.json`),`utf-8`)).name!==`boltdocs`){let e=x.default.dirname(t);for(;e!==x.default.parse(e).root;){if(S.default.existsSync(x.default.join(e,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=x.default.dirname(e)}}return{optimizeDeps:{include:[`react`,`react-dom`,`react-router-dom`],exclude:[`boltdocs`,`boltdocs/client`]},resolve:{alias:[{find:`boltdocs/entry`,replacement:R(x.default.resolve(e.root||process.cwd(),`boltdocs-entry.cjs`))}]}}}}},configResolved(e){a=e,s?.runHook(`configResolved`,i)},async configureServer(e){await s?.runHook(`beforeDev`),e.middlewares.use((e,t,n)=>{process.env.NODE_ENV===`production`&&Object.entries(mt).forEach(([e,n])=>{t.setHeader(e,n)}),i.security?.enableCSP&&t.setHeader(`Content-Security-Policy`,ht(i)),n()}),e.middlewares.use((e,t,n)=>{if(e.url===`/robots.txt`){n();return}n()}),e.middlewares.use(async(t,n,r)=>{let a=t.url?.split(`?`)[0]||`/`,o=t.headers.accept||``,s=a===`/`||a.startsWith(`/docs`)||i.i18n&&Object.keys(i.i18n.locales).some(e=>a.startsWith(`/${e}/docs`)||a===`/${e}`)||!0,c=/\.(js|css|png|jpe?g|gif|svg|ico|webp|woff2?|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac|pdf|zip|gz|map|json)$/i.test(a);if(o.includes(`text/html`)&&!c&&s){let r=dt(i);r=ft(r,i),r=await e.transformIndexHtml(t.url||`/`,r),n.statusCode=200,n.setHeader(`Content-Type`,`text/html`),n.end(r);return}r()});let t=st.map(e=>x.default.resolve(process.cwd(),e)),a=[`tsx`,`jsx`].map(e=>x.default.resolve(n,`layout.${e}`)),o=[`tsx`,`ts`,`jsx`,`js`],c=o.map(e=>x.default.resolve(n,`mdx-components.${e}`)),l=o.map(e=>x.default.resolve(n,`pages-external/index.${e}`)),u=o.map(e=>x.default.resolve(n,`icons.${e}`));e.watcher.add([...t,...c,...a,...l,...u]);let d=async(t,a)=>{try{let s=R(t);if(st.some(e=>s.endsWith(e))){e.restart();return}if(o.some(e=>s.endsWith(`mdx-components.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-mdx-components.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(o.some(e=>s.endsWith(`icons.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-icons.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.endsWith(`layout.tsx`)||s.endsWith(`layout.jsx`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-layout.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.includes(`/pages-external/`)||s.includes(`\\pages-external\\`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-entry`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(!s.startsWith(r)||!xe(s))return;if(a===`add`||a===`unlink`){Le(),i=await J(n);let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`custom`,event:`boltdocs:config-update`,data:{theme:i?.theme,i18n:i?.i18n,versions:i?.versions,siteUrl:i?.siteUrl}})}else Re(t);let c=e.moduleGraph.getModuleById(`\0virtual:boltdocs-routes.ts`);c&&e.moduleGraph.invalidateModule(c);let l=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);l&&e.moduleGraph.invalidateModule(l),e.ws.send({type:`full-reload`})}catch(e){console.error(`[boltdocs] HMR error during ${a} event:`,e)}};e.watcher.on(`add`,e=>d(e,`add`)),e.watcher.on(`unlink`,e=>d(e,`unlink`)),e.watcher.on(`change`,e=>d(e,`change`)),await s?.runHook(`afterDev`)},resolveId(e){let t=a?.root||process.cwd();return e.includes(`boltdocs-entry.mjs`)||e===`virtual:boltdocs-entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`?R(x.default.resolve(t,`boltdocs-entry.mjs`)):e.includes(`boltdocs-client.mjs`)||e===`virtual:boltdocs-client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.ts`?R(x.default.resolve(t,`boltdocs-client.mjs`)):e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(t){if(t.includes(`boltdocs-entry.mjs`)||t===`\0virtual:boltdocs-entry`)return ut(e,i);if(t.includes(`boltdocs-client.mjs`)||t===`\0virtual:boltdocs-client.ts`||t===`virtual:boltdocs-client`){let e=__dirname,t=e;for(;e!==x.default.parse(e).root;){if(S.default.existsSync(x.default.join(e,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=x.default.dirname(e)}let n=x.default.join(t,`src/client/index.ts`),r=x.default.join(t,`dist/client/index.js`);return`export * from '${R(S.default.existsSync(n)?n:r)}';`}if(!t.startsWith(`\0virtual:boltdocs-`))return;let r=t.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(r===`routes`){let e=Je(await Ge(n,i));return`export default ${JSON.stringify(e,null,2)};`}if(r===`config`){let e={theme:i?.theme,i18n:i?.i18n,versions:i?.versions,siteUrl:i?.siteUrl,plugins:i?.plugins?.map(e=>({name:e.name}))};return`export default ${JSON.stringify(e,null,2)};`}if(r===`entry`)return ut(e,i);if(r===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let r of e){let e=x.default.resolve(n,`mdx-components.${r}`);if(S.default.existsSync(e)){t=e;break}}if(t){let e=R(t);return`import * as components from '${e}';
|
|
84
|
+
</body>`)),e}function pt(e){let t=[];for(let n of e)if(t.push({id:n.path,title:n.title,content:n._content||``,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version});return t}const mt={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains`};function ht(e){let t=process.env.NODE_ENV===`development`,n={"default-src":[`'self'`],"script-src":[`'self'`,`'unsafe-inline'`],"style-src":[`'self'`,`'unsafe-inline'`],"img-src":[`'self'`,`data:`,`https:`],"font-src":[`'self'`],"connect-src":[`'self'`]};return t&&(n[`script-src`]=[`'self'`,`'unsafe-eval'`,`'unsafe-inline'`],n[`style-src`]=[`'self'`,`'unsafe-inline'`]),Object.entries(n).map(([e,t])=>`${e} ${t.join(` `)}`).join(`; `)}var Y=class e extends Error{pluginName;constructor(t,n){super(`[plugin:${t}] ${n}`),this.name=`PluginError`,this.pluginName=t,Object.setPrototypeOf(this,e.prototype)}},X=class e extends Y{constructor(t,n){super(t,`Validation failed: ${n}`),this.name=`PluginValidationError`,Object.setPrototypeOf(this,e.prototype)}},gt=class e extends Y{constructor(t,n){super(t,`Compatibility error: ${n}`),this.name=`PluginCompatibilityError`,Object.setPrototypeOf(this,e.prototype)}},_t=class e extends Y{constructor(t,n){super(t,`Missing required permission: '${n}'`),this.name=`PluginPermissionError`,Object.setPrototypeOf(this,e.prototype)}},vt=class e extends Y{hookName;constructor(t,n,r){super(t,`Error in hook '${n}': ${r.message}`),this.name=`PluginHookError`,this.hookName=n,this.stack=r.stack,Object.setPrototypeOf(this,e.prototype)}},yt=class{data=new Map;getNamespaceKey(e,t){return`${e}:${t}`}get(e,t){let n=this.getNamespaceKey(e,t),r=this.data.get(n);if(r!==void 0)return typeof r==`object`&&r?JSON.parse(JSON.stringify(r)):r}set(e,t,n){let r=this.getNamespaceKey(e,t),i=typeof n==`object`&&n?JSON.parse(JSON.stringify(n)):n;this.data.set(r,i)}has(e,t){let n=this.getNamespaceKey(e,t);return this.data.has(n)}};const bt=Qe.extend({version:g.z.string().optional(),boltdocsVersion:g.z.string().optional(),permissions:g.z.array(g.z.string()).optional(),hooks:g.z.object({beforeBuild:g.z.function().optional(),afterBuild:g.z.function().optional(),beforeDev:g.z.function().optional(),afterDev:g.z.function().optional(),configResolved:g.z.function().optional(),buildEnd:g.z.function().optional()}).optional()});function xt(e,t){let n=[],r=new Set;for(let i of e){let e=bt.safeParse(i);if(!e.success)throw new X(i.name||`unknown`,e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `));let a=e.data;if(r.has(a.name))throw new X(a.name,`Duplicate plugin name detected`);if(r.add(a.name),a.boltdocsVersion&&!C.default.satisfies(t,a.boltdocsVersion))throw new gt(a.name,`Plugin expects Boltdocs version ${a.boltdocsVersion}, but current is ${t}`);if(a.components){for(let[e,t]of Object.entries(a.components))if((t.includes(`..`)||_.default.isAbsolute(t))&&t.includes(`..`))throw new X(a.name,`Component '${e}' has an invalid path: traversal sequences are not allowed.`)}n.push(a)}return n}function Z(e,t){return e.permissions?e.permissions.includes(t):!1}var Q=class{static checkPermission(e,t){if(!Z(e,t))throw new _t(e.name,t)}static getSanitizedCapabilities(e){return{remarkPlugins:Z(e,`mdx:remark`)?e.remarkPlugins:[],rehypePlugins:Z(e,`mdx:rehype`)?e.rehypePlugins:[],vitePlugins:Z(e,`vite:config`)?e.vitePlugins:[],components:Z(e,`components`)?e.components:{}}}static async executeWithIsolation(e,t,n,r){try{return this.checkPermission(e,t),await r()}catch(t){if(t instanceof _t){console.warn(`[boltdocs] Skipping hook '${n}' for plugin '${e.name}': ${t.message}`);return}throw t}}},St=class{plugins;config;store;constructor(e,t){this.plugins=e,this.config=t,this.store=new yt}async runHook(e,...t){let n=this.getSortedPlugins();for(let r of n){if(!r.hooks?.[e])continue;let n=this.createContext(r),i=e.toLowerCase().includes(`build`),a=e.toLowerCase().includes(`dev`),o=i?`hooks:build`:a?`hooks:dev`:void 0;try{o?await Q.executeWithIsolation(r,o,e,()=>r.hooks[e](n,...t)):await r.hooks[e](n,...t)}catch(t){let i=new vt(r.name,e,t instanceof Error?t:Error(String(t)));n.logger.error(i)}}}getSortedPlugins(){let e=this.plugins.filter(e=>e.enforce===`pre`),t=this.plugins.filter(e=>!e.enforce),n=this.plugins.filter(e=>e.enforce===`post`);return[...e,...t,...n]}createContext(e){return{config:Object.freeze({...this.config}),meta:{name:e.name,version:e.version,boltdocsVersion:e.boltdocsVersion},store:{get:(e,t)=>this.store.get(e,t),set:(e,t,n)=>this.store.set(e,t,n),has:(e,t)=>this.store.has(e,t)},logger:this.createLogger(e.name)}}createLogger(e){let t=`[plugin:${e}]`;return{info:e=>console.log(`${t} INFO: ${e}`),warn:e=>console.warn(`${t} WARN: ${e}`),error:e=>{let n=e instanceof Error?e.message:e;console.error(`${t} ERROR: ${n}`)},debug:e=>console.debug(`${t} DEBUG: ${e}`)}}};function Ct(e){return e}function wt(e={},t){let n=x.default.resolve(process.cwd(),e.docsDir||`docs`),r=R(n),i=t,a,o=!1,s,c=[];return[{name:`vite-plugin-boltdocs`,enforce:`pre`,async config(e,t){o=t.command===`build`;let r=e.envDir||process.cwd(),a=(0,d.loadEnv)(t.mode,r,``);Object.assign(process.env,a),i||=await J(n);let l=(await Promise.resolve().then(()=>require(`./package-c99Cs7mD.cjs`))).version,u=xt(i.plugins||[],l);return i.plugins=u,s=new St(u,i),c=u.flatMap(e=>Q.getSanitizedCapabilities(e).vitePlugins||[]),o&&await s.runHook(`beforeBuild`),{ssgOptions:{entry:`boltdocs/entry`,htmlEntry:`index.html`,dirStyle:`nested`,includeAllRoutes:!0,mock:!0,script:`async`,beastiesOptions:{preload:`media`},onFinished:async e=>{let t=ct(Je(await Ge(n,i)),i);t&&S.default.writeFileSync(x.default.join(e,`sitemap.xml`),t);let r=lt(i);S.default.writeFileSync(x.default.join(e,`robots.txt`),r)}},build:{ssrManifest:o},async config(){let e=__dirname;for(;e!==x.default.parse(e).root&&!S.default.existsSync(x.default.join(e,`package.json`));)e=x.default.dirname(e);if(S.default.existsSync(x.default.join(e,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(e,`package.json`),`utf-8`)).name!==`boltdocs`){let t=x.default.dirname(e);for(;t!==x.default.parse(t).root;){if(S.default.existsSync(x.default.join(t,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(t,`package.json`),`utf-8`)).name===`boltdocs`){e=t;break}t=x.default.dirname(t)}}return{optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-router-dom`,`react-helmet-async`],exclude:[`boltdocs`,`boltdocs/client`]},resolve:{dedupe:[`react`,`react-dom`]}}}}},configResolved(e){a=e,s?.runHook(`configResolved`,i)},async configureServer(e){await s?.runHook(`beforeDev`),e.middlewares.use((e,t,n)=>{process.env.NODE_ENV===`production`&&Object.entries(mt).forEach(([e,n])=>{t.setHeader(e,n)}),i.security?.enableCSP&&t.setHeader(`Content-Security-Policy`,ht(i)),n()}),e.middlewares.use((e,t,n)=>{if(e.url===`/robots.txt`){n();return}n()}),e.middlewares.use(async(t,n,r)=>{let a=t.url?.split(`?`)[0]||`/`,o=t.headers.accept||``,s=a===`/`||a.startsWith(`/docs`)||i.i18n&&Object.keys(i.i18n.locales).some(e=>a.startsWith(`/${e}/docs`)||a===`/${e}`)||!0,c=/\.(js|css|png|jpe?g|gif|svg|ico|webp|woff2?|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac|pdf|zip|gz|map|json)$/i.test(a);if(o.includes(`text/html`)&&!c&&s){let r=dt(i);r=ft(r,i),r=await e.transformIndexHtml(t.url||`/`,r),n.statusCode=200,n.setHeader(`Content-Type`,`text/html`),n.end(r);return}r()});let t=st.map(e=>x.default.resolve(process.cwd(),e)),a=[`tsx`,`jsx`].map(e=>x.default.resolve(n,`layout.${e}`)),o=[`tsx`,`ts`,`jsx`,`js`],c=o.map(e=>x.default.resolve(n,`mdx-components.${e}`)),l=o.map(e=>x.default.resolve(n,`pages-external/index.${e}`)),u=o.map(e=>x.default.resolve(n,`icons.${e}`));e.watcher.add([...t,...c,...a,...l,...u]);let d=async(t,a)=>{try{let s=R(t);if(st.some(e=>s.endsWith(e))){e.restart();return}if(o.some(e=>s.endsWith(`mdx-components.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-mdx-components.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(o.some(e=>s.endsWith(`icons.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-icons.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.endsWith(`layout.tsx`)||s.endsWith(`layout.jsx`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-layout.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.includes(`/pages-external/`)||s.includes(`\\pages-external\\`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-entry`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(!s.startsWith(r)||!xe(s))return;if(a===`add`||a===`unlink`){Le(),i=await J(n);let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`custom`,event:`boltdocs:config-update`,data:{theme:i?.theme,i18n:i?.i18n,versions:i?.versions,siteUrl:i?.siteUrl}})}else Re(t);let c=e.moduleGraph.getModuleById(`\0virtual:boltdocs-routes.ts`);c&&e.moduleGraph.invalidateModule(c);let l=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);l&&e.moduleGraph.invalidateModule(l),e.ws.send({type:`full-reload`})}catch(e){console.error(`[boltdocs] HMR error during ${a} event:`,e)}};e.watcher.on(`add`,e=>d(e,`add`)),e.watcher.on(`unlink`,e=>d(e,`unlink`)),e.watcher.on(`change`,e=>d(e,`change`)),await s?.runHook(`afterDev`)},resolveId(e){let t=a?.root||process.cwd();return e.includes(`boltdocs-entry.mjs`)||e===`virtual:boltdocs-entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`?R(x.default.resolve(t,`boltdocs-entry.mjs`)):e.includes(`boltdocs-client.mjs`)||e===`virtual:boltdocs-client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.ts`?R(x.default.resolve(t,`boltdocs-client.mjs`)):e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(t){if(t.includes(`boltdocs-entry.mjs`)||t===`\0virtual:boltdocs-entry`)return ut(e,i);if(t.includes(`boltdocs-client.mjs`)||t===`\0virtual:boltdocs-client.ts`||t===`virtual:boltdocs-client`){let e=__dirname,t=e;for(;e!==x.default.parse(e).root;){if(S.default.existsSync(x.default.join(e,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=x.default.dirname(e)}let n=x.default.join(t,`src/client/index.ts`),r=x.default.join(t,`dist/client/index.js`);return`export * from '${R(S.default.existsSync(n)?n:r)}';`}if(!t.startsWith(`\0virtual:boltdocs-`))return;let r=t.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(r===`routes`){let e=Je(await Ge(n,i));return`export default ${JSON.stringify(e,null,2)};`}if(r===`config`){let e={theme:i?.theme,i18n:i?.i18n,versions:i?.versions,siteUrl:i?.siteUrl,plugins:i?.plugins?.map(e=>({name:e.name}))};return`export default ${JSON.stringify(e,null,2)};`}if(r===`entry`)return ut(e,i);if(r===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let r of e){let e=x.default.resolve(n,`mdx-components.${r}`);if(S.default.existsSync(e)){t=e;break}}if(t){let e=R(t);return`import * as components from '${e}';
|
|
85
85
|
const mdxComponents = components.default || components;
|
|
86
86
|
export default mdxComponents;
|
|
87
|
-
export * from '${e}';`}return`export default {};`}if(r===`layout`){let e=[`tsx`,`jsx`],t=null;for(let r of e){let e=x.default.resolve(n,`layout.${r}`);if(S.default.existsSync(e)){t=e;break}}return
|
|
88
|
-
export default UserLayout
|
|
89
|
-
export default DefaultLayout;`}if(r===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let r of e){let e=x.default.resolve(n,`icons.${r}`);if(S.default.existsSync(e)){t=e;break}}return t?`import * as icons from '${R(t)}';\nexport default icons;`:`export default {};`}if(r===`search`){let e=pt(await Ge(n,i));return`export default ${JSON.stringify(e,null,2)};`}if(r===`client`){let e=__dirname,t=``;for(;e&&e!==x.default.parse(e).root;){let n=x.default.join(e,`src/client/index.ts`),r=x.default.join(e,`dist/client/index.mjs`),i=x.default.join(e,`client/index.ts`);if(S.default.existsSync(n)){t=R(n);break}if(S.default.existsSync(r)){t=R(r);break}if(S.default.existsSync(i)){t=R(i);break}e=x.default.dirname(e)}if(!t)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${__dirname}`);return`export * from '${t}';`}},transformIndexHtml:{order:`pre`,handler(e){return ft(e,i)}},async closeBundle(){!o||a?.build?.ssr||(await s?.runHook(`afterBuild`),await s?.runHook(`buildEnd`))}},(0,te.ViteImageOptimizer)({includePublic:!0,png:{quality:80},jpeg:{quality:80},jpg:{quality:80},webp:{quality:80},avif:{quality:80},svg:{multipass:!0,plugins:[{name:`preset-default`}]}}),{name:`vite-plugin-boltdocs-extra-plugins`,async configResolved(){}},...c]}const $=new Ie(`mdx`),Tt=[k.default.default||k.default,A.default.default||A.default,j.default.default||j.default,M.default.default||M.default,N.default.default||N.default,P.default.default||P.default,F.default.default||F.default],Et=[ie.default,ae.default,oe.default,se.default,ce.default,le.default,ue.default,de.default,fe.default,pe.default,me.default,he.default];let Dt=null,Ot=null;const kt=()=>(Dt??=(0,ne.createJavaScriptRegexEngine)(),Dt),At=async e=>Ot||(Ot=(0,re.createHighlighterCore)({themes:Tt,langs:Et,engine:kt()}),Ot),jt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:line-numbers`,pre(e){let n=this.options.meta?.__raw||``,r=/lineNumbers|showLineNumbers/.test(n);(t||r)&&this.addClassToHast(e,`shiki-line-numbers`)}}},Mt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:word-wrap`,pre(e){let n=this.options.meta?.__raw||``,r=/wordWrap|word-wrap/.test(n);(t||r)&&this.addClassToHast(e,`shiki-word-wrap`)}}},Nt=()=>({name:`AddTitleProperty`,pre(e){let t=this.options.meta?.__raw;if(!t)return;let n=t.match(/title=(["'])(.*?)\1/)?.[2];e.properties[`data-title`]=n}}),Pt=()=>({name:`AddLanguageProperty`,pre(e){e.properties[`data-lang`]=this.options.lang||`plaintext`}});var Ft=class{config;constructor(e){this.config=e}getTheme(){return this.config?.theme?.codeTheme||{light:`github-light`,dark:`github-dark`}}async getHighlighter(){return await At(this.getTheme())}getOptions(e,t){let n=this.getTheme(),r={lang:e,meta:{__raw:t},transformers:[jt(),Mt(),Nt(),Pt()]};return typeof n==`object`?r.themes={light:n.light,dark:n.dark}:r.theme=n,r}async render(e,t,n){let r=await this.getHighlighter(),i=this.getOptions(t,n);return r.codeToHtml(e,i)}};function It(e){let t=new Ft(e);return async e=>{let n=await t.getHighlighter();(0,O.visit)(e,[`mdxJsxFlowElement`,`mdxJsxTextElement`],e=>{if(e.name!==`ComponentPreview`)return;let r=e.attributes?.find(e=>e.name===`code`),i=``;if(r){if(typeof r.value==`string`)i=r.value;else if(r.value?.type===`mdxJsxAttributeValueExpression`){let e=r.value.value??``;i=e.match(/^[`'"]([\s\S]+)[`'"]$/)?.[1]??e}}if(!i)return;let a=e.attributes?.find(e=>e.name===`lineNumbers`||e.name===`showLineNumbers`),o=e.attributes?.find(e=>e.name===`wordWrap`||e.name===`word-wrap`),s=e.attributes?.find(e=>e.name===`title`),c=``;a&&(c+=` lineNumbers`),o&&(c+=` wordWrap`),s&&typeof s.value==`string`&&(c+=` title="${s.value}"`);let l=t.getOptions(`tsx`,c),u=n.codeToHtml(i,l);e.attributes=(e.attributes??[]).filter(e=>e.name!==`highlightedHtml`),e.attributes.push({type:`mdxJsxAttribute`,name:`highlightedHtml`,value:u})})}}function Lt(e){let t=new Ft(e);return async e=>{let n=await t.getHighlighter();(0,O.visit)(e,`element`,e=>{if(e.tagName===`pre`&&e.children?.[0]?.tagName===`code`){let r=e.children[0],i=(r.properties?.className||[]).find(e=>e.startsWith(`language-`)),a=i?i.slice(9):`text`,o=r.children[0]?.value||``,s=r.properties?.metastring||r.data?.meta||``,c=t.getOptions(a,s),l=n.codeToHtml(o,c);e.properties[`data-highlighted`]=`true`,e.properties[`data-highlighted-html`]=l,e.properties[`data-lang`]=a,e.children=[]}})}}function Rt(){return e=>{(0,O.visit)(e,`code`,e=>{e.meta&&(e.data=e.data||{},e.data.hProperties=e.data.hProperties||{},e.data.hProperties.metastring=e.meta)})}}let zt=!1;function Bt(e,t=w.default){let n=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).remarkPlugins||[])||[],r=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).rehypePlugins||[])||[],i=t({remarkPlugins:[T.default,E.default,Rt,[It,e],...n],rehypePlugins:[D.default,[Lt,e],...r],jsxRuntime:`automatic`});return{...i,name:`vite-plugin-boltdocs-mdx`,async buildStart(){zt||=($.load(),!0),i.buildStart&&await i.buildStart.call(this)},async transform(e,t,n){if(!t.endsWith(`.md`)&&!t.endsWith(`.mdx`))return i.transform?.call(this,e,t,n);let r=`${t}:${v.default.createHash(`md5`).update(e).digest(`hex`)}:v2`,a=$.get(r);if(a)return{code:a,map:null};let o=await i.transform.call(this,e,t,n);return o&&typeof o==`object`&&o.code&&$.set(r,o.code),o},async buildEnd(){$.save(),await $.flush(),i.buildEnd&&await i.buildEnd.call(this)}}}async function Vt(e){let t=await J(e?.docsDir||`docs`);return[...wt({...e,homePage:e?.homePage||t.homePage},t),Bt(t)]}async function Ht(e,t=`development`){let n=await J(`docs`,e),r=t===`production`,i=r?{...mt}:{};return n.security?.enableCSP&&(i[`Content-Security-Policy`]=ht(n)),{root:e,mode:t,oxc:{jsx:{development:!r,runtime:`automatic`,importSource:`react`}},optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-helmet-async`,`react-router-dom`],rolldownOptions:{}},build:{rolldownOptions:{}},plugins:[(0,l.default)(),(0,u.default)(),await Vt({...n,root:e})],resolve:{alias:{"boltdocs/entry":(0,d.normalizePath)(x.default.resolve(e,`boltdocs-entry.mjs`)),"boltdocs/client":(0,d.normalizePath)(x.default.resolve(e,`boltdocs-client.mjs`))},dedupe:[`react`,`react-dom`,`react-router-dom`,`react-helmet-async`,`@bdocs/ssg`]},ssr:{noExternal:[`boltdocs`,/@bdocs\/(?!ssg).*/,`react-helmet-async`]},server:{headers:{...i,...n.vite?.server?.headers},...n.vite?.server},preview:{headers:{...i,...n.vite?.preview?.headers},...n.vite?.preview},...n.vite}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return ut}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return Ce}});
|
|
87
|
+
export * from '${e}';`}return`export default {};`}if(r===`layout`){let e=[`tsx`,`jsx`],t=null;for(let r of e){let e=x.default.resolve(n,`layout.${r}`);if(S.default.existsSync(e)){t=e;break}}if(t)return`import UserLayout from '${R(t)}';
|
|
88
|
+
export default UserLayout;`;throw Error(`[Boltdocs] Layout file not found. A 'layout.tsx' or 'layout.jsx' file is mandatory in your docs directory. Please create one to define your site structure.`)}if(r===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let r of e){let e=x.default.resolve(n,`icons.${r}`);if(S.default.existsSync(e)){t=e;break}}return t?`import * as icons from '${R(t)}';\nexport default icons;`:`export default {};`}if(r===`search`){let e=pt(await Ge(n,i));return`export default ${JSON.stringify(e,null,2)};`}if(r===`client`){let e=__dirname,t=``;for(;e&&e!==x.default.parse(e).root;){let n=x.default.join(e,`src/client/index.ts`),r=x.default.join(e,`dist/client/index.mjs`),i=x.default.join(e,`client/index.ts`);if(S.default.existsSync(n)){t=R(n);break}if(S.default.existsSync(r)){t=R(r);break}if(S.default.existsSync(i)){t=R(i);break}e=x.default.dirname(e)}if(!t)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${__dirname}`);return`export * from '${t}';`}},transformIndexHtml:{order:`pre`,handler(e){return ft(e,i)}},async closeBundle(){!o||a?.build?.ssr||(await s?.runHook(`afterBuild`),await s?.runHook(`buildEnd`))}},(0,te.ViteImageOptimizer)({includePublic:!0,png:{quality:80},jpeg:{quality:80},jpg:{quality:80},webp:{quality:80},avif:{quality:80},svg:{multipass:!0,plugins:[{name:`preset-default`}]}}),{name:`vite-plugin-boltdocs-extra-plugins`,async configResolved(){}},...c]}const $=new Ie(`mdx`),Tt=[k.default.default||k.default,A.default.default||A.default,j.default.default||j.default,M.default.default||M.default,N.default.default||N.default,P.default.default||P.default,F.default.default||F.default],Et=[ie.default,ae.default,oe.default,se.default,ce.default,le.default,ue.default,de.default,fe.default,pe.default,me.default,he.default];let Dt=null,Ot=null;const kt=()=>(Dt??=(0,ne.createJavaScriptRegexEngine)(),Dt),At=async e=>Ot||(Ot=(0,re.createHighlighterCore)({themes:Tt,langs:Et,engine:kt()}),Ot),jt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:line-numbers`,pre(e){let n=this.options.meta?.__raw||``,r=/lineNumbers|showLineNumbers/.test(n);(t||r)&&this.addClassToHast(e,`shiki-line-numbers`)}}},Mt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:word-wrap`,pre(e){let n=this.options.meta?.__raw||``,r=/wordWrap|word-wrap/.test(n);(t||r)&&this.addClassToHast(e,`shiki-word-wrap`)}}},Nt=()=>({name:`AddTitleProperty`,pre(e){let t=this.options.meta?.__raw;if(!t)return;let n=t.match(/title=(["'])(.*?)\1/)?.[2];e.properties[`data-title`]=n}}),Pt=()=>({name:`AddLanguageProperty`,pre(e){e.properties[`data-lang`]=this.options.lang||`plaintext`}});var Ft=class{config;constructor(e){this.config=e}getTheme(){return this.config?.theme?.codeTheme||{light:`github-light`,dark:`github-dark`}}async getHighlighter(){return await At(this.getTheme())}getOptions(e,t){let n=this.getTheme(),r={lang:e,meta:{__raw:t},transformers:[jt(),Mt(),Nt(),Pt()]};return typeof n==`object`?r.themes={light:n.light,dark:n.dark}:r.theme=n,r}async render(e,t,n){let r=await this.getHighlighter(),i=this.getOptions(t,n);return r.codeToHtml(e,i)}};function It(e){let t=new Ft(e);return async e=>{let n=await t.getHighlighter();(0,O.visit)(e,[`mdxJsxFlowElement`,`mdxJsxTextElement`],e=>{if(e.name!==`ComponentPreview`)return;let r=e.attributes?.find(e=>e.name===`code`),i=``;if(r){if(typeof r.value==`string`)i=r.value;else if(r.value?.type===`mdxJsxAttributeValueExpression`){let e=r.value.value??``;i=e.match(/^[`'"]([\s\S]+)[`'"]$/)?.[1]??e}}if(!i)return;let a=e.attributes?.find(e=>e.name===`lineNumbers`||e.name===`showLineNumbers`),o=e.attributes?.find(e=>e.name===`wordWrap`||e.name===`word-wrap`),s=e.attributes?.find(e=>e.name===`title`),c=``;a&&(c+=` lineNumbers`),o&&(c+=` wordWrap`),s&&typeof s.value==`string`&&(c+=` title="${s.value}"`);let l=t.getOptions(`tsx`,c),u=n.codeToHtml(i,l);e.attributes=(e.attributes??[]).filter(e=>e.name!==`highlightedHtml`),e.attributes.push({type:`mdxJsxAttribute`,name:`highlightedHtml`,value:u})})}}function Lt(e){let t=new Ft(e);return async e=>{let n=await t.getHighlighter();(0,O.visit)(e,`element`,e=>{if(e.tagName===`pre`&&e.children?.[0]?.tagName===`code`){let r=e.children[0],i=(r.properties?.className||[]).find(e=>e.startsWith(`language-`)),a=i?i.slice(9):`text`,o=r.children[0]?.value||``,s=r.properties?.metastring||r.data?.meta||``,c=t.getOptions(a,s),l=n.codeToHtml(o,c);e.properties[`data-highlighted`]=`true`,e.properties[`data-highlighted-html`]=l,e.properties[`data-lang`]=a,e.children=[]}})}}function Rt(){return e=>{(0,O.visit)(e,`code`,e=>{e.meta&&(e.data=e.data||{},e.data.hProperties=e.data.hProperties||{},e.data.hProperties.metastring=e.meta)})}}let zt=!1;function Bt(e,t=w.default){let n=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).remarkPlugins||[])||[],r=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).rehypePlugins||[])||[],i=t({remarkPlugins:[T.default,E.default,Rt,[It,e],...n],rehypePlugins:[D.default,[Lt,e],...r],jsxRuntime:`automatic`});return{...i,name:`vite-plugin-boltdocs-mdx`,async buildStart(){zt||=($.load(),!0),i.buildStart&&await i.buildStart.call(this)},async transform(e,t,n){if(!t.endsWith(`.md`)&&!t.endsWith(`.mdx`))return i.transform?.call(this,e,t,n);let r=`${t}:${v.default.createHash(`md5`).update(e).digest(`hex`)}:v2`,a=$.get(r);if(a)return{code:a,map:null};let o=await i.transform.call(this,e,t,n);return o&&typeof o==`object`&&o.code&&$.set(r,o.code),o},async buildEnd(){$.save(),await $.flush(),i.buildEnd&&await i.buildEnd.call(this)}}}async function Vt(e){let t=await J(e?.docsDir||`docs`);return[...wt({...e,homePage:e?.homePage||t.homePage},t),Bt(t)]}async function Ht(e,t=`development`){let n=await J(`docs`,e),r=t===`production`,i=r?{...mt}:{};return n.security?.enableCSP&&(i[`Content-Security-Policy`]=ht(n)),{root:e,mode:t,oxc:{jsx:{development:!r,runtime:`automatic`,importSource:`react`}},optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-helmet-async`,`react-router-dom`,`use-sync-external-store/shim`],rolldownOptions:{}},build:{rolldownOptions:{}},plugins:[(0,l.default)(),(0,u.default)(),await Vt({...n,root:e})],resolve:{alias:[{find:`boltdocs/entry`,replacement:(0,d.normalizePath)(x.default.resolve(e,`boltdocs-entry.mjs`))},{find:`boltdocs/client`,replacement:(0,d.normalizePath)(x.default.resolve(e,`boltdocs-client.mjs`))},{find:`use-sync-external-store/shim/index.js`,replacement:`react`},{find:`use-sync-external-store/shim`,replacement:`react`},{find:`use-sync-external-store`,replacement:`react`}],dedupe:[`react`,`react-dom`,`react-router-dom`,`react-helmet-async`,`@bdocs/ssg`]},ssr:{noExternal:[`boltdocs`,/@bdocs\/(?!ssg).*/,`react-helmet-async`,`react-aria-components`,`@react-aria/collections`,`@react-aria/utils`]},server:{headers:{...i,...n.vite?.server?.headers},...n.vite?.server},preview:{headers:{...i,...n.vite?.preview?.headers},...n.vite?.preview},...n.vite}}Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return ut}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return Ce}});
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var e=`2.6.
|
|
6
|
+
var e=`2.6.1`;Object.defineProperty(exports,`version`,{enumerable:!0,get:function(){return e}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boltdocs",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "A lightweight documentation generator for React projects.",
|
|
5
5
|
"main": "dist/node/index.mjs",
|
|
6
6
|
"module": "dist/node/index.mjs",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
33
|
"bin",
|
|
34
|
-
"src/client"
|
|
34
|
+
"src/client",
|
|
35
|
+
"src/shared"
|
|
35
36
|
],
|
|
36
37
|
"keywords": [
|
|
37
38
|
"docs",
|
package/src/client/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export type { BoltdocsConfig, BoltdocsThemeConfig } from '../shared/types'
|
|
2
|
-
export { defineConfig } from '../shared/config-utils'
|
|
3
1
|
export type {
|
|
4
2
|
ComponentRoute,
|
|
5
3
|
LayoutProps,
|
|
@@ -14,7 +12,6 @@ export { useMdxComponents } from './app/mdx-components-context'
|
|
|
14
12
|
export * from './hooks/index'
|
|
15
13
|
// Composable layout building blocks
|
|
16
14
|
export { DocsLayout } from './components/docs-layout'
|
|
17
|
-
export { DefaultLayout } from './components/default-layout'
|
|
18
15
|
|
|
19
16
|
// Default UI components (for use in custom layout.tsx)
|
|
20
17
|
export { Navbar } from './components/ui-base/navbar'
|
|
@@ -104,3 +101,4 @@ export { Skeleton as PrimitiveSkeleton } from './components/primitives/skeleton'
|
|
|
104
101
|
|
|
105
102
|
// Utilities
|
|
106
103
|
export { cn } from './utils/cn'
|
|
104
|
+
export { getTranslated } from './utils/i18n'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BoltdocsConfig } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type-safe helper for defining Boltdocs configuration.
|
|
5
|
+
* This is an identity function that provides IntelliSense in both
|
|
6
|
+
* Node.js (config files) and client-side code (MDX examples).
|
|
7
|
+
*
|
|
8
|
+
* @param config - The Boltdocs configuration object
|
|
9
|
+
*/
|
|
10
|
+
export function defineConfig(config: BoltdocsConfig): BoltdocsConfig {
|
|
11
|
+
return config
|
|
12
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Plugin as VitePlugin } from 'vite'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a single social link in the configuration.
|
|
5
|
+
*/
|
|
6
|
+
export interface BoltdocsSocialLink {
|
|
7
|
+
icon: 'discord' | 'x' | 'github' | 'bluesky' | string
|
|
8
|
+
link: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the site footer.
|
|
13
|
+
*/
|
|
14
|
+
export interface BoltdocsFooterConfig {
|
|
15
|
+
text?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Theme-specific configuration options.
|
|
20
|
+
*/
|
|
21
|
+
export interface BoltdocsThemeConfig {
|
|
22
|
+
title?: string | Record<string, string>
|
|
23
|
+
description?: string | Record<string, string>
|
|
24
|
+
logo?:
|
|
25
|
+
| string
|
|
26
|
+
| {
|
|
27
|
+
dark: string
|
|
28
|
+
light: string
|
|
29
|
+
alt?: string
|
|
30
|
+
width?: number
|
|
31
|
+
height?: number
|
|
32
|
+
}
|
|
33
|
+
navbar?: Array<{
|
|
34
|
+
label: string | Record<string, string>
|
|
35
|
+
href: string
|
|
36
|
+
}>
|
|
37
|
+
sidebar?: Record<string, Array<{ text: string; link: string }>>
|
|
38
|
+
sidebarGroups?: Record<string, { title?: string; icon?: string }>
|
|
39
|
+
socialLinks?: BoltdocsSocialLink[]
|
|
40
|
+
footer?: BoltdocsFooterConfig
|
|
41
|
+
breadcrumbs?: boolean
|
|
42
|
+
editLink?: string
|
|
43
|
+
communityHelp?: string
|
|
44
|
+
version?: string
|
|
45
|
+
githubRepo?: string
|
|
46
|
+
favicon?: string
|
|
47
|
+
poweredBy?: boolean
|
|
48
|
+
tabs?: Array<{
|
|
49
|
+
id: string
|
|
50
|
+
text: string | Record<string, string>
|
|
51
|
+
icon?: string
|
|
52
|
+
}>
|
|
53
|
+
codeTheme?: ShikiTheme | { light: ShikiTheme; dark: ShikiTheme }
|
|
54
|
+
copyMarkdown?: boolean | { text?: string; icon?: string }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List of supported syntax highlighting themes.
|
|
59
|
+
*/
|
|
60
|
+
export type ShikiTheme =
|
|
61
|
+
| 'github-dark'
|
|
62
|
+
| 'github-light'
|
|
63
|
+
| 'tokyo-night'
|
|
64
|
+
| 'dracula'
|
|
65
|
+
| 'nord'
|
|
66
|
+
| 'one-dark-pro'
|
|
67
|
+
| 'one-light'
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Configuration for the robots.txt file.
|
|
71
|
+
*/
|
|
72
|
+
export type BoltdocsRobotsConfig =
|
|
73
|
+
| string
|
|
74
|
+
| {
|
|
75
|
+
rules?: Array<{
|
|
76
|
+
userAgent: string
|
|
77
|
+
allow?: string | string[]
|
|
78
|
+
disallow?: string | string[]
|
|
79
|
+
}>
|
|
80
|
+
sitemaps?: string[]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Configuration for a specific locale.
|
|
85
|
+
*/
|
|
86
|
+
export interface BoltdocsLocaleConfig {
|
|
87
|
+
label?: string
|
|
88
|
+
direction?: 'ltr' | 'rtl'
|
|
89
|
+
htmlLang?: string
|
|
90
|
+
calendar?: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Configuration for internationalization (i18n).
|
|
95
|
+
*/
|
|
96
|
+
export interface BoltdocsI18nConfig {
|
|
97
|
+
defaultLocale: string
|
|
98
|
+
locales: Record<string, string>
|
|
99
|
+
localeConfigs?: Record<string, BoltdocsLocaleConfig>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Configuration for a specific documentation version.
|
|
104
|
+
*/
|
|
105
|
+
export interface BoltdocsVersionConfig {
|
|
106
|
+
label: string
|
|
107
|
+
path: string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Configuration for documentation versioning.
|
|
112
|
+
*/
|
|
113
|
+
export interface BoltdocsVersionsConfig {
|
|
114
|
+
defaultVersion: string
|
|
115
|
+
prefix?: string
|
|
116
|
+
versions: BoltdocsVersionConfig[]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Defines a Boltdocs plugin.
|
|
121
|
+
*/
|
|
122
|
+
export interface BoltdocsPlugin {
|
|
123
|
+
name: string
|
|
124
|
+
enforce?: 'pre' | 'post'
|
|
125
|
+
version?: string
|
|
126
|
+
boltdocsVersion?: string
|
|
127
|
+
permissions?: string[] // simplified for shared types
|
|
128
|
+
remarkPlugins?: unknown[]
|
|
129
|
+
rehypePlugins?: unknown[]
|
|
130
|
+
vitePlugins?: VitePlugin[]
|
|
131
|
+
components?: Record<string, string>
|
|
132
|
+
hooks?: Record<string, any>
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Configuration for security-related settings.
|
|
137
|
+
*/
|
|
138
|
+
export interface BoltdocsSecurityConfig {
|
|
139
|
+
headers?: Record<string, string>
|
|
140
|
+
enableCSP?: boolean
|
|
141
|
+
customHeaders?: Record<string, string>
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Configuration for SEO.
|
|
146
|
+
*/
|
|
147
|
+
export interface BoltdocsSeoConfig {
|
|
148
|
+
metatags?: Record<string, string>
|
|
149
|
+
indexing?: 'all' | 'public'
|
|
150
|
+
thumbnails?: {
|
|
151
|
+
background?: string
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The root configuration object for Boltdocs.
|
|
157
|
+
*/
|
|
158
|
+
export interface BoltdocsConfig {
|
|
159
|
+
siteUrl?: string
|
|
160
|
+
docsDir?: string
|
|
161
|
+
base?: string
|
|
162
|
+
homePage?: string
|
|
163
|
+
theme?: BoltdocsThemeConfig
|
|
164
|
+
i18n?: BoltdocsI18nConfig
|
|
165
|
+
versions?: BoltdocsVersionsConfig
|
|
166
|
+
plugins?: BoltdocsPlugin[]
|
|
167
|
+
robots?: BoltdocsRobotsConfig
|
|
168
|
+
security?: BoltdocsSecurityConfig
|
|
169
|
+
seo?: BoltdocsSeoConfig
|
|
170
|
+
vite?: any // Avoid pulling in entire Vite types here
|
|
171
|
+
}
|
package/dist/node-BgvNl2Ay.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
-
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
import e from"@vitejs/plugin-react";import t from"@tailwindcss/vite";import n from"node:path";import{fileURLToPath as r}from"node:url";import{loadConfigFromFile as i,loadEnv as a,normalizePath as o}from"vite";import s from"fast-glob";import c from"fs";import l from"gray-matter";import u from"isomorphic-dompurify";import{z as d}from"zod";import f from"path";import p from"crypto";import m from"zlib";import{promisify as h}from"util";import ee from"github-slugger";import{ViteImageOptimizer as te}from"vite-plugin-image-optimizer";import g from"node:fs";import _ from"semver";import v from"@mdx-js/rollup";import ne from"remark-gfm";import re from"remark-frontmatter";import ie from"rehype-slug";import{visit as y}from"unist-util-visit";import{createJavaScriptRegexEngine as b}from"shiki/engine/javascript";import{createHighlighterCore as x}from"shiki/core";import S from"@shikijs/themes/github-light";import C from"@shikijs/themes/github-dark";import ae from"@shikijs/themes/tokyo-night";import w from"@shikijs/themes/dracula";import T from"@shikijs/themes/nord";import E from"@shikijs/themes/one-dark-pro";import oe from"@shikijs/themes/one-light";import D from"@shikijs/langs/html";import se from"@shikijs/langs/js";import ce from"@shikijs/langs/ts";import le from"@shikijs/langs/tsx";import ue from"@shikijs/langs/css";import de from"@shikijs/langs/json";import fe from"@shikijs/langs/bash";import pe from"@shikijs/langs/markdown";import me from"@shikijs/langs/mdx";import he from"@shikijs/langs/yaml";import ge from"@shikijs/langs/rust";import _e from"@shikijs/langs/toml";const O=n.dirname(r(import.meta.url)),ve=/^[a-zA-Z0-9\-_\/\.\(\)]+$/,ye=d.object({title:d.string().max(200).optional(),description:d.string().max(500).optional(),sidebarPosition:d.number().optional(),sidebarLabel:d.string().max(100).optional(),category:d.string().max(50).optional(),order:d.number().optional(),badge:d.string().max(50).optional(),icon:d.string().max(50).optional()});var k=class e extends Error{constructor(t){super(t),this.name=`SecurityViolationError`,Object.setPrototypeOf(this,e.prototype)}},be=class e extends k{constructor(t){super(t),this.name=`PathTraversalError`,Object.setPrototypeOf(this,e.prototype)}},xe=class e extends k{constructor(t){super(t),this.name=`EncodingSecurityError`,Object.setPrototypeOf(this,e.prototype)}},A=class e extends k{constructor(t){super(t),this.name=`ValidationError`,Object.setPrototypeOf(this,e.prototype)}};function j(e){return e.replace(/\\/g,`/`)}function M(e){return e.replace(/^\d+\./,``)}function Se(e){let t=e.match(/^(\d+)\./);return t?parseInt(t[1],10):void 0}function Ce(e){return/\.mdx?$/.test(e)}function N(e){try{return c.statSync(e).mtimeMs}catch{return 0}}function we(e){let t=c.readFileSync(e,`utf-8`);try{let{data:n,content:r,matter:i}=l(t);if(i&&i.length>10240)throw L(`FRONTMATTER_TOO_LARGE`,`Frontmatter block exceeds size limit`,{size:i.length,file:e}),new A(`Security breach: Frontmatter size exceeds limit of 10240 bytes`);let a=ye.safeParse(n);a.success||console.warn(`[VALIDATION][${e}] Invalid frontmatter fields detected.`);let o={...a.success?a.data:{}};return o.title&&=F(o.title).trim(),o.description&&=F(o.description).trim(),{data:o,content:r}}catch(e){if(e instanceof A)throw e;return{data:{},content:t}}}function Te(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function Ee(e){return Te(e)}function De(e){let t=e.split(`/`).map(e=>M(Oe(e))).join(`/`).replace(/\/$/,``);return t=t.replace(/\.mdx?$/,``),(t===`index`||t.endsWith(`/index`))&&(t=t.replace(/index$/,``)),t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function P(e){return u.sanitize(e,{ALLOWED_TAGS:`b.i.em.strong.a.p.br.code.pre.span.div.h1.h2.h3.h4.h5.h6.ul.ol.li.table.thead.tbody.tr.th.td.blockquote.hr`.split(`.`),ALLOWED_ATTR:[`href`,`title`,`target`,`class`,`id`,`src`,`alt`,`width`,`height`],FORCE_BODY:!0})}u.addHook(`afterSanitizeAttributes`,e=>{if(e.hasAttribute(`href`)){let t=e.getAttribute(`href`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`href`)}if(e.hasAttribute(`src`)){let t=e.getAttribute(`src`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`src`)}});function F(e){return u.sanitize(e,{ALLOWED_TAGS:[],KEEP_CONTENT:!0})}function I(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Oe(e){return e.replace(/[^a-zA-Z0-9\-_\/\.]/g,``).split(`/`).filter(e=>e!==`..`&&e!==`.`).map(e=>e.replace(/\.\.+/g,`.`)).join(`/`)}function L(e,t,n={}){let r=new Date().toISOString(),i={...n};for(let e in i)typeof i[e]==`string`&&i[e].includes(`:`)&&(i[e]=i[e].split(/[\\/]/).pop()||i[e]);console.error(`[SECURITY][${r}] TYPE: ${e} | MESSAGE: ${t} | DETAILS: ${JSON.stringify(i)}`)}const R=h(c.writeFile),ke=h(c.readFile),z=h(c.mkdir),Ae=h(c.rename);h(c.unlink);const je=process.env.BOLTDOCS_CACHE_DIR||`.boltdocs`,Me=parseInt(process.env.BOLTDOCS_CACHE_LRU_LIMIT||`2000`,10),Ne=process.env.BOLTDOCS_CACHE_COMPRESS!==`0`;var Pe=class{cache=new Map;constructor(e){this.limit=e}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.limit){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}this.cache.set(e,t)}get size(){return this.cache.size}clear(){this.cache.clear()}};const B=new class{queue=Promise.resolve();pendingCount=0;add(e){this.pendingCount++,this.queue=this.queue.then(e).finally(()=>{this.pendingCount--})}async flush(){await this.queue}get pending(){return this.pendingCount}};var Fe=class{entries=new Map;cachePath=null;compress;constructor(e={}){if(this.compress=e.compress===void 0?Ne:e.compress,e.name){let t=e.root||process.cwd(),n=this.compress?`json.gz`:`json`;this.cachePath=f.resolve(t,je,`${e.name}.${n}`)}}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&!(!this.cachePath||!c.existsSync(this.cachePath)))try{let e=c.readFileSync(this.cachePath);this.cachePath.endsWith(`.gz`)&&(e=m.gunzipSync(e));let t=JSON.parse(e.toString(`utf-8`));this.entries=new Map(Object.entries(t))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`||!this.cachePath)return;let e=Object.fromEntries(this.entries),t=JSON.stringify(e),n=this.cachePath,r=this.compress;B.add(async()=>{try{await z(f.dirname(n),{recursive:!0});let e=Buffer.from(t);r&&(e=m.gzipSync(e));let i=`${n}.${p.randomBytes(4).toString(`hex`)}.tmp`;await R(i,e),await Ae(i,n)}catch{}})}get(e){let t=this.entries.get(e);return!t||N(e)!==t.mtime?null:t.data}set(e,t){this.entries.set(e,{data:t,mtime:N(e)})}isValid(e){let t=this.entries.get(e);return t?N(e)===t.mtime:!1}invalidate(e){this.entries.delete(e)}invalidateAll(){this.entries.clear()}pruneStale(e){for(let t of this.entries.keys())e.has(t)||this.entries.delete(t)}get size(){return this.entries.size}async flush(){await B.flush()}},Ie=class{index=new Map;memoryCache=new Pe(Me);baseDir;shardsDir;indexPath;constructor(e,t=process.cwd()){this.baseDir=f.resolve(t,je,`transform-${e}`),this.shardsDir=f.resolve(this.baseDir,`shards`),this.indexPath=f.resolve(this.baseDir,`index.json`)}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&c.existsSync(this.indexPath))try{let e=c.readFileSync(this.indexPath,`utf-8`);this.index=new Map(Object.entries(JSON.parse(e)))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`)return;let e=JSON.stringify(Object.fromEntries(this.index)),t=this.indexPath;B.add(async()=>{await z(f.dirname(t),{recursive:!0}),await R(t,e)})}async getMany(e){let t=new Map,n=[];for(let r of e){let e=this.memoryCache.get(r);e?t.set(r,e):this.index.has(r)&&n.push(r)}if(n.length>0){let e=await Promise.all(n.map(async e=>{let t=this.index.get(e),n=f.resolve(this.shardsDir,`${t}.gz`);try{let t=await ke(n),r=m.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,r),{key:e,val:r}}catch{return null}}));for(let n of e)n&&t.set(n.key,n.val)}return t}get(e){let t=this.memoryCache.get(e);if(t)return t;let n=this.index.get(e);if(!n)return null;let r=f.resolve(this.shardsDir,`${n}.gz`);if(!c.existsSync(r))return null;try{let t=c.readFileSync(r),n=m.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,n),n}catch{return null}}set(e,t){let n=p.createHash(`md5`).update(t).digest(`hex`);this.index.set(e,n),this.memoryCache.set(e,t);let r=f.resolve(this.shardsDir,`${n}.gz`);B.add(async()=>{if(c.existsSync(r))return;await z(this.shardsDir,{recursive:!0});let e=m.gzipSync(Buffer.from(t)),n=`${r}.${p.randomBytes(4).toString(`hex`)}.tmp`;await R(n,e),await Ae(n,r)})}get size(){return this.index.size}async flush(){await B.flush()}};const V=new Fe({name:`routes`});function Le(){V.invalidateAll()}function Re(e){V.invalidate(e)}function ze(e,t,n,r){let i;try{i=decodeURIComponent(e)}catch{let t=f.basename(e);throw L(`ENCODING_ERROR`,`Invalid character encoding`,{file:t}),new xe(`Security breach: Invalid characters or encoding in path: ${t}`)}if(i.length>260){let e=f.basename(i);throw L(`PATH_TOO_LONG`,`Path length exceeds limit`,{length:i.length,file:e}),new be(`Security breach: Path length exceeds limit of 260 characters: ${e}`)}let a=f.resolve(i),o=f.resolve(t),s=j(f.relative(o,a));if(s.startsWith(`../`)||s===`..`||a.includes(`\0`)||!ve.test(s)){let t=f.basename(e);throw L(`PATH_TRAVERSAL_ATTEMPT`,`Path traversal or invalid characters detected`,{path:s}),new be(`Security breach: File is outside of docs directory, contains null bytes, or invalid characters: ${t}`)}let{data:c,content:l}=we(e),u=s.split(`/`),d,p;if(r?.versions&&u.length>0){let e=u[0],t=r.versions.prefix||``,n=r.versions.versions.find(n=>e===t+n.path||e===n.path);n&&(p=n.path,u=u.slice(1))}if(r?.i18n&&u.length>0){let e=u[0];r.i18n.locales[e]&&(d=e,u=u.slice(1))}let m;if(u.length>0){let e=u[0].match(/^\((.+)\)$/);e&&(m=e[1].toLowerCase(),u=u.slice(1))}let h;u=u.map(e=>{let t=M(e);return t.startsWith(`_`)&&t!==`_`?(h=t.substring(1),e.substring(0,e.length-t.length)+t.substring(1)):e});let te=u.join(`/`),g;g=c.permalink?c.permalink.startsWith(`/`)?c.permalink:`/${c.permalink}`:De(te||`index.md`);let _=n;p&&(_+=`/`+p),d&&(_+=`/`+d),m&&(_+=`/`+m),_+=g===`/`?``:g,(!_||_===``)&&(_=`/`);let v=u[u.length-1],ne=M(v),re=M(f.basename(e,f.extname(e))),ie=c.sidebarPosition??Se(v),y=u.length>=2?u[0]:void 0,b=y?M(y):void 0,x=u.length===2&&/^index\.mdx?$/.test(ne),S=new ee,C=[];for(let e of l.matchAll(/^(#{2,4})\s+(.+)$/gm)){let t=e[1].length,n=P(e[2].replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).trim()).trim(),r=S.slug(n);C.push({level:t,text:n,id:r})}let ae=c.title?P(String(c.title)):re,w=c.description?P(String(c.description)):``;!w&&l&&(w=F(l.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim().slice(0,160));let T=c.badge?P(String(c.badge)):void 0,E=c.icon?String(c.icon):void 0,oe=Be(l),D={},se=[`og:`,`twitter:`,`article:`,`music:`,`video:`,`profile:`,`book:`],ce=[`noindex`,`robots`,`canonical`,`keywords`,`author`];c.seo&&typeof c.seo==`object`&&Object.assign(D,c.seo);for(let e of Object.keys(c))(ce.includes(e)||se.some(t=>e.startsWith(t)))&&(D[e]=c[e]);return c.hidden===!0&&D.noindex===void 0&&(D.noindex=!0),{route:{path:_,componentPath:e,filePath:s,title:ae,description:w,sidebarPosition:ie,headings:C,locale:d,version:p,badge:T,icon:E,tab:m,subRouteGroup:h,_content:oe,_rawContent:l,seo:Object.keys(D).length>0?D:void 0},relativeDir:b,isGroupIndex:x,inferredTab:m,groupMeta:x?{title:c.groupTitle||c.title||(b?I(b):``),position:c.groupPosition??c.sidebarPosition??(y?Se(y):void 0),icon:E}:void 0,inferredGroupPosition:y?Se(y):void 0}}function Be(e){return F(e.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/\{[^\}]+\}/g,``).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim()}function Ve(e){return e.sort((e,t)=>!e.group&&!t.group?He(e,t):e.group?t.group?e.group===t.group?He(e,t):Ue(e,t):1:-1)}function He(e,t){return e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0?e.sidebarPosition-t.sidebarPosition:e.sidebarPosition===void 0?t.sidebarPosition===void 0?e.title.localeCompare(t.title):1:-1}function Ue(e,t){return e.groupPosition!==void 0&&t.groupPosition!==void 0?e.groupPosition-t.groupPosition:e.groupPosition===void 0?t.groupPosition===void 0?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):1:-1}let H=null;const U=new Map;async function W(e,t,n=`/docs`,r=!0){V.load(),U.clear(),(process.env.BOLTDOCS_FORCE_REPARSE===`true`||t?.i18n)&&V.invalidateAll();let i;!r&&H?i=H:(i=await s([`**/*.md`,`**/*.mdx`],{cwd:e,absolute:!0,suppressErrors:!0,followSymbolicLinks:!1}),H=i),V.pruneStale(new Set(i));let a=[],o=0;for(let r=0;r<i.length;r+=50){let s=i.slice(r,r+50),c=await Promise.all(s.map(async r=>{let i=V.get(r);if(i)return o++,i;let a=ze(r,e,n,t);return V.set(r,a),a}));a.push(...c),r+50<i.length&&await new Promise(e=>setImmediate(e))}V.save();let c=new Map,l=[];for(let e of a)if(e.isGroupIndex&&e.relativeDir&&l.push(e),e.relativeDir){let t=c.get(e.relativeDir);t?t.position===void 0&&e.inferredGroupPosition!==void 0&&(t.position=e.inferredGroupPosition):(t={title:I(e.relativeDir),position:e.inferredGroupPosition},c.set(e.relativeDir,t))}for(let e of l){let t=c.get(e.relativeDir);e.groupMeta&&(t.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(t.position=e.groupMeta.position),e.groupMeta.icon&&(t.icon=e.groupMeta.icon))}if(t?.theme?.sidebarGroups)for(let[e,n]of Object.entries(t.theme.sidebarGroups)){let t=c.get(e);t?(n.title&&(t.title=n.title),n.icon&&(t.icon=n.icon)):c.set(e,{title:n.title||I(e),icon:n.icon})}let u=Array(a.length);for(let e=0;e<a.length;e++){let t=a[e],n=t.relativeDir,r=n?c.get(n):void 0;u[e]={...t.route,group:n,groupTitle:r?.title||(n?I(n):void 0),groupPosition:r?.position,groupIcon:r?.icon}}let d=u;if(t?.i18n){let e=We(u,t,n);d=[...u,...e]}return Ve(d)}function We(e,t,n){let r=t.i18n.defaultLocale,i=Object.keys(t.i18n.locales),a=[],o=new Map,s=[];for(let t of e){let e=t.locale||r;o.has(e)||o.set(e,new Set),o.get(e).add(t.path),e===r&&s.push(t)}for(let e of i){let i=o.get(e)||new Set;for(let o of s){let s=Ge(o.path,r,e,n,t);s!==o.path&&(i.has(s)||a.push({...o,path:s,locale:e}))}}return a}function Ge(e,t,n,r,i){let a=`${e}:${n}`,o=U.get(a);if(o)return o;let s=r;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let i=t+n.path;if(e.startsWith(`${r}/${i}`)){s+=`/`+i;break}if(e.startsWith(`${r}/${n.path}`)){s+=`/`+n.path;break}}}let c=e.substring(s.length),l=`/${t}`;if(c.startsWith(l+`/`))c=`/`+n+`/`+c.substring(l.length+1);else if(c===l)c=`/`+n;else if(c===`/`||c===``)c=`/`+n;else{let e=c.startsWith(`/`)?``:`/`;c=`/`+n+e+c}let u=s+c;return U.size>2e3&&U.clear(),U.set(a,u),u}function Ke(e){return e.map(e=>({path:e.path,filePath:e.filePath,title:e.title,description:e.description||``,sidebarPosition:e.sidebarPosition,badge:e.badge,icon:e.icon,headings:e.headings||[],_content:e._content||``,locale:e.locale,version:e.version,tab:e.tab,group:e.group,groupTitle:e.groupTitle,groupPosition:e.groupPosition,groupIcon:e.groupIcon,subRouteGroup:e.subRouteGroup,seo:e.seo}))}const qe=d.object({icon:d.string().max(50),link:d.string().url()}),Je=d.object({text:d.string().max(2e3).optional()}),Ye=d.enum([`fs:read`,`fs:write`,`vite:config`,`mdx:remark`,`mdx:rehype`,`components`,`hooks:build`,`hooks:dev`]),Xe=d.object({name:d.string(),enforce:d.enum([`pre`,`post`]).optional(),version:d.string().optional(),boltdocsVersion:d.string().optional(),permissions:d.array(Ye).optional(),remarkPlugins:d.array(d.any()).optional(),rehypePlugins:d.array(d.any()).optional(),vitePlugins:d.array(d.any()).optional(),components:d.record(d.string(),d.string()).optional(),hooks:d.record(d.string(),d.any()).optional()}),Ze=d.object({title:d.union([d.string(),d.record(d.string(),d.string())]).optional(),description:d.union([d.string(),d.record(d.string(),d.string())]).optional(),logo:d.union([d.string(),d.object({dark:d.string(),light:d.string(),alt:d.string().optional(),width:d.number().optional(),height:d.number().optional()})]).optional(),navbar:d.array(d.object({label:d.union([d.string(),d.record(d.string(),d.string())]),href:d.string()})).optional(),sidebar:d.record(d.string(),d.array(d.object({text:d.string(),link:d.string()}))).optional(),sidebarGroups:d.record(d.string(),d.object({title:d.string().optional(),icon:d.string().optional()})).optional(),socialLinks:d.array(qe).optional(),footer:Je.optional(),breadcrumbs:d.boolean().optional(),editLink:d.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:d.string().url().optional(),version:d.string().max(50).optional(),githubRepo:d.string().max(100).optional(),favicon:d.string().optional(),poweredBy:d.boolean().optional(),tabs:d.array(d.object({id:d.string(),text:d.union([d.string(),d.record(d.string(),d.string())]),icon:d.string().optional()})).optional(),codeTheme:d.union([d.string(),d.object({light:d.string(),dark:d.string()})]).optional(),copyMarkdown:d.union([d.boolean(),d.object({text:d.string().optional(),icon:d.string().optional()})]).optional()}),Qe=d.union([d.string(),d.object({rules:d.array(d.object({userAgent:d.string(),allow:d.union([d.string(),d.array(d.string())]).optional(),disallow:d.union([d.string(),d.array(d.string())]).optional()})).optional(),sitemaps:d.array(d.string().url()).optional()})]),$e=d.object({defaultLocale:d.string(),locales:d.record(d.string(),d.string()),localeConfigs:d.record(d.string(),d.object({label:d.string().optional(),direction:d.enum([`ltr`,`rtl`]).optional(),htmlLang:d.string().optional(),calendar:d.string().optional()})).optional()}),et=d.object({defaultVersion:d.string(),prefix:d.string().optional(),versions:d.array(d.object({label:d.string(),path:d.string()}))}),tt=d.object({headers:d.record(d.string(),d.string()).optional(),enableCSP:d.boolean().optional(),customHeaders:d.record(d.string(),d.string()).optional()}),nt=d.object({metatags:d.record(d.string(),d.string()).optional(),indexing:d.enum([`all`,`public`]).optional(),thumbnails:d.object({background:d.string().optional()}).optional()}),rt=d.object({siteUrl:d.string().url().optional(),docsDir:d.string().optional(),homePage:d.string().optional(),theme:Ze.optional(),i18n:$e.optional(),versions:et.optional(),plugins:d.array(Xe).optional(),robots:Qe.optional(),security:tt.optional(),seo:nt.optional(),vite:d.record(d.string(),d.unknown()).optional()});function it(e){return e}const G=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function K(e,t=process.cwd()){let r=t,a={docsDir:n.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`},poweredBy:!0,breadcrumbs:!0}},o={};for(let e of G){let t=n.resolve(r,e);if(g.existsSync(t))try{let e=await i({command:`serve`,mode:`development`},t,r);if(e){o=e.config;break}}catch(t){console.warn(`[boltdocs] Failed to load config from ${e}:`,t)}}let s={title:o.title,description:o.description,logo:o.logo,favicon:o.favicon,navbar:o.navbar,sidebar:o.sidebar,sidebarGroups:o.theme?.sidebarGroups,socialLinks:o.socialLinks,footer:o.footer,githubRepo:o.githubRepo,tabs:o.tabs,codeTheme:o.codeTheme,copyMarkdown:o.copyMarkdown,breadcrumbs:o.breadcrumbs,poweredBy:o.poweredBy,communityHelp:o.communityHelp,version:o.version,editLink:o.editLink,...o.theme||{}},c=Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));c.navbar&&=c.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``}));let l={docsDir:n.resolve(e),homePage:o.homePage,theme:{...a.theme,...c},i18n:o.i18n,versions:o.versions,siteUrl:o.siteUrl,plugins:o.plugins||[],robots:o.robots,security:o.security,vite:o.vite},u=rt.safeParse(l);if(!u.success)throw new A(`Invalid Boltdocs configuration:\n${u.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
|
|
7
|
-
`)}`);return u.data}function at(e,t){let n=(t.siteUrl||``).replace(/\/$/,``);if(!n)return``;let r=t.seo?.indexing!==`all`&&t.seo?.indexing!==`public`;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
8
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
9
|
-
${e.filter(e=>e.seo?.noindex||typeof e.seo?.robots==`string`&&e.seo.robots.includes(`noindex`)?!1:(r&&e.seo?.index,!0)).map(e=>` <url>
|
|
10
|
-
<loc>${Ee(`${n}${e.path.startsWith(`/`)?e.path:`/${e.path}`}`)}</loc>
|
|
11
|
-
<changefreq>weekly</changefreq>
|
|
12
|
-
<priority>0.7</priority>
|
|
13
|
-
</url>`).join(`
|
|
14
|
-
`)}
|
|
15
|
-
</urlset>`}function ot(e){let t=e.siteUrl||``,n=t?`${t.replace(/\/$/,``)}/sitemap.xml`:``;if(e.seo?.indexing!==`all`&&e.seo?.indexing!==`public`&&e.seo?.indexing)return[`User-agent: *`,`Disallow: /`].filter(Boolean).join(`
|
|
16
|
-
`);if(typeof e.robots==`string`)return e.robots;if(e.robots&&typeof e.robots==`object`){let t=e.robots.rules||[],r=e.robots.sitemaps||[],i=t.map(e=>{let t=`User-agent: ${e.userAgent}\n`;return e.allow&&(Array.isArray(e.allow)?t+=e.allow.map(e=>`Allow: ${e}`).join(`
|
|
17
|
-
`)+`
|
|
18
|
-
`:t+=`Allow: ${e.allow}\n`),e.disallow&&(Array.isArray(e.disallow)?t+=e.disallow.map(e=>`Disallow: ${e}`).join(`
|
|
19
|
-
`)+`
|
|
20
|
-
`:t+=`Disallow: ${e.disallow}\n`),t.trim()}).join(`
|
|
21
|
-
|
|
22
|
-
`),a=[...n?[n]:[],...r].map(e=>`Sitemap: ${e}`).join(`
|
|
23
|
-
`);return`${i}${a?`\n\n${a}`:``}`}return[`User-agent: *`,`Allow: /`,``,n?`Sitemap: ${n}`:``].filter(Boolean).join(`
|
|
24
|
-
`)}function q(e,t){let n=e.homePage?`import HomePage from '${j(e.homePage)}';`:``,r=f.resolve(process.cwd(),`index.css`),i=c.existsSync(r)?`import './index.css';`:``,a=e.homePage?`homePage: HomePage,`:``,o=t?.plugins?.flatMap(e=>Object.entries(e.components||{}))||[],s=o.map(([e,t])=>`import * as _comp_${e} from '${j(t)}';
|
|
25
|
-
const ${e} = _comp_${e}.default || _comp_${e}['${e}'] || _comp_${e};`).join(`
|
|
26
|
-
`),l=o.map(([e])=>e).join(`, `),u=f.basename(e.docsDir||`docs`),d=f.resolve(process.cwd(),e.docsDir||`docs`),p=[`tsx`,`ts`,`jsx`,`js`].map(e=>f.resolve(d,`pages-external/index.${e}`)).find(e=>c.existsSync(e)),m=p?`import * as _external_module from '${j(p)}';`:``;return a=p?`homePage: _external_module.homePage || HomePage,`:e.homePage?`homePage: HomePage,`:``,`
|
|
27
|
-
import { ViteReactSSG } from '@bdocs/ssg';
|
|
28
|
-
import { createRoutes } from 'boltdocs/client';
|
|
29
|
-
import _routes from 'virtual:boltdocs-routes.ts';
|
|
30
|
-
import _config from 'virtual:boltdocs-config.ts';
|
|
31
|
-
import _user_mdx_components from 'virtual:boltdocs-mdx-components.tsx';
|
|
32
|
-
import _Layout from 'virtual:boltdocs-layout.tsx';
|
|
33
|
-
${i}
|
|
34
|
-
${n}
|
|
35
|
-
${s}
|
|
36
|
-
${m}
|
|
37
|
-
|
|
38
|
-
const mdxModules = import.meta.glob('/${u}/**/*.{md,mdx}', { eager: true });
|
|
39
|
-
|
|
40
|
-
export const createRoot = ViteReactSSG(
|
|
41
|
-
{
|
|
42
|
-
routes: createRoutes({
|
|
43
|
-
routesData: _routes,
|
|
44
|
-
config: _config,
|
|
45
|
-
mdxModules,
|
|
46
|
-
Layout: _Layout,
|
|
47
|
-
${a}
|
|
48
|
-
${p?`externalPages: _external_module.pages, externalLayout: _external_module.layout,`:``}
|
|
49
|
-
components: { ${l}${l?`, `:``} ...(_user_mdx_components || {}) },
|
|
50
|
-
}),
|
|
51
|
-
},
|
|
52
|
-
({ isClient }) => {
|
|
53
|
-
// Boltdocs initialization hook
|
|
54
|
-
if (isClient) {
|
|
55
|
-
// Client-side initialization
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
`}function st(e){return`<!doctype html>
|
|
60
|
-
<html lang="en">
|
|
61
|
-
<head>
|
|
62
|
-
<meta charset="UTF-8" />
|
|
63
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
64
|
-
<title>${e.theme?.title||`Boltdocs`}</title>
|
|
65
|
-
</head>
|
|
66
|
-
<body>
|
|
67
|
-
<div id="root"></div>
|
|
68
|
-
</body>
|
|
69
|
-
</html>`}function ct(e,t){(!e||!e.includes(`<body`)||!e.includes(`<head`))&&(e=st(t));let n=t.theme,r=n?.title||`Boltdocs`,i=n?.description||``,a=n?.favicon;!a&&n?.logo&&(a=typeof n.logo==`string`?n.logo:n.logo.light||n.logo.dark);let o=[a?`<link rel="icon" href="${a}">`:``,`<meta name="description" content="${i}">`,`<meta property="og:title" content="${r}">`,`<meta property="og:description" content="${i}">`,`<meta property="og:type" content="website">`,`<meta name="twitter:card" content="summary_large_image">`,`<meta name="twitter:title" content="${r}">`,`<meta name="twitter:description" content="${i}">`,`<meta name="generator" content="Boltdocs">`].filter(Boolean).join(`
|
|
70
|
-
`);return e=e.includes(`<title>`)?e.replace(/<title>.*?<\/title>/,`<title>${r}</title>`):e.replace(`</head>`,` <title>${r}</title>\n </head>`),e=e.replace(`</head>`,` ${o}\n
|
|
71
|
-
<script>
|
|
72
|
-
(function() {
|
|
73
|
-
try {
|
|
74
|
-
var stored = localStorage.getItem("boltdocs-theme");
|
|
75
|
-
var isDark =
|
|
76
|
-
stored === "dark" ||
|
|
77
|
-
(stored !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
78
|
-
document.documentElement.classList.toggle("dark", isDark);
|
|
79
|
-
document.documentElement.dataset.theme = isDark ? "dark" : "light";
|
|
80
|
-
} catch (e) {}
|
|
81
|
-
})();
|
|
82
|
-
<\/script>
|
|
83
|
-
</head>`),!e.includes(`src/main`)&&!e.includes(`virtual:boltdocs-entry`)&&(e=e.replace(`</body>`,` <script type="module">import "virtual:boltdocs-entry";<\/script>
|
|
84
|
-
</body>`)),e}function lt(e){let t=[];for(let n of e)if(t.push({id:n.path,title:n.title,content:n._content||``,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version});return t}const ut={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains`};function dt(e){let t=process.env.NODE_ENV===`development`,n={"default-src":[`'self'`],"script-src":[`'self'`,`'unsafe-inline'`],"style-src":[`'self'`,`'unsafe-inline'`],"img-src":[`'self'`,`data:`,`https:`],"font-src":[`'self'`],"connect-src":[`'self'`]};return t&&(n[`script-src`]=[`'self'`,`'unsafe-eval'`,`'unsafe-inline'`],n[`style-src`]=[`'self'`,`'unsafe-inline'`]),Object.entries(n).map(([e,t])=>`${e} ${t.join(` `)}`).join(`; `)}var J=class e extends Error{pluginName;constructor(t,n){super(`[plugin:${t}] ${n}`),this.name=`PluginError`,this.pluginName=t,Object.setPrototypeOf(this,e.prototype)}},Y=class e extends J{constructor(t,n){super(t,`Validation failed: ${n}`),this.name=`PluginValidationError`,Object.setPrototypeOf(this,e.prototype)}},ft=class e extends J{constructor(t,n){super(t,`Compatibility error: ${n}`),this.name=`PluginCompatibilityError`,Object.setPrototypeOf(this,e.prototype)}},X=class e extends J{constructor(t,n){super(t,`Missing required permission: '${n}'`),this.name=`PluginPermissionError`,Object.setPrototypeOf(this,e.prototype)}},pt=class e extends J{hookName;constructor(t,n,r){super(t,`Error in hook '${n}': ${r.message}`),this.name=`PluginHookError`,this.hookName=n,this.stack=r.stack,Object.setPrototypeOf(this,e.prototype)}},mt=class{data=new Map;getNamespaceKey(e,t){return`${e}:${t}`}get(e,t){let n=this.getNamespaceKey(e,t),r=this.data.get(n);if(r!==void 0)return typeof r==`object`&&r?JSON.parse(JSON.stringify(r)):r}set(e,t,n){let r=this.getNamespaceKey(e,t),i=typeof n==`object`&&n?JSON.parse(JSON.stringify(n)):n;this.data.set(r,i)}has(e,t){let n=this.getNamespaceKey(e,t);return this.data.has(n)}};const ht=Xe.extend({version:d.string().optional(),boltdocsVersion:d.string().optional(),permissions:d.array(d.string()).optional(),hooks:d.object({beforeBuild:d.function().optional(),afterBuild:d.function().optional(),beforeDev:d.function().optional(),afterDev:d.function().optional(),configResolved:d.function().optional(),buildEnd:d.function().optional()}).optional()});function gt(e,t){let n=[],r=new Set;for(let i of e){let e=ht.safeParse(i);if(!e.success)throw new Y(i.name||`unknown`,e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `));let a=e.data;if(r.has(a.name))throw new Y(a.name,`Duplicate plugin name detected`);if(r.add(a.name),a.boltdocsVersion&&!_.satisfies(t,a.boltdocsVersion))throw new ft(a.name,`Plugin expects Boltdocs version ${a.boltdocsVersion}, but current is ${t}`);if(a.components){for(let[e,t]of Object.entries(a.components))if((t.includes(`..`)||f.isAbsolute(t))&&t.includes(`..`))throw new Y(a.name,`Component '${e}' has an invalid path: traversal sequences are not allowed.`)}n.push(a)}return n}function Z(e,t){return e.permissions?e.permissions.includes(t):!1}var Q=class{static checkPermission(e,t){if(!Z(e,t))throw new X(e.name,t)}static getSanitizedCapabilities(e){return{remarkPlugins:Z(e,`mdx:remark`)?e.remarkPlugins:[],rehypePlugins:Z(e,`mdx:rehype`)?e.rehypePlugins:[],vitePlugins:Z(e,`vite:config`)?e.vitePlugins:[],components:Z(e,`components`)?e.components:{}}}static async executeWithIsolation(e,t,n,r){try{return this.checkPermission(e,t),await r()}catch(t){if(t instanceof X){console.warn(`[boltdocs] Skipping hook '${n}' for plugin '${e.name}': ${t.message}`);return}throw t}}},_t=class{plugins;config;store;constructor(e,t){this.plugins=e,this.config=t,this.store=new mt}async runHook(e,...t){let n=this.getSortedPlugins();for(let r of n){if(!r.hooks?.[e])continue;let n=this.createContext(r),i=e.toLowerCase().includes(`build`),a=e.toLowerCase().includes(`dev`),o=i?`hooks:build`:a?`hooks:dev`:void 0;try{o?await Q.executeWithIsolation(r,o,e,()=>r.hooks[e](n,...t)):await r.hooks[e](n,...t)}catch(t){let i=new pt(r.name,e,t instanceof Error?t:Error(String(t)));n.logger.error(i)}}}getSortedPlugins(){let e=this.plugins.filter(e=>e.enforce===`pre`),t=this.plugins.filter(e=>!e.enforce),n=this.plugins.filter(e=>e.enforce===`post`);return[...e,...t,...n]}createContext(e){return{config:Object.freeze({...this.config}),meta:{name:e.name,version:e.version,boltdocsVersion:e.boltdocsVersion},store:{get:(e,t)=>this.store.get(e,t),set:(e,t,n)=>this.store.set(e,t,n),has:(e,t)=>this.store.has(e,t)},logger:this.createLogger(e.name)}}createLogger(e){let t=`[plugin:${e}]`;return{info:e=>console.log(`${t} INFO: ${e}`),warn:e=>console.warn(`${t} WARN: ${e}`),error:e=>{let n=e instanceof Error?e.message:e;console.error(`${t} ERROR: ${n}`)},debug:e=>console.debug(`${t} DEBUG: ${e}`)}}};function vt(e){return e}function yt(e={},t){let r=n.resolve(process.cwd(),e.docsDir||`docs`),i=j(r),o=t,s,c=!1,l,u=[];return[{name:`vite-plugin-boltdocs`,enforce:`pre`,async config(t,i){c=i.command===`build`;let s=t.envDir||process.cwd(),d=a(i.mode,s,``);Object.assign(process.env,d),o||=await K(r);let f=(await import(`./package-CR0HF9x3.mjs`)).version,p=gt(o.plugins||[],f);return o.plugins=p,l=new _t(p,o),u=p.flatMap(e=>Q.getSanitizedCapabilities(e).vitePlugins||[]),c&&await l.runHook(`beforeBuild`),{ssgOptions:{entry:`boltdocs/entry`,htmlEntry:`index.html`,dirStyle:`nested`,includeAllRoutes:!0,mock:!0,script:`async`,beastiesOptions:{preload:`media`},onFinished:async e=>{let t=at(Ke(await W(r,o)),o);t&&g.writeFileSync(n.join(e,`sitemap.xml`),t);let i=ot(o);g.writeFileSync(n.join(e,`robots.txt`),i)}},build:{ssrManifest:c},async config(){let t=O;for(;t!==n.parse(t).root&&!g.existsSync(n.join(t,`package.json`));)t=n.dirname(t);if(g.existsSync(n.join(t,`package.json`))&&JSON.parse(g.readFileSync(n.join(t,`package.json`),`utf-8`)).name!==`boltdocs`){let e=n.dirname(t);for(;e!==n.parse(e).root;){if(g.existsSync(n.join(e,`package.json`))&&JSON.parse(g.readFileSync(n.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=n.dirname(e)}}return{optimizeDeps:{include:[`react`,`react-dom`,`react-router-dom`],exclude:[`boltdocs`,`boltdocs/client`]},resolve:{alias:[{find:`boltdocs/entry`,replacement:j(n.resolve(e.root||process.cwd(),`boltdocs-entry.cjs`))}]}}}}},configResolved(e){s=e,l?.runHook(`configResolved`,o)},async configureServer(e){await l?.runHook(`beforeDev`),e.middlewares.use((e,t,n)=>{process.env.NODE_ENV===`production`&&Object.entries(ut).forEach(([e,n])=>{t.setHeader(e,n)}),o.security?.enableCSP&&t.setHeader(`Content-Security-Policy`,dt(o)),n()}),e.middlewares.use((e,t,n)=>{if(e.url===`/robots.txt`){n();return}n()}),e.middlewares.use(async(t,n,r)=>{let i=t.url?.split(`?`)[0]||`/`,a=t.headers.accept||``,s=i===`/`||i.startsWith(`/docs`)||o.i18n&&Object.keys(o.i18n.locales).some(e=>i.startsWith(`/${e}/docs`)||i===`/${e}`)||!0,c=/\.(js|css|png|jpe?g|gif|svg|ico|webp|woff2?|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac|pdf|zip|gz|map|json)$/i.test(i);if(a.includes(`text/html`)&&!c&&s){let r=st(o);r=ct(r,o),r=await e.transformIndexHtml(t.url||`/`,r),n.statusCode=200,n.setHeader(`Content-Type`,`text/html`),n.end(r);return}r()});let t=G.map(e=>n.resolve(process.cwd(),e)),a=[`tsx`,`jsx`].map(e=>n.resolve(r,`layout.${e}`)),s=[`tsx`,`ts`,`jsx`,`js`],c=s.map(e=>n.resolve(r,`mdx-components.${e}`)),u=s.map(e=>n.resolve(r,`pages-external/index.${e}`)),d=s.map(e=>n.resolve(r,`icons.${e}`));e.watcher.add([...t,...c,...a,...u,...d]);let f=async(t,n)=>{try{let a=j(t);if(G.some(e=>a.endsWith(e))){e.restart();return}if(s.some(e=>a.endsWith(`mdx-components.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-mdx-components.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.some(e=>a.endsWith(`icons.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-icons.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(a.endsWith(`layout.tsx`)||a.endsWith(`layout.jsx`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-layout.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(a.includes(`/pages-external/`)||a.includes(`\\pages-external\\`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-entry`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(!a.startsWith(i)||!Ce(a))return;if(n===`add`||n===`unlink`){Le(),o=await K(r);let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`custom`,event:`boltdocs:config-update`,data:{theme:o?.theme,i18n:o?.i18n,versions:o?.versions,siteUrl:o?.siteUrl}})}else Re(t);let c=e.moduleGraph.getModuleById(`\0virtual:boltdocs-routes.ts`);c&&e.moduleGraph.invalidateModule(c);let l=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);l&&e.moduleGraph.invalidateModule(l),e.ws.send({type:`full-reload`})}catch(e){console.error(`[boltdocs] HMR error during ${n} event:`,e)}};e.watcher.on(`add`,e=>f(e,`add`)),e.watcher.on(`unlink`,e=>f(e,`unlink`)),e.watcher.on(`change`,e=>f(e,`change`)),await l?.runHook(`afterDev`)},resolveId(e){let t=s?.root||process.cwd();return e.includes(`boltdocs-entry.mjs`)||e===`virtual:boltdocs-entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`?j(n.resolve(t,`boltdocs-entry.mjs`)):e.includes(`boltdocs-client.mjs`)||e===`virtual:boltdocs-client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.ts`?j(n.resolve(t,`boltdocs-client.mjs`)):e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(t){if(t.includes(`boltdocs-entry.mjs`)||t===`\0virtual:boltdocs-entry`)return q(e,o);if(t.includes(`boltdocs-client.mjs`)||t===`\0virtual:boltdocs-client.ts`||t===`virtual:boltdocs-client`){let e=O,t=e;for(;e!==n.parse(e).root;){if(g.existsSync(n.join(e,`package.json`))&&JSON.parse(g.readFileSync(n.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=n.dirname(e)}let r=n.join(t,`src/client/index.ts`),i=n.join(t,`dist/client/index.js`);return`export * from '${j(g.existsSync(r)?r:i)}';`}if(!t.startsWith(`\0virtual:boltdocs-`))return;let i=t.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(i===`routes`){let e=Ke(await W(r,o));return`export default ${JSON.stringify(e,null,2)};`}if(i===`config`){let e={theme:o?.theme,i18n:o?.i18n,versions:o?.versions,siteUrl:o?.siteUrl,plugins:o?.plugins?.map(e=>({name:e.name}))};return`export default ${JSON.stringify(e,null,2)};`}if(i===`entry`)return q(e,o);if(i===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let i of e){let e=n.resolve(r,`mdx-components.${i}`);if(g.existsSync(e)){t=e;break}}if(t){let e=j(t);return`import * as components from '${e}';
|
|
85
|
-
const mdxComponents = components.default || components;
|
|
86
|
-
export default mdxComponents;
|
|
87
|
-
export * from '${e}';`}return`export default {};`}if(i===`layout`){let e=[`tsx`,`jsx`],t=null;for(let i of e){let e=n.resolve(r,`layout.${i}`);if(g.existsSync(e)){t=e;break}}return t?`import UserLayout from '${j(t)}';
|
|
88
|
-
export default UserLayout;`:`import { DefaultLayout } from '${j(n.resolve(O,`../../client/components/default-layout.tsx`))}';
|
|
89
|
-
export default DefaultLayout;`}if(i===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let i of e){let e=n.resolve(r,`icons.${i}`);if(g.existsSync(e)){t=e;break}}return t?`import * as icons from '${j(t)}';\nexport default icons;`:`export default {};`}if(i===`search`){let e=lt(await W(r,o));return`export default ${JSON.stringify(e,null,2)};`}if(i===`client`){let e=O,t=``;for(;e&&e!==n.parse(e).root;){let r=n.join(e,`src/client/index.ts`),i=n.join(e,`dist/client/index.mjs`),a=n.join(e,`client/index.ts`);if(g.existsSync(r)){t=j(r);break}if(g.existsSync(i)){t=j(i);break}if(g.existsSync(a)){t=j(a);break}e=n.dirname(e)}if(!t)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${O}`);return`export * from '${t}';`}},transformIndexHtml:{order:`pre`,handler(e){return ct(e,o)}},async closeBundle(){!c||s?.build?.ssr||(await l?.runHook(`afterBuild`),await l?.runHook(`buildEnd`))}},te({includePublic:!0,png:{quality:80},jpeg:{quality:80},jpg:{quality:80},webp:{quality:80},avif:{quality:80},svg:{multipass:!0,plugins:[{name:`preset-default`}]}}),{name:`vite-plugin-boltdocs-extra-plugins`,async configResolved(){}},...u]}const $=new Ie(`mdx`),bt=[S.default||S,C.default||C,ae.default||ae,w.default||w,T.default||T,E.default||E,oe.default||oe],xt=[D,se,ce,le,ue,de,fe,pe,me,he,ge,_e];let St=null,Ct=null;const wt=()=>(St??=b(),St),Tt=async e=>Ct||(Ct=x({themes:bt,langs:xt,engine:wt()}),Ct),Et=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:line-numbers`,pre(e){let n=this.options.meta?.__raw||``,r=/lineNumbers|showLineNumbers/.test(n);(t||r)&&this.addClassToHast(e,`shiki-line-numbers`)}}},Dt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:word-wrap`,pre(e){let n=this.options.meta?.__raw||``,r=/wordWrap|word-wrap/.test(n);(t||r)&&this.addClassToHast(e,`shiki-word-wrap`)}}},Ot=()=>({name:`AddTitleProperty`,pre(e){let t=this.options.meta?.__raw;if(!t)return;let n=t.match(/title=(["'])(.*?)\1/)?.[2];e.properties[`data-title`]=n}}),kt=()=>({name:`AddLanguageProperty`,pre(e){e.properties[`data-lang`]=this.options.lang||`plaintext`}});var At=class{config;constructor(e){this.config=e}getTheme(){return this.config?.theme?.codeTheme||{light:`github-light`,dark:`github-dark`}}async getHighlighter(){return await Tt(this.getTheme())}getOptions(e,t){let n=this.getTheme(),r={lang:e,meta:{__raw:t},transformers:[Et(),Dt(),Ot(),kt()]};return typeof n==`object`?r.themes={light:n.light,dark:n.dark}:r.theme=n,r}async render(e,t,n){let r=await this.getHighlighter(),i=this.getOptions(t,n);return r.codeToHtml(e,i)}};function jt(e){let t=new At(e);return async e=>{let n=await t.getHighlighter();y(e,[`mdxJsxFlowElement`,`mdxJsxTextElement`],e=>{if(e.name!==`ComponentPreview`)return;let r=e.attributes?.find(e=>e.name===`code`),i=``;if(r){if(typeof r.value==`string`)i=r.value;else if(r.value?.type===`mdxJsxAttributeValueExpression`){let e=r.value.value??``;i=e.match(/^[`'"]([\s\S]+)[`'"]$/)?.[1]??e}}if(!i)return;let a=e.attributes?.find(e=>e.name===`lineNumbers`||e.name===`showLineNumbers`),o=e.attributes?.find(e=>e.name===`wordWrap`||e.name===`word-wrap`),s=e.attributes?.find(e=>e.name===`title`),c=``;a&&(c+=` lineNumbers`),o&&(c+=` wordWrap`),s&&typeof s.value==`string`&&(c+=` title="${s.value}"`);let l=t.getOptions(`tsx`,c),u=n.codeToHtml(i,l);e.attributes=(e.attributes??[]).filter(e=>e.name!==`highlightedHtml`),e.attributes.push({type:`mdxJsxAttribute`,name:`highlightedHtml`,value:u})})}}function Mt(e){let t=new At(e);return async e=>{let n=await t.getHighlighter();y(e,`element`,e=>{if(e.tagName===`pre`&&e.children?.[0]?.tagName===`code`){let r=e.children[0],i=(r.properties?.className||[]).find(e=>e.startsWith(`language-`)),a=i?i.slice(9):`text`,o=r.children[0]?.value||``,s=r.properties?.metastring||r.data?.meta||``,c=t.getOptions(a,s),l=n.codeToHtml(o,c);e.properties[`data-highlighted`]=`true`,e.properties[`data-highlighted-html`]=l,e.properties[`data-lang`]=a,e.children=[]}})}}function Nt(){return e=>{y(e,`code`,e=>{e.meta&&(e.data=e.data||{},e.data.hProperties=e.data.hProperties||{},e.data.hProperties.metastring=e.meta)})}}let Pt=!1;function Ft(e,t=v){let n=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).remarkPlugins||[])||[],r=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).rehypePlugins||[])||[],i=t({remarkPlugins:[ne,re,Nt,[jt,e],...n],rehypePlugins:[ie,[Mt,e],...r],jsxRuntime:`automatic`});return{...i,name:`vite-plugin-boltdocs-mdx`,async buildStart(){Pt||=($.load(),!0),i.buildStart&&await i.buildStart.call(this)},async transform(e,t,n){if(!t.endsWith(`.md`)&&!t.endsWith(`.mdx`))return i.transform?.call(this,e,t,n);let r=`${t}:${p.createHash(`md5`).update(e).digest(`hex`)}:v2`,a=$.get(r);if(a)return{code:a,map:null};let o=await i.transform.call(this,e,t,n);return o&&typeof o==`object`&&o.code&&$.set(r,o.code),o},async buildEnd(){$.save(),await $.flush(),i.buildEnd&&await i.buildEnd.call(this)}}}async function It(e){let t=await K(e?.docsDir||`docs`);return[...yt({...e,homePage:e?.homePage||t.homePage},t),Ft(t)]}async function Lt(r,i=`development`){let a=await K(`docs`,r),s=i===`production`,c=s?{...ut}:{};return a.security?.enableCSP&&(c[`Content-Security-Policy`]=dt(a)),{root:r,mode:i,oxc:{jsx:{development:!s,runtime:`automatic`,importSource:`react`}},optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-helmet-async`,`react-router-dom`],rolldownOptions:{}},build:{rolldownOptions:{}},plugins:[e(),t(),await It({...a,root:r})],resolve:{alias:{"boltdocs/entry":o(n.resolve(r,`boltdocs-entry.mjs`)),"boltdocs/client":o(n.resolve(r,`boltdocs-client.mjs`))},dedupe:[`react`,`react-dom`,`react-router-dom`,`react-helmet-async`,`@bdocs/ssg`]},ssr:{noExternal:[`boltdocs`,/@bdocs\/(?!ssg).*/,`react-helmet-async`]},server:{headers:{...c,...a.vite?.server?.headers},...a.vite?.server},preview:{headers:{...c,...a.vite?.preview?.headers},...a.vite?.preview},...a.vite}}export{it as _,Q as a,gt as c,J as d,pt as f,K as g,q as h,_t as i,mt as l,Y as m,Lt as n,ht as o,X as p,vt as r,Z as s,It as t,ft as u,j as v,we as y};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { DocsLayout } from './docs-layout'
|
|
2
|
-
import { Navbar } from './ui-base/navbar'
|
|
3
|
-
import { Sidebar } from './ui-base/sidebar'
|
|
4
|
-
import { OnThisPage } from './ui-base/on-this-page'
|
|
5
|
-
import { Head } from './ui-base/head'
|
|
6
|
-
import { Breadcrumbs } from './ui-base/breadcrumbs'
|
|
7
|
-
import { PageNav } from './ui-base/page-nav'
|
|
8
|
-
import { ErrorBoundary } from './ui-base/error-boundary'
|
|
9
|
-
import { CopyMarkdown } from './ui-base/copy-markdown'
|
|
10
|
-
import { useRoutes } from '../hooks/use-routes'
|
|
11
|
-
import { useConfig } from '../app/config-context'
|
|
12
|
-
import { useMdxComponents } from '../app/mdx-components-context'
|
|
13
|
-
import { useLocation } from 'react-router-dom'
|
|
14
|
-
import { getTranslated } from '../utils/i18n'
|
|
15
|
-
|
|
16
|
-
export interface LayoutProps {
|
|
17
|
-
children: React.ReactNode
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The built-in default layout for Boltdocs.
|
|
22
|
-
* Users who create their own `layout.tsx` can import the same building blocks
|
|
23
|
-
* and rearrange, wrap, or replace any section.
|
|
24
|
-
*/
|
|
25
|
-
export function DefaultLayout({ children }: LayoutProps) {
|
|
26
|
-
const {
|
|
27
|
-
routes: filteredRoutes,
|
|
28
|
-
allRoutes,
|
|
29
|
-
currentRoute,
|
|
30
|
-
currentLocale,
|
|
31
|
-
} = useRoutes()
|
|
32
|
-
const { pathname } = useLocation()
|
|
33
|
-
const config = useConfig()
|
|
34
|
-
const mdxComponents = useMdxComponents()
|
|
35
|
-
const CopyMarkdownComp = (mdxComponents.CopyMarkdown as any) || CopyMarkdown
|
|
36
|
-
|
|
37
|
-
const isDocs = pathname.startsWith('/docs')
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<DocsLayout>
|
|
41
|
-
<Head
|
|
42
|
-
siteTitle={
|
|
43
|
-
getTranslated(config.theme?.title, currentLocale) || 'Boltdocs'
|
|
44
|
-
}
|
|
45
|
-
siteDescription={
|
|
46
|
-
getTranslated(config.theme?.description, currentLocale) || ''
|
|
47
|
-
}
|
|
48
|
-
routes={allRoutes}
|
|
49
|
-
/>
|
|
50
|
-
<Navbar />
|
|
51
|
-
|
|
52
|
-
<DocsLayout.Body>
|
|
53
|
-
{isDocs && <Sidebar routes={filteredRoutes} config={config} />}
|
|
54
|
-
|
|
55
|
-
<DocsLayout.Content>
|
|
56
|
-
<DocsLayout.ContentMdx>
|
|
57
|
-
{isDocs && (
|
|
58
|
-
<DocsLayout.ContentHeader>
|
|
59
|
-
<Breadcrumbs />
|
|
60
|
-
<CopyMarkdownComp
|
|
61
|
-
mdxRaw={currentRoute?._rawContent}
|
|
62
|
-
route={currentRoute}
|
|
63
|
-
config={config.theme?.copyMarkdown}
|
|
64
|
-
/>
|
|
65
|
-
</DocsLayout.ContentHeader>
|
|
66
|
-
)}
|
|
67
|
-
|
|
68
|
-
<ErrorBoundary>{children}</ErrorBoundary>
|
|
69
|
-
|
|
70
|
-
{isDocs && (
|
|
71
|
-
<DocsLayout.ContentFooter>
|
|
72
|
-
<PageNav />
|
|
73
|
-
</DocsLayout.ContentFooter>
|
|
74
|
-
)}
|
|
75
|
-
</DocsLayout.ContentMdx>
|
|
76
|
-
</DocsLayout.Content>
|
|
77
|
-
|
|
78
|
-
{isDocs && (
|
|
79
|
-
<OnThisPage
|
|
80
|
-
headings={currentRoute?.headings}
|
|
81
|
-
editLink={config.theme?.editLink}
|
|
82
|
-
communityHelp={config.theme?.communityHelp}
|
|
83
|
-
filePath={currentRoute?.filePath}
|
|
84
|
-
/>
|
|
85
|
-
)}
|
|
86
|
-
</DocsLayout.Body>
|
|
87
|
-
</DocsLayout>
|
|
88
|
-
)
|
|
89
|
-
}
|