@stacksjs/bunpress 0.2.33 → 0.2.35

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.
@@ -0,0 +1,37 @@
1
+ import type { BunPressConfig, SidebarItem } from './types';
2
+ /**
3
+ * The sidebar sections drawn for a path. A path-keyed sidebar picks the
4
+ * longest key the path starts with, so `/guide/` wins over `/`.
5
+ */
6
+ export declare function sidebarSectionsFor(config: BunPressConfig, currentPath: string): SidebarItem[];
7
+ /**
8
+ * The trail for `currentPath`. Pages that are not in the sidebar get an
9
+ * empty trail: there is no section to name and no order to walk.
10
+ */
11
+ export declare function resolveDocTrail(sections: SidebarItem[], currentPath: string): DocTrail;
12
+ /**
13
+ * "Section › Page". The last entry is where the reader is, so it is marked
14
+ * as the current page for assistive technology as well as drawn in the
15
+ * accent colour.
16
+ */
17
+ export declare function renderBreadcrumb(trail: DocTrail, ariaLabel?: string): string;
18
+ /** The previous and next pages, as two cards. Nothing when the page has neither. */
19
+ export declare function renderDocPager(trail: DocTrail, href: (link: string) => string, labels?: { prev: string, next: string, nav: string }): string;
20
+ /**
21
+ * Where a page sits in the sidebar: the trail of section and group titles
22
+ * above it, and the pages before and after it in reading order.
23
+ *
24
+ * Both come from the sidebar the reader is looking at, so they can never
25
+ * disagree with it: the breadcrumb names the section a page is filed under,
26
+ * and the pager walks the sidebar's links top to bottom.
27
+ */
28
+ export declare interface TrailLink {
29
+ text: string
30
+ link: string
31
+ }
32
+ export declare interface DocTrail {
33
+ ancestors: string[]
34
+ current?: string
35
+ prev?: TrailLink
36
+ next?: TrailLink
37
+ }
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{a as p,b as u,c as m,d as o,e as s,f as h,g as a,h as d,i as t,j as c,k as Oj,l as kj,m as Cj,n as Mj,o as Tj}from"../chunk-ds2b3vtw.js";import{v as S,w as V,x as W,y as X,z as Y}from"../chunk-zxfhq634.js";import{$ as _,A as x,B as v,C as g,D as f,I as Ej,J as Gj,K as Jj,L as Kj,M as Nj,N as Pj,O as Qj,P as Sj,Q as Vj,R as Wj,S as Xj,T as Yj,U as Zj,V as _j,W as $j,X as Aj,Y as Fj,Z as Ij,_ as Z,aa as $,ba as Lj}from"../chunk-dgdd6yma.js";import{ia as i,ja as l,ka as n,la as r,ma as e,na as jj,oa as qj,pa as zj,qa as Bj,ra as Dj}from"../chunk-twt99rzk.js";function D(E){return E.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function N(E,K=!1){let z=E.trim();if(!z||/[\u0000-\u0020\u007f-\u009f\\]/.test(z))return null;let G=/^([a-z][a-z\d+.-]*):/i.exec(z)?.[1]?.toLowerCase();if(/^[^/]*:/.test(z)&&(!G||!["http","https",...K?[]:["mailto"]].includes(G)))return null;return z}function F(E,K={}){let z=[],G=E.replace(/[\u0000-\u0002]/g,""),Q=(j)=>j.replace(/\u0001(\d+)\u0002/g,(q,B)=>z[Number(B)]??""),J=(j)=>D(Q(j));return Bun.markdown.render(G,{text:(j)=>`\x01${z.push(j)-1}\x02`,heading:(j,q)=>`<h${q.level} id="wiki-${D(q.id??"")}">${j}</h${q.level}>`,paragraph:(j)=>`<p>${j}</p>`,blockquote:(j)=>`<blockquote>${j}</blockquote>`,strong:(j)=>`<strong>${j}</strong>`,emphasis:(j)=>`<em>${j}</em>`,strikethrough:(j)=>`<del>${j}</del>`,hr:()=>"<hr>",codespan:(j)=>`<code>${J(j)}</code>`,code:(j,q)=>{return`<pre><code${q?.language&&/^[\w+#.-]{1,30}$/.test(q.language)?` class="language-${D(q.language)}"`:""}>${J(j)}</code></pre>`},list:(j,q)=>q.ordered?`<ol start="${q.start??1}">${j}</ol>`:`<ul>${j}</ul>`,listItem:(j,q)=>`<li>${typeof q.checked==="boolean"?`<input type="checkbox" disabled${q.checked?" checked":""}>`:""}${j}</li>`,table:(j)=>`<table>${j}</table>`,thead:(j)=>`<thead>${j}</thead>`,tbody:(j)=>`<tbody>${j}</tbody>`,tr:(j)=>`<tr>${j}</tr>`,th:(j)=>`<th>${j}</th>`,td:(j)=>`<td>${j}</td>`,link:(j,q)=>{let B=N(q.href);if(!B)return j;let P=N(K.resolveLink?.(B)??B);return P?`<a href="${D(P)}" rel="nofollow noopener noreferrer">${j}</a>`:j},image:(j,q)=>{let B=N(q.src,!0);return B?`<img src="${D(B)}" alt="${J(j)}" loading="lazy">`:J(j)},html:(j)=>j},{tables:!0,strikethrough:!0,tasklists:!0,autolinks:!0,headings:{ids:!0}}).replace(/\u0001(\d+)\u0002/g,(j,q)=>D(z[Number(q)]??""))}export{kj as wrapInLayout,Oj as stripConfiguredBasePath,Mj as startServer,r as splitLocaleFromPath,u as setLanguageAliases,Tj as serveCLI,l as resolveI18nConfig,p as resetHighlighter,Kj as reserveUniqueSlug,F as renderUntrustedMarkdown,$j as processInlineTocSyntax,t as prewarmHighlighter,m as normalizeLanguage,Cj as markdownToHtml,Gj as markdownHeadingText,e as localizeUrl,zj as localeLabel,jj as localeContentCandidates,n as loadI18nTranslations,o as isLanguageSupported,h as highlightCodeSync,s as highlightCode,d as getSyntaxHighlightingStyles,c as getHighlighterInstance,i as getConfiguredBasePath,f as getConfig,Nj as generateUniqueSlug,Fj as generateTocStyles,Ij as generateTocScripts,_j as generateTocPositions,Vj as generateTocHtml,Zj as generateTocData,Jj as generateSlug,Y as generateSitemap,Xj as generateSidebarTocHtml,V as generateRssFeed,W as generateRobotsTxt,Dj as generateLocaleDetectionScript,Wj as generateInlineTocHtml,Bj as generateHreflangTags,Yj as generateFloatingTocHtml,Sj as filterHeadings,Pj as extractHeadings,Aj as enhanceHeadingsWithAnchors,Ej as defaultTocConfig,x as defaultConfig,Lj as decodeHtmlEntities,qj as configForLocale,g as config,Qj as buildTocHierarchy,X as buildSitemap,_ as buildSearchRuntimeConfig,$ as buildSearchIndex,S as buildRssFeed,v as applyConfigPlugins,Z as SEARCH_INDEX_PATH,a as LIGHT_TOKEN_PALETTE};
2
+ import{a as p,b as u,c as m,d as o,e as s,f as h,g as a,h as d,i as t,j as c,k as Oj,l as kj,m as Cj,n as Mj,o as Tj,p as Rj}from"../chunk-xw4vt0ew.js";import{A as Y,w as S,x as V,y as W,z as X}from"../chunk-9g247fj7.js";import{$ as Z,B as x,C as v,D as g,E as f,J as Ej,K as Gj,L as Jj,M as Kj,N as Nj,O as Pj,P as Qj,Q as Sj,R as Vj,S as Wj,T as Xj,U as Yj,V as Zj,W as _j,X as $j,Y as Aj,Z as Fj,_ as Ij,aa as _,ba as $,ca as Lj}from"../chunk-kw0tya77.js";import{ja as i,ka as l,la as n,ma as r,na as e,oa as jj,pa as qj,qa as zj,ra as Bj,sa as Dj}from"../chunk-94yk2vs9.js";function D(E){return E.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function N(E,K=!1){let z=E.trim();if(!z||/[\u0000-\u0020\u007f-\u009f\\]/.test(z))return null;let G=/^([a-z][a-z\d+.-]*):/i.exec(z)?.[1]?.toLowerCase();if(/^[^/]*:/.test(z)&&(!G||!["http","https",...K?[]:["mailto"]].includes(G)))return null;return z}function F(E,K={}){let z=[],G=E.replace(/[\u0000-\u0002]/g,""),Q=(j)=>j.replace(/\u0001(\d+)\u0002/g,(q,B)=>z[Number(B)]??""),J=(j)=>D(Q(j));return Bun.markdown.render(G,{text:(j)=>`\x01${z.push(j)-1}\x02`,heading:(j,q)=>`<h${q.level} id="wiki-${D(q.id??"")}">${j}</h${q.level}>`,paragraph:(j)=>`<p>${j}</p>`,blockquote:(j)=>`<blockquote>${j}</blockquote>`,strong:(j)=>`<strong>${j}</strong>`,emphasis:(j)=>`<em>${j}</em>`,strikethrough:(j)=>`<del>${j}</del>`,hr:()=>"<hr>",codespan:(j)=>`<code>${J(j)}</code>`,code:(j,q)=>{return`<pre><code${q?.language&&/^[\w+#.-]{1,30}$/.test(q.language)?` class="language-${D(q.language)}"`:""}>${J(j)}</code></pre>`},list:(j,q)=>q.ordered?`<ol start="${q.start??1}">${j}</ol>`:`<ul>${j}</ul>`,listItem:(j,q)=>`<li>${typeof q.checked==="boolean"?`<input type="checkbox" disabled${q.checked?" checked":""}>`:""}${j}</li>`,table:(j)=>`<table>${j}</table>`,thead:(j)=>`<thead>${j}</thead>`,tbody:(j)=>`<tbody>${j}</tbody>`,tr:(j)=>`<tr>${j}</tr>`,th:(j)=>`<th>${j}</th>`,td:(j)=>`<td>${j}</td>`,link:(j,q)=>{let B=N(q.href);if(!B)return j;let P=N(K.resolveLink?.(B)??B);return P?`<a href="${D(P)}" rel="nofollow noopener noreferrer">${j}</a>`:j},image:(j,q)=>{let B=N(q.src,!0);return B?`<img src="${D(B)}" alt="${J(j)}" loading="lazy">`:J(j)},html:(j)=>j},{tables:!0,strikethrough:!0,tasklists:!0,autolinks:!0,headings:{ids:!0}}).replace(/\u0001(\d+)\u0002/g,(j,q)=>D(z[Number(q)]??""))}export{Cj as wrapInLayout,Oj as stripConfiguredBasePath,Tj as startServer,r as splitLocaleFromPath,u as setLanguageAliases,Rj as serveCLI,l as resolveI18nConfig,p as resetHighlighter,Kj as reserveUniqueSlug,F as renderUntrustedMarkdown,$j as processInlineTocSyntax,t as prewarmHighlighter,m as normalizeLanguage,Mj as markdownToHtml,Gj as markdownHeadingText,e as localizeUrl,zj as localeLabel,jj as localeContentCandidates,n as loadI18nTranslations,o as isLanguageSupported,h as highlightCodeSync,s as highlightCode,d as getSyntaxHighlightingStyles,c as getHighlighterInstance,i as getConfiguredBasePath,f as getConfig,Nj as generateUniqueSlug,Fj as generateTocStyles,Ij as generateTocScripts,_j as generateTocPositions,Vj as generateTocHtml,Zj as generateTocData,Jj as generateSlug,Y as generateSitemap,Xj as generateSidebarTocHtml,V as generateRssFeed,W as generateRobotsTxt,Dj as generateLocaleDetectionScript,Wj as generateInlineTocHtml,Bj as generateHreflangTags,Yj as generateFloatingTocHtml,Sj as filterHeadings,Pj as extractHeadings,Aj as enhanceHeadingsWithAnchors,Ej as defaultTocConfig,x as defaultConfig,Lj as decodeHtmlEntities,qj as configForLocale,g as config,Qj as buildTocHierarchy,X as buildSitemap,_ as buildSearchRuntimeConfig,$ as buildSearchIndex,S as buildRssFeed,v as applyConfigPlugins,Z as SEARCH_INDEX_PATH,a as LIGHT_TOKEN_PALETTE,kj as BUN_THEME_FONTS};
@@ -30,6 +30,18 @@ export declare function serveCLI(options?: {
30
30
  watch?: boolean
31
31
  config?: BunPressConfig
32
32
  }): Promise<void>;
33
+ /**
34
+ * Build web-font markup from `config.fonts`: `<link>` tags (preconnect +
35
+ * Google Fonts stylesheet) for the document head, and raw `@font-face` CSS for
36
+ * self-hosted fonts. Returns empty strings when no fonts are configured.
37
+ */
38
+ /**
39
+ * The faces the bun theme is drawn in: Archivo, condensed and heavy, for the
40
+ * headings, and Martian Mono for code and labels. Both are on Google Fonts
41
+ * with the width axes the theme asks for. A site that sets `fonts` itself
42
+ * keeps exactly what it set.
43
+ */
44
+ export declare const BUN_THEME_FONTS: string[];
33
45
  /** Which code-block extras are switched on, from `features.codeBlocks`. */
34
46
  export declare interface CodeBlockFeatures {
35
47
  lineHighlighting: boolean
@@ -2,6 +2,16 @@
2
2
  * Load a template file from the templates directory
3
3
  */
4
4
  export declare function loadTemplate(name: string): Promise<string>;
5
+ /**
6
+ * Remove Blade-style `{{-- ... --}}` comments from a template's source.
7
+ *
8
+ * The interpolator only knows `{{ key }}` and `{!! key !!}`, so a comment was
9
+ * shipped as visible page text: sidebar.stx's multi-line note about where its
10
+ * scripts live rendered under the nav on every docs page. Stripped here, from
11
+ * the template source only, so page content that documents the syntax is
12
+ * never touched.
13
+ */
14
+ export declare function stripTemplateComments(source: string): string;
5
15
  /**
6
16
  * Render a bundled Bunpress template.
7
17
  * Supports escaped {{ key }} and raw {!! key !!} placeholders.
@@ -1,26 +1,16 @@
1
1
  /**
2
- * Get all Bun theme CSS combined
2
+ * Get all Bun theme CSS combined: the default theme, then the Bun layer.
3
3
  */
4
4
  export declare function getBunThemeCSS(): string;
5
- /**
6
- * Get Bun theme CSS variables only
7
- */
5
+ /** The Bun palette and tokens only. */
8
6
  export declare function getBunVars(): string;
9
- /**
10
- * Get Bun base styles only
11
- */
7
+ /** The Bun chrome and prose layer, without the default theme under it. */
12
8
  export declare function getBunBase(): string;
13
- /**
14
- * Get Bun custom block styles only
15
- */
9
+ /** The Bun callout styles only. */
16
10
  export declare function getBunCustomBlocks(): string;
17
- /**
18
- * Get Bun code group styles only
19
- */
11
+ /** The Bun code block, code group and syntax styles only. */
20
12
  export declare function getBunCodeGroups(): string;
21
- /**
22
- * Get Bun extra styles only
23
- */
13
+ /** The Bun home page styles only. */
24
14
  export declare function getBunExtras(): string;
25
15
  declare const bunTheme: BunTheme;
26
16
  export declare interface BunTheme {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/bunpress",
3
3
  "type": "module",
4
- "version": "0.2.33",
4
+ "version": "0.2.35",
5
5
  "description": "Modern documentation engine. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{k as c,l as d,m as e,n as f,o as g}from"./chunk-ds2b3vtw.js";import{ba as b}from"./chunk-dgdd6yma.js";import{ia as a}from"./chunk-twt99rzk.js";export{d as wrapInLayout,c as stripConfiguredBasePath,f as startServer,g as serveCLI,e as markdownToHtml,a as getConfiguredBasePath,b as decodeHtmlEntities};
@@ -1,38 +0,0 @@
1
- // @bun
2
- var Y=import.meta.require;function Q(q){return(q.sitemap?.baseUrl||q.url||"").replace(/\/$/,"")}function j(q){if(q.basePath){let B=q.basePath.trim().replace(/\/+$/,"");if(!B||B==="/")return"";return B.startsWith("/")?B:`/${B}`}let G=Q(q);if(!G)return"";try{let B=new URL(G).pathname.replace(/\/+$/,"");return B==="/"?"":B}catch{return""}}var V={"search.placeholder":"Search documentation","toc.title":"On this page","nav.menu":"Menu","search.noResults":"No results for","theme.toggle":"Toggle dark mode"};function A(q){let G=q?.i18n,B=(G?.locales??[]).filter(Boolean),H=G?.defaultLocale||B[0]||q?.lang||"en",J=(G?.enabled??B.length>1)&&B.length>0;return{enabled:J,locales:J?B:[H],defaultLocale:H,fallbackLocale:G?.fallbackLocale??H,localePath:G?.localePath??"./locales",detectLocale:G?.detectLocale===!0,localeNames:G?.localeNames??{},localeConfig:G?.localeConfig??{},translate:(K)=>V[K]??K}}async function E(q,G){if(!q.enabled)return q;try{let{createTranslator:B,loadTranslations:H}=await import("@stacksjs/ts-i18n"),J=await H({translationsDir:q.localePath,defaultLocale:q.defaultLocale,fallbackLocale:q.fallbackLocale,sources:G?.i18n?.sources??["ts","yaml","json"],optional:!0,verbose:!1}),K=B(J,{defaultLocale:q.defaultLocale,fallbackLocale:q.fallbackLocale}),P=new Set;for(let M of Object.values(J))for(let N of Object.keys(M??{}))P.add(N);let W=[...P].sort((M,N)=>M==="theme"?-1:N==="theme"?1:M.localeCompare(N));return{...q,translate:(M,N,X)=>{for(let R of[M,...W.map((O)=>`${O}.${M}`)])try{let O=K(R,N,X);if(typeof O==="string"&&O&&O!==R)return O}catch{}return V[M]??M}}}catch(B){return console.warn("[bunpress] i18n translations could not be loaded; falling back to defaults \u2014",B instanceof Error?B.message:B),q}}function F(q,G){if(!q.enabled)return{locale:q.defaultLocale,path:G};let B=G.match(/^\/([^/]+)(\/.*)?$/);if(B&&q.locales.includes(B[1])&&B[1]!==q.defaultLocale)return{locale:B[1],path:B[2]||"/"};return{locale:q.defaultLocale,path:G}}function Z(q,G,B){if(!q.enabled||G===q.defaultLocale)return B||"/";return`/${G}${B==="/"?"":B}`||`/${G}`}function I(q,G,B,H){let J=H==="/"?"/index":H,K=[];if(q.enabled&&B!==q.defaultLocale)K.push(`${G}/${B}${J}.md`),K.push(`${G}/${B}${J}/index.md`),K.push(`${G}${J}.${B}.md`);if(K.push(`${G}${J}.md`),K.push(`${G}${J}/index.md`),q.enabled)K.push(`${G}${J}.${q.defaultLocale}.md`);return K}function _(q,G,B){let H=G.localeConfig[B];if(!H)return q;return{...q,...H,themeConfig:H.themeConfig?{...q.themeConfig,...H.themeConfig}:q.themeConfig,markdown:H.markdown?{...q.markdown,...H.markdown}:q.markdown}}function D(q,G){return q.localeNames[G]??G}function S(q,G,B){if(!q.enabled)return"";let H=Q(G);if(!H)return"";let J=q.locales.map((K)=>{let P=`${H}${Z(q,K,B==="/index"?"/":B)}`;return`<link rel="alternate" hreflang="${K}" href="${P}">`});return J.push(`<link rel="alternate" hreflang="x-default" href="${H}${B==="/index"?"/":B}">`),J.join(`
3
- `)}function w(q){if(!q.enabled||!q.detectLocale)return"";return`
4
- (function () {
5
- var LOCALES = ${JSON.stringify(q.locales)};
6
- var DEFAULT = ${JSON.stringify(q.defaultLocale)};
7
- var KEY = 'bunpress-locale';
8
-
9
- try {
10
- var current = location.pathname.split('/')[1];
11
- if (LOCALES.indexOf(current) !== -1) {
12
- // Reading a non-default locale is itself a choice; remember it.
13
- localStorage.setItem(KEY, current);
14
- return;
15
- }
16
- if (localStorage.getItem(KEY)) return;
17
-
18
- var preferred = (navigator.languages || [navigator.language || ''])
19
- .map(function (tag) { return String(tag).toLowerCase(); });
20
-
21
- for (var i = 0; i < preferred.length; i++) {
22
- var tag = preferred[i];
23
- var exact = LOCALES.indexOf(tag) !== -1 ? tag : null;
24
- // 'en-GB' should match an 'en' locale.
25
- var base = exact || (LOCALES.indexOf(tag.split('-')[0]) !== -1 ? tag.split('-')[0] : null);
26
- if (base && base !== DEFAULT) {
27
- localStorage.setItem(KEY, base);
28
- location.replace(\`/\${base}\${location.pathname}\${location.search}\${location.hash}\`);
29
- return;
30
- }
31
- if (base === DEFAULT) return;
32
- }
33
- } catch (_) {
34
- // Storage or history unavailable: leave the reader where they are.
35
- }
36
- })();
37
- `.trim()}
38
- export{Y as ga,Q as ha,j as ia,A as ja,E as ka,F as la,Z as ma,I as na,_ as oa,D as pa,S as qa,w as ra};