@blackwork/docs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +9 -0
  4. package/dist/config/defaults.cjs +9 -0
  5. package/dist/config/defaults.mjs +9 -0
  6. package/dist/config/define-config.cjs +9 -0
  7. package/dist/config/define-config.d.mts +7 -0
  8. package/dist/config/define-config.d.ts +7 -0
  9. package/dist/config/define-config.mjs +9 -0
  10. package/dist/config/define-docs-config.cjs +9 -0
  11. package/dist/config/define-docs-config.d.mts +9 -0
  12. package/dist/config/define-docs-config.d.ts +9 -0
  13. package/dist/config/define-docs-config.mjs +9 -0
  14. package/dist/config/load-content-config.cjs +9 -0
  15. package/dist/config/load-content-config.d.mts +8 -0
  16. package/dist/config/load-content-config.d.ts +8 -0
  17. package/dist/config/load-content-config.mjs +9 -0
  18. package/dist/config/types.d.mts +78 -0
  19. package/dist/config/types.d.ts +78 -0
  20. package/dist/index.cjs +9 -0
  21. package/dist/index.d.mts +24 -0
  22. package/dist/index.d.ts +24 -0
  23. package/dist/index.mjs +9 -0
  24. package/dist/mdx/default-docs-components.cjs +9 -0
  25. package/dist/mdx/default-docs-components.d.mts +7 -0
  26. package/dist/mdx/default-docs-components.d.ts +7 -0
  27. package/dist/mdx/default-docs-components.mjs +9 -0
  28. package/dist/mdx/merge-docs-components.cjs +9 -0
  29. package/dist/mdx/merge-docs-components.d.mts +7 -0
  30. package/dist/mdx/merge-docs-components.d.ts +7 -0
  31. package/dist/mdx/merge-docs-components.mjs +9 -0
  32. package/dist/metadata/create-doc-metadata.cjs +9 -0
  33. package/dist/metadata/create-doc-metadata.d.mts +33 -0
  34. package/dist/metadata/create-doc-metadata.d.ts +33 -0
  35. package/dist/metadata/create-doc-metadata.mjs +9 -0
  36. package/dist/navigation/build-locale-links.cjs +9 -0
  37. package/dist/navigation/build-locale-links.d.mts +24 -0
  38. package/dist/navigation/build-locale-links.d.ts +24 -0
  39. package/dist/navigation/build-locale-links.mjs +9 -0
  40. package/dist/navigation/build-pager.cjs +9 -0
  41. package/dist/navigation/build-pager.d.mts +25 -0
  42. package/dist/navigation/build-pager.d.ts +25 -0
  43. package/dist/navigation/build-pager.mjs +9 -0
  44. package/dist/navigation/build-sidebar.cjs +9 -0
  45. package/dist/navigation/build-sidebar.d.mts +28 -0
  46. package/dist/navigation/build-sidebar.d.ts +28 -0
  47. package/dist/navigation/build-sidebar.mjs +9 -0
  48. package/dist/navigation/resolve-sidebar.cjs +9 -0
  49. package/dist/navigation/resolve-sidebar.d.mts +20 -0
  50. package/dist/navigation/resolve-sidebar.d.ts +20 -0
  51. package/dist/navigation/resolve-sidebar.mjs +9 -0
  52. package/dist/next/context.cjs +9 -0
  53. package/dist/next/context.mjs +9 -0
  54. package/dist/next/load-doc-content.cjs +9 -0
  55. package/dist/next/load-doc-content.mjs +9 -0
  56. package/dist/next/load-generated-manifest.cjs +9 -0
  57. package/dist/next/load-generated-manifest.mjs +9 -0
  58. package/dist/next/metadata.cjs +9 -0
  59. package/dist/next/metadata.d.mts +12 -0
  60. package/dist/next/metadata.d.ts +12 -0
  61. package/dist/next/metadata.mjs +9 -0
  62. package/dist/next/page.cjs +9 -0
  63. package/dist/next/page.d.mts +16 -0
  64. package/dist/next/page.d.ts +16 -0
  65. package/dist/next/page.mjs +9 -0
  66. package/dist/next/render-route.cjs +9 -0
  67. package/dist/next/render-route.d.mts +10 -0
  68. package/dist/next/render-route.d.ts +10 -0
  69. package/dist/next/render-route.mjs +9 -0
  70. package/dist/next/resolve-document-lang.cjs +9 -0
  71. package/dist/next/resolve-document-lang.mjs +9 -0
  72. package/dist/next/root-layout.cjs +9 -0
  73. package/dist/next/root-layout.d.mts +19 -0
  74. package/dist/next/root-layout.d.ts +19 -0
  75. package/dist/next/root-layout.mjs +9 -0
  76. package/dist/next-plugin/generate.cjs +32 -0
  77. package/dist/next-plugin/generate.mjs +32 -0
  78. package/dist/next.cjs +9 -0
  79. package/dist/next.d.mts +21 -0
  80. package/dist/next.d.ts +21 -0
  81. package/dist/next.mjs +9 -0
  82. package/dist/routing/build-static-params.cjs +9 -0
  83. package/dist/routing/build-static-params.d.mts +13 -0
  84. package/dist/routing/build-static-params.d.ts +13 -0
  85. package/dist/routing/build-static-params.mjs +9 -0
  86. package/dist/routing/resolve-docs-route.cjs +9 -0
  87. package/dist/routing/resolve-docs-route.d.mts +35 -0
  88. package/dist/routing/resolve-docs-route.d.ts +35 -0
  89. package/dist/routing/resolve-docs-route.mjs +9 -0
  90. package/dist/runtime.cjs +9 -0
  91. package/dist/runtime.d.mts +4 -0
  92. package/dist/runtime.d.ts +4 -0
  93. package/dist/runtime.mjs +9 -0
  94. package/dist/source/build-docs-source.cjs +9 -0
  95. package/dist/source/build-docs-source.mjs +9 -0
  96. package/dist/source/collect-docs-manifest.cjs +9 -0
  97. package/dist/source/collect-docs-manifest.mjs +9 -0
  98. package/dist/source/create-docs-source-from-manifest.cjs +9 -0
  99. package/dist/source/create-docs-source-from-manifest.mjs +9 -0
  100. package/dist/source/create-docs-source.cjs +9 -0
  101. package/dist/source/create-docs-source.d.mts +10 -0
  102. package/dist/source/create-docs-source.d.ts +10 -0
  103. package/dist/source/create-docs-source.mjs +9 -0
  104. package/dist/source/types.d.mts +36 -0
  105. package/dist/source/types.d.ts +36 -0
  106. package/dist/theme/components/content-shell.cjs +9 -0
  107. package/dist/theme/components/content-shell.d.mts +17 -0
  108. package/dist/theme/components/content-shell.d.ts +17 -0
  109. package/dist/theme/components/content-shell.mjs +9 -0
  110. package/dist/theme/components/docs-rail-scroll-state.cjs +9 -0
  111. package/dist/theme/components/docs-rail-scroll-state.mjs +9 -0
  112. package/dist/theme/components/docs-rail-scroll.cjs +9 -0
  113. package/dist/theme/components/docs-rail-scroll.mjs +9 -0
  114. package/dist/theme/components/docs-scroll-reset.cjs +9 -0
  115. package/dist/theme/components/docs-scroll-reset.mjs +9 -0
  116. package/dist/theme/components/docs-shell.cjs +9 -0
  117. package/dist/theme/components/docs-shell.d.mts +17 -0
  118. package/dist/theme/components/docs-shell.d.ts +17 -0
  119. package/dist/theme/components/docs-shell.mjs +9 -0
  120. package/dist/theme/components/docs-toc-geometry.cjs +9 -0
  121. package/dist/theme/components/docs-toc-geometry.mjs +9 -0
  122. package/dist/theme/components/docs-toc.cjs +9 -0
  123. package/dist/theme/components/docs-toc.mjs +9 -0
  124. package/dist/theme/components/footer.cjs +9 -0
  125. package/dist/theme/components/footer.d.mts +11 -0
  126. package/dist/theme/components/footer.d.ts +11 -0
  127. package/dist/theme/components/footer.mjs +9 -0
  128. package/dist/theme/components/header.cjs +9 -0
  129. package/dist/theme/components/header.d.mts +16 -0
  130. package/dist/theme/components/header.d.ts +16 -0
  131. package/dist/theme/components/header.mjs +9 -0
  132. package/dist/theme/components/home-shell.cjs +9 -0
  133. package/dist/theme/components/home-shell.d.mts +14 -0
  134. package/dist/theme/components/home-shell.d.ts +14 -0
  135. package/dist/theme/components/home-shell.mjs +9 -0
  136. package/dist/theme/components/link.cjs +9 -0
  137. package/dist/theme/components/link.d.mts +9 -0
  138. package/dist/theme/components/link.d.ts +9 -0
  139. package/dist/theme/components/link.mjs +9 -0
  140. package/dist/theme/components/shell-shared.cjs +9 -0
  141. package/dist/theme/components/shell-shared.mjs +9 -0
  142. package/dist/theme/create-home-data.cjs +9 -0
  143. package/dist/theme/create-home-data.d.mts +18 -0
  144. package/dist/theme/create-home-data.d.ts +18 -0
  145. package/dist/theme/create-home-data.mjs +9 -0
  146. package/dist/theme/slots.cjs +9 -0
  147. package/dist/theme/slots.d.mts +7 -0
  148. package/dist/theme/slots.d.ts +7 -0
  149. package/dist/theme/slots.mjs +9 -0
  150. package/dist/theme/types.d.mts +64 -0
  151. package/dist/theme/types.d.ts +64 -0
  152. package/dist/theme.cjs +9 -0
  153. package/dist/theme.d.mts +11 -0
  154. package/dist/theme.d.ts +11 -0
  155. package/dist/theme.mjs +9 -0
  156. package/package.json +81 -0
@@ -0,0 +1,12 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "../config/types.mjs";
3
+ import { DocsRouteParams } from "../routing/resolve-docs-route.mjs";
4
+
5
+ //#region src/next/metadata.d.ts
6
+ interface GenerateMetadataOptions {
7
+ config?: DocsConfig | NormalizedDocsConfig;
8
+ params?: DocsRouteParams | Promise<DocsRouteParams>;
9
+ rootDir?: string;
10
+ }
11
+ //#endregion
12
+ export { GenerateMetadataOptions };
@@ -0,0 +1,12 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "../config/types.js";
3
+ import { DocsRouteParams } from "../routing/resolve-docs-route.js";
4
+
5
+ //#region src/next/metadata.d.ts
6
+ interface GenerateMetadataOptions {
7
+ config?: DocsConfig | NormalizedDocsConfig;
8
+ params?: DocsRouteParams | Promise<DocsRouteParams>;
9
+ rootDir?: string;
10
+ }
11
+ //#endregion
12
+ export { GenerateMetadataOptions };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{createDocMetadata as e}from"../metadata/create-doc-metadata.mjs";import{resolveDocsRoute as t}from"../routing/resolve-docs-route.mjs";import{createNextDocsContext as n}from"./context.mjs";const r=async({config:r,params:i,rootDir:a}={})=>{let{normalizedConfig:o,source:s}=await n({config:r,rootDir:a}),c=t({source:s,params:await i});if(c.kind===`notFound`)return{};let l=c.kind===`redirect`?s.getLegacyAliasHref(c.locale,c.slugSegments)??c.entry.href:c.entry.href;return e({config:o,entry:c.entry,pathname:l,source:s})};export{r as generateMetadata};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=require(`../routing/build-static-params.cjs`),t=require(`../routing/resolve-docs-route.cjs`),n=require(`./context.cjs`),r=require(`./render-route.cjs`),i=async({config:t,rootDir:r}={})=>{let{source:i}=await n.createNextDocsContext({config:t,rootDir:r});return e.buildDocsStaticParams({source:i})},a=async({config:e,onNotFound:i,onRedirect:a,params:o,rootDir:s})=>{let{normalizedConfig:c,source:l}=await n.createNextDocsContext({rootDir:s,config:e});return r.renderResolvedDocsRoute({config:c,onNotFound:i,onRedirect:a,resolution:t.resolveDocsRoute({source:l,params:await o}),source:l})};exports.DocsPage=a,exports.generateStaticParams=i;
@@ -0,0 +1,16 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "../config/types.mjs";
3
+ import { DocsRouteParams } from "../routing/resolve-docs-route.mjs";
4
+ import { DocsPageAdapterHooks } from "./render-route.mjs";
5
+ import { ReactNode } from "react";
6
+
7
+ //#region src/next/page.d.ts
8
+ interface GenerateStaticParamsOptions {
9
+ config?: DocsConfig | NormalizedDocsConfig;
10
+ rootDir?: string;
11
+ }
12
+ interface DocsPageProps extends DocsPageAdapterHooks, GenerateStaticParamsOptions {
13
+ params?: DocsRouteParams | Promise<DocsRouteParams>;
14
+ }
15
+ //#endregion
16
+ export { DocsPageProps, GenerateStaticParamsOptions };
@@ -0,0 +1,16 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "../config/types.js";
3
+ import { DocsRouteParams } from "../routing/resolve-docs-route.js";
4
+ import { DocsPageAdapterHooks } from "./render-route.js";
5
+ import { ReactNode } from "react";
6
+
7
+ //#region src/next/page.d.ts
8
+ interface GenerateStaticParamsOptions {
9
+ config?: DocsConfig | NormalizedDocsConfig;
10
+ rootDir?: string;
11
+ }
12
+ interface DocsPageProps extends DocsPageAdapterHooks, GenerateStaticParamsOptions {
13
+ params?: DocsRouteParams | Promise<DocsRouteParams>;
14
+ }
15
+ //#endregion
16
+ export { DocsPageProps, GenerateStaticParamsOptions };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{buildDocsStaticParams as e}from"../routing/build-static-params.mjs";import{resolveDocsRoute as t}from"../routing/resolve-docs-route.mjs";import{createNextDocsContext as n}from"./context.mjs";import{renderResolvedDocsRoute as r}from"./render-route.mjs";const i=async({config:t,rootDir:r}={})=>{let{source:i}=await n({config:t,rootDir:r});return e({source:i})},a=async({config:e,onNotFound:i,onRedirect:a,params:o,rootDir:s})=>{let{normalizedConfig:c,source:l}=await n({rootDir:s,config:e});return r({config:c,onNotFound:i,onRedirect:a,resolution:t({source:l,params:await o}),source:l})};export{a as DocsPage,i as generateStaticParams};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../theme/components/link.cjs`),t=require(`../theme/components/shell-shared.cjs`),n=require(`../theme/components/content-shell.cjs`),r=require(`../theme/components/docs-shell.cjs`),i=require(`../theme/components/home-shell.cjs`),a=require(`./load-doc-content.cjs`);let o=require(`react/jsx-runtime`),s=require(`blackwork/rsc`);const c=({href:t})=>(0,o.jsxs)(s.LayoutMain,{className:`items-center justify-center py-20`,children:[(0,o.jsx)(`meta`,{httpEquiv:`refresh`,content:`0;url=${t}`}),(0,o.jsxs)(s.Empty,{"data-docs-region":`redirect`,className:`max-w-xl border-border/60`,children:[(0,o.jsxs)(s.EmptyHeader,{children:[(0,o.jsx)(s.EmptyTitle,{children:`Redirecting to the canonical URL`}),(0,o.jsx)(s.EmptyDescription,{children:`The requested path is an alias. You will be sent to the canonical page automatically.`})]}),(0,o.jsx)(s.EmptyContent,{children:(0,o.jsx)(s.Button,{asChild:!0,children:(0,o.jsx)(e.DefaultDocsLink,{href:t,children:`Continue now`})})})]})]}),l=async({config:e,onNotFound:s,onRedirect:l,resolution:u,source:d})=>{if(u.kind===`notFound`)return s?await s():null;if(u.kind===`redirect`)return l?await l(u.entry.href):(0,o.jsx)(c,{href:u.entry.href});if(u.slugSegments.length===0)return(0,o.jsx)(i.DefaultHomeShell,{config:e,locale:u.locale,source:d});let f=await a.loadDocContent({config:e,entry:u.entry});return t.getEntrySectionConfig(e,u.entry).layout===`content`?(0,o.jsx)(n.DefaultContentShell,{config:e,entry:u.entry,headings:f.headings,source:d,children:f.jsxElement}):(0,o.jsx)(r.DefaultDocsShell,{config:e,entry:u.entry,headings:f.headings,source:d,children:f.jsxElement})};exports.renderResolvedDocsRoute=l;
@@ -0,0 +1,10 @@
1
+
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/next/render-route.d.ts
5
+ interface DocsPageAdapterHooks {
6
+ onNotFound?: () => ReactNode | Promise<ReactNode>;
7
+ onRedirect?: (href: string) => ReactNode | Promise<ReactNode>;
8
+ }
9
+ //#endregion
10
+ export { DocsPageAdapterHooks };
@@ -0,0 +1,10 @@
1
+
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/next/render-route.d.ts
5
+ interface DocsPageAdapterHooks {
6
+ onNotFound?: () => ReactNode | Promise<ReactNode>;
7
+ onRedirect?: (href: string) => ReactNode | Promise<ReactNode>;
8
+ }
9
+ //#endregion
10
+ export { DocsPageAdapterHooks };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{DefaultDocsLink as e}from"../theme/components/link.mjs";import{getEntrySectionConfig as t}from"../theme/components/shell-shared.mjs";import{DefaultContentShell as n}from"../theme/components/content-shell.mjs";import{DefaultDocsShell as r}from"../theme/components/docs-shell.mjs";import{DefaultHomeShell as i}from"../theme/components/home-shell.mjs";import{loadDocContent as a}from"./load-doc-content.mjs";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{Button as c,Empty as l,EmptyContent as u,EmptyDescription as d,EmptyHeader as f,EmptyTitle as p,LayoutMain as m}from"blackwork/rsc";const h=({href:t})=>s(m,{className:`items-center justify-center py-20`,children:[o(`meta`,{httpEquiv:`refresh`,content:`0;url=${t}`}),s(l,{"data-docs-region":`redirect`,className:`max-w-xl border-border/60`,children:[s(f,{children:[o(p,{children:`Redirecting to the canonical URL`}),o(d,{children:`The requested path is an alias. You will be sent to the canonical page automatically.`})]}),o(u,{children:o(c,{asChild:!0,children:o(e,{href:t,children:`Continue now`})})})]})]}),g=async({config:e,onNotFound:s,onRedirect:c,resolution:l,source:u})=>{if(l.kind===`notFound`)return s?await s():null;if(l.kind===`redirect`)return c?await c(l.entry.href):o(h,{href:l.entry.href});if(l.slugSegments.length===0)return o(i,{config:e,locale:l.locale,source:u});let d=await a({config:e,entry:l.entry});return t(e,l.entry).layout===`content`?o(n,{config:e,entry:l.entry,headings:d.headings,source:u,children:d.jsxElement}):o(r,{config:e,entry:l.entry,headings:d.headings,source:u,children:d.jsxElement})};export{g as renderResolvedDocsRoute};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=e=>Object.values(e.locales??{}),t=(t,n)=>{if(n)return t.locales?.[n]??e(t).find(e=>e.code===n)},n=(e,n)=>{let[r]=(n?.split(`?`)[0]?.split(`#`)[0]??``).split(`/`).filter(Boolean);return r?t(e,r):void 0},r=n=>t(n,n.defaultLocale)??e(n)[0],i=({config:e,pathname:t})=>{let{content:i}=e,a=n(i,t)??r(i);return a?.lang||a?.code||i.defaultLocale||`en`};exports.resolveDocumentLang=i;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=e=>Object.values(e.locales??{}),t=(t,n)=>{if(n)return t.locales?.[n]??e(t).find(e=>e.code===n)},n=(e,n)=>{let[r]=(n?.split(`?`)[0]?.split(`#`)[0]??``).split(`/`).filter(Boolean);return r?t(e,r):void 0},r=n=>t(n,n.defaultLocale)??e(n)[0],i=({config:e,pathname:t})=>{let{content:i}=e,a=n(i,t)??r(i);return a?.lang||a?.code||i.defaultLocale||`en`};export{i as resolveDocumentLang};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../config/define-config.cjs`),t=require(`../theme/components/docs-scroll-reset.cjs`),n=require(`./resolve-document-lang.cjs`);let r=require(`blackwork`),i=require(`react/jsx-runtime`);const a=async e=>{let t=(e?await e:void 0)?.slug?.filter(e=>e.length>0)??[];return t.length>0?`/${t.join(`/`)}`:`/`},o=e=>e===`light`||e===`dark`,s=e=>{let t=typeof e.storageKey==`string`?e.storageKey:void 0,n=o(e.defaultTheme)?e.defaultTheme:void 0;return{...t?{storageKey:t}:{},...n?{defaultTheme:n}:{}}},c=async({children:o,config:c,params:l})=>{let u=e.defineConfig(c),d=n.resolveDocumentLang({config:u,pathname:await a(l)}),f=s(u.theme);return(0,i.jsxs)(`html`,{lang:d,suppressHydrationWarning:!0,children:[(0,i.jsx)(`head`,{children:(0,i.jsx)(r.ThemeScript,{...f})}),(0,i.jsx)(`body`,{className:`flex min-h-screen w-screen flex-col`,children:(0,i.jsxs)(r.ThemeProvider,{...f,children:[(0,i.jsx)(t.DocsScrollReset,{}),o]})})]})};exports.DocsRootLayout=c;
@@ -0,0 +1,19 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "../config/types.mjs";
3
+ import { DocsRouteParams } from "../routing/resolve-docs-route.mjs";
4
+ import { ReactNode } from "react";
5
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
6
+
7
+ //#region src/next/root-layout.d.ts
8
+ interface DocsRootLayoutProps {
9
+ children: ReactNode;
10
+ config?: DocsConfig | NormalizedDocsConfig;
11
+ params?: DocsRouteParams | Promise<DocsRouteParams>;
12
+ }
13
+ declare const DocsRootLayout: ({
14
+ children,
15
+ config,
16
+ params
17
+ }: DocsRootLayoutProps) => Promise<_$react_jsx_runtime0.JSX.Element>;
18
+ //#endregion
19
+ export { DocsRootLayout, DocsRootLayoutProps };
@@ -0,0 +1,19 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "../config/types.js";
3
+ import { DocsRouteParams } from "../routing/resolve-docs-route.js";
4
+ import { ReactNode } from "react";
5
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
6
+
7
+ //#region src/next/root-layout.d.ts
8
+ interface DocsRootLayoutProps {
9
+ children: ReactNode;
10
+ config?: DocsConfig | NormalizedDocsConfig;
11
+ params?: DocsRouteParams | Promise<DocsRouteParams>;
12
+ }
13
+ declare const DocsRootLayout: ({
14
+ children,
15
+ config,
16
+ params
17
+ }: DocsRootLayoutProps) => Promise<_$react_jsx_runtime0.JSX.Element>;
18
+ //#endregion
19
+ export { DocsRootLayout, DocsRootLayoutProps };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{defineConfig as e}from"../config/define-config.mjs";import{DocsScrollReset as t}from"../theme/components/docs-scroll-reset.mjs";import{resolveDocumentLang as n}from"./resolve-document-lang.mjs";import{ThemeProvider as r,ThemeScript as i}from"blackwork";import{jsx as a,jsxs as o}from"react/jsx-runtime";const s=async e=>{let t=(e?await e:void 0)?.slug?.filter(e=>e.length>0)??[];return t.length>0?`/${t.join(`/`)}`:`/`},c=e=>e===`light`||e===`dark`,l=e=>{let t=typeof e.storageKey==`string`?e.storageKey:void 0,n=c(e.defaultTheme)?e.defaultTheme:void 0;return{...t?{storageKey:t}:{},...n?{defaultTheme:n}:{}}},u=async({children:c,config:u,params:d})=>{let f=e(u),p=n({config:f,pathname:await s(d)}),m=l(f.theme);return o(`html`,{lang:p,suppressHydrationWarning:!0,children:[a(`head`,{children:a(i,{...m})}),a(`body`,{className:`flex min-h-screen w-screen flex-col`,children:o(r,{...m,children:[a(t,{}),c]})})]})};export{u as DocsRootLayout};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../source/collect-docs-manifest.cjs`);let t=require(`node:fs`),n=require(`node:path`),r=require(`node:crypto`);const i=(e,t)=>{let i=(0,r.createHash)(`sha1`).update((0,n.relative)((0,n.resolve)(t),e.sourcePath)).digest(`hex`).slice(0,12);return`${e.locale}-${i}`},a=e=>JSON.stringify(e,null,2),o=({rootDir:r=`.`,config:o,outDir:s=`.blackwork/docs`}={})=>{let c=e.collectDocsManifest({rootDir:r,config:o}),l=(0,n.resolve)(r),u=(0,n.resolve)(l,s),d=(0,n.join)(u,`content`),f=(0,n.join)(u,`manifest.mjs`),p=[];(0,t.rmSync)(u,{recursive:!0,force:!0}),(0,t.mkdirSync)(d,{recursive:!0});for(let e of c.entries){let r=`${i(e,l)}.mjs`,o=`./content/${r}`,s=(0,n.join)(d,r),c=(0,t.readFileSync)(e.sourcePath,`utf8`);(0,t.writeFileSync)(s,`const source = ${JSON.stringify(c)}\n\nexport default source\n`),p.push(`{
10
+ locale: ${a(e.locale)},
11
+ slugSegments: ${a(e.slugSegments)},
12
+ href: ${a(e.href)},
13
+ legacyHref: ${a(e.legacyHref)},
14
+ sourcePath: ${a(e.sourcePath)},
15
+ format: ${a(e.format)},
16
+ title: ${a(e.title)},
17
+ description: ${a(e.description)},
18
+ order: ${a(e.order)},
19
+ frontmatter: ${a(e.frontmatter)},
20
+ loadSource: async () => (await import(${a(o)})).default,
21
+ }`)}return(0,t.writeFileSync)(f,`export const docsManifest = {
22
+ defaultLocale: ${a(c.defaultLocale)},
23
+ enableDefaultLocaleRedirect: ${a(c.enableDefaultLocaleRedirect)},
24
+ localeCodes: ${a(c.localeCodes)},
25
+ entries: [
26
+ ${p.map(e=>` ${e}`).join(`,
27
+ `)}
28
+ ],
29
+ }
30
+
31
+ export default docsManifest
32
+ `),{contentModulesDir:d,manifestPath:f}};exports.generateDocsManifestFiles=o;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{collectDocsManifest as e}from"../source/collect-docs-manifest.mjs";import{mkdirSync as t,readFileSync as n,rmSync as r,writeFileSync as i}from"node:fs";import{join as a,relative as o,resolve as s}from"node:path";import{createHash as c}from"node:crypto";const l=(e,t)=>{let n=c(`sha1`).update(o(s(t),e.sourcePath)).digest(`hex`).slice(0,12);return`${e.locale}-${n}`},u=e=>JSON.stringify(e,null,2),d=({rootDir:o=`.`,config:c,outDir:d=`.blackwork/docs`}={})=>{let f=e({rootDir:o,config:c}),p=s(o),m=s(p,d),h=a(m,`content`),g=a(m,`manifest.mjs`),_=[];r(m,{recursive:!0,force:!0}),t(h,{recursive:!0});for(let e of f.entries){let t=`${l(e,p)}.mjs`,r=`./content/${t}`,o=a(h,t),s=n(e.sourcePath,`utf8`);i(o,`const source = ${JSON.stringify(s)}\n\nexport default source\n`),_.push(`{
10
+ locale: ${u(e.locale)},
11
+ slugSegments: ${u(e.slugSegments)},
12
+ href: ${u(e.href)},
13
+ legacyHref: ${u(e.legacyHref)},
14
+ sourcePath: ${u(e.sourcePath)},
15
+ format: ${u(e.format)},
16
+ title: ${u(e.title)},
17
+ description: ${u(e.description)},
18
+ order: ${u(e.order)},
19
+ frontmatter: ${u(e.frontmatter)},
20
+ loadSource: async () => (await import(${u(r)})).default,
21
+ }`)}return i(g,`export const docsManifest = {
22
+ defaultLocale: ${u(f.defaultLocale)},
23
+ enableDefaultLocaleRedirect: ${u(f.enableDefaultLocaleRedirect)},
24
+ localeCodes: ${u(f.localeCodes)},
25
+ entries: [
26
+ ${_.map(e=>` ${e}`).join(`,
27
+ `)}
28
+ ],
29
+ }
30
+
31
+ export default docsManifest
32
+ `),{contentModulesDir:h,manifestPath:g}};export{d as generateDocsManifestFiles};
package/dist/next.cjs ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./config/define-config.cjs`),t=require(`./config/load-content-config.cjs`),n=require(`./next-plugin/generate.cjs`);let r=require(`node:fs`),i=require(`node:path`);const a=new Set,o=({config:r,content:a,rootDir:o=process.cwd(),outDir:c,configPath:l=`docs.config.ts`}={})=>{let u=(0,i.resolve)(o),d=(0,i.resolve)(u,l),f=t.resolveDocsContentConfigPath({rootDir:u}),p=t.loadDocsContentConfig({rootDir:u}),m=p||a||r?.content?{...p??{},...a??{},...r?.content??{}}:void 0,h=e.defineConfig({...r??{},...m?{content:m}:{}});return n.generateDocsManifestFiles({rootDir:u,config:h,outDir:c}),process.env.NODE_ENV===`development`&&console.log(`[blackwork-docs] generated manifest available at .blackwork/docs/manifest.mjs`),process.env.NODE_ENV===`development`&&s({config:h,configPath:d,contentConfigPath:f,outDir:c,rootDir:u}),(e={})=>{let t=e.turbopack??{};return{...e,turbopack:{...t,resolveAlias:{...t.resolveAlias,"private-blackwork-docs-root/*":`./*`}},webpack(t,n){var r;return t.resolve||(t.resolve={}),(r=t.resolve).alias||(r.alias={}),t.resolve.alias[`private-blackwork-docs-root`]=u,e.webpack?.(t,n)??t}}}},s=({config:e,configPath:t,contentConfigPath:o,outDir:s,rootDir:c})=>{let l=(0,i.resolve)(c,e.content.root),u=`${c}:${s??`.blackwork/docs`}`;a.has(u)||(a.add(u),import(`chokidar`).then(({watch:i})=>{let d=[l];(0,r.existsSync)(t)&&d.push(t),o&&(0,r.existsSync)(o)&&d.push(o);let f=i(d,{ignoreInitial:!0,persistent:!0});f.on(`all`,()=>{n.generateDocsManifestFiles({rootDir:c,config:e,outDir:s})}),f.on(`error`,()=>{a.delete(u)}),process.once(`exit`,()=>{a.delete(u),f.close()})}).catch(()=>{a.delete(u)}))};exports.withBlackworkDocs=o;
@@ -0,0 +1,21 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "./config/types.mjs";
3
+ import { NextConfig } from "next";
4
+
5
+ //#region src/next-plugin/index.d.ts
6
+ interface WithBlackworkDocsOptions {
7
+ config?: DocsConfig | NormalizedDocsConfig;
8
+ content?: DocsConfig['content'] | NormalizedDocsConfig['content'];
9
+ rootDir?: string;
10
+ outDir?: string;
11
+ configPath?: string;
12
+ }
13
+ declare const withBlackworkDocs: ({
14
+ config,
15
+ content,
16
+ rootDir,
17
+ outDir,
18
+ configPath
19
+ }?: WithBlackworkDocsOptions) => (nextConfig?: NextConfig) => NextConfig;
20
+ //#endregion
21
+ export { WithBlackworkDocsOptions, withBlackworkDocs };
package/dist/next.d.ts ADDED
@@ -0,0 +1,21 @@
1
+
2
+ import { DocsConfig, NormalizedDocsConfig } from "./config/types.js";
3
+ import { NextConfig } from "next";
4
+
5
+ //#region src/next-plugin/index.d.ts
6
+ interface WithBlackworkDocsOptions {
7
+ config?: DocsConfig | NormalizedDocsConfig;
8
+ content?: DocsConfig['content'] | NormalizedDocsConfig['content'];
9
+ rootDir?: string;
10
+ outDir?: string;
11
+ configPath?: string;
12
+ }
13
+ declare const withBlackworkDocs: ({
14
+ config,
15
+ content,
16
+ rootDir,
17
+ outDir,
18
+ configPath
19
+ }?: WithBlackworkDocsOptions) => (nextConfig?: NextConfig) => NextConfig;
20
+ //#endregion
21
+ export { WithBlackworkDocsOptions, withBlackworkDocs };
package/dist/next.mjs ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{defineConfig as e}from"./config/define-config.mjs";import{loadDocsContentConfig as t,resolveDocsContentConfigPath as n}from"./config/load-content-config.mjs";import{generateDocsManifestFiles as r}from"./next-plugin/generate.mjs";import{existsSync as i}from"node:fs";import{resolve as a}from"node:path";const o=new Set,s=({config:i,content:o,rootDir:s=process.cwd(),outDir:l,configPath:u=`docs.config.ts`}={})=>{let d=a(s),f=a(d,u),p=n({rootDir:d}),m=t({rootDir:d}),h=m||o||i?.content?{...m??{},...o??{},...i?.content??{}}:void 0,g=e({...i??{},...h?{content:h}:{}});return r({rootDir:d,config:g,outDir:l}),process.env.NODE_ENV===`development`&&console.log(`[blackwork-docs] generated manifest available at .blackwork/docs/manifest.mjs`),process.env.NODE_ENV===`development`&&c({config:g,configPath:f,contentConfigPath:p,outDir:l,rootDir:d}),(e={})=>{let t=e.turbopack??{};return{...e,turbopack:{...t,resolveAlias:{...t.resolveAlias,"private-blackwork-docs-root/*":`./*`}},webpack(t,n){var r;return t.resolve||(t.resolve={}),(r=t.resolve).alias||(r.alias={}),t.resolve.alias[`private-blackwork-docs-root`]=d,e.webpack?.(t,n)??t}}}},c=({config:e,configPath:t,contentConfigPath:n,outDir:s,rootDir:c})=>{let l=a(c,e.content.root),u=`${c}:${s??`.blackwork/docs`}`;o.has(u)||(o.add(u),import(`chokidar`).then(({watch:a})=>{let d=[l];i(t)&&d.push(t),n&&i(n)&&d.push(n);let f=a(d,{ignoreInitial:!0,persistent:!0});f.on(`all`,()=>{r({rootDir:c,config:e,outDir:s})}),f.on(`error`,()=>{o.delete(u)}),process.once(`exit`,()=>{o.delete(u),f.close()})}).catch(()=>{o.delete(u)}))};export{s as withBlackworkDocs};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=e=>{let t=e.split(`/`).filter(Boolean);return t.length===0?{}:{slug:t}},t=({slug:e})=>e?.join(`/`)??``;function n({source:n}){let r=n.getLocaleCodes().flatMap(e=>n.getEntries(e)).map(t=>e(t.href)),i=n.isDefaultLocaleRedirectEnabled()?n.getAliasEntries().map(t=>e(t.legacyHref)):[],a=new Map;for(let e of[...r,...i])a.set(t(e),e);return[...a.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([,e])=>e)}exports.buildDocsStaticParams=n;
@@ -0,0 +1,13 @@
1
+
2
+ import { DocsSource } from "../source/types.mjs";
3
+ import { DocsRouteParams } from "./resolve-docs-route.mjs";
4
+
5
+ //#region src/routing/build-static-params.d.ts
6
+ interface BuildDocsStaticParamsOptions {
7
+ source: DocsSource;
8
+ }
9
+ declare function buildDocsStaticParams({
10
+ source
11
+ }: BuildDocsStaticParamsOptions): DocsRouteParams[];
12
+ //#endregion
13
+ export { BuildDocsStaticParamsOptions, buildDocsStaticParams };
@@ -0,0 +1,13 @@
1
+
2
+ import { DocsSource } from "../source/types.js";
3
+ import { DocsRouteParams } from "./resolve-docs-route.js";
4
+
5
+ //#region src/routing/build-static-params.d.ts
6
+ interface BuildDocsStaticParamsOptions {
7
+ source: DocsSource;
8
+ }
9
+ declare function buildDocsStaticParams({
10
+ source
11
+ }: BuildDocsStaticParamsOptions): DocsRouteParams[];
12
+ //#endregion
13
+ export { BuildDocsStaticParamsOptions, buildDocsStaticParams };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=e=>{let t=e.split(`/`).filter(Boolean);return t.length===0?{}:{slug:t}},t=({slug:e})=>e?.join(`/`)??``;function n({source:n}){let r=n.getLocaleCodes().flatMap(e=>n.getEntries(e)).map(t=>e(t.href)),i=n.isDefaultLocaleRedirectEnabled()?n.getAliasEntries().map(t=>e(t.legacyHref)):[],a=new Map;for(let e of[...r,...i])a.set(t(e),e);return[...a.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([,e])=>e)}export{n as buildDocsStaticParams};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e={kind:`notFound`},t=e=>e?.filter(e=>e.length>0)??[],n=(t,n,r)=>{if(!t)return e;let i=r.getEntry(t,n);return i?{kind:`page`,locale:t,slugSegments:n,href:i.href,entry:i}:e};function r({source:r,params:i={}}){let a=r.getDefaultLocale(),o=new Set(r.getLocaleCodes()),s=t(i.slug),[c,...l]=s;if(c&&o.has(c)){if(c===a){if(!r.isDefaultLocaleRedirectEnabled())return e;let t=r.getEntry(c,l);return t?{kind:`redirect`,locale:c,slugSegments:l,href:t.href,entry:t}:e}return n(c,l,r)}return n(a,s,r)}exports.resolveDocsRoute=r;
@@ -0,0 +1,35 @@
1
+
2
+ import { DocEntry, DocsSource } from "../source/types.mjs";
3
+
4
+ //#region src/routing/resolve-docs-route.d.ts
5
+ interface DocsRouteParams {
6
+ slug?: string[];
7
+ }
8
+ interface ResolveDocsRouteOptions {
9
+ source: DocsSource;
10
+ params?: DocsRouteParams;
11
+ }
12
+ interface ResolvedDocsPageRoute {
13
+ kind: 'page';
14
+ locale: string;
15
+ slugSegments: string[];
16
+ href: string;
17
+ entry: DocEntry;
18
+ }
19
+ interface ResolvedDocsRedirectRoute {
20
+ kind: 'redirect';
21
+ locale: string;
22
+ slugSegments: string[];
23
+ href: string;
24
+ entry: DocEntry;
25
+ }
26
+ interface ResolvedDocsNotFoundRoute {
27
+ kind: 'notFound';
28
+ }
29
+ type DocsRouteResolution = ResolvedDocsPageRoute | ResolvedDocsRedirectRoute | ResolvedDocsNotFoundRoute;
30
+ declare function resolveDocsRoute({
31
+ source,
32
+ params
33
+ }: ResolveDocsRouteOptions): DocsRouteResolution;
34
+ //#endregion
35
+ export { DocsRouteParams, DocsRouteResolution, ResolveDocsRouteOptions, ResolvedDocsNotFoundRoute, ResolvedDocsPageRoute, ResolvedDocsRedirectRoute, resolveDocsRoute };
@@ -0,0 +1,35 @@
1
+
2
+ import { DocEntry, DocsSource } from "../source/types.js";
3
+
4
+ //#region src/routing/resolve-docs-route.d.ts
5
+ interface DocsRouteParams {
6
+ slug?: string[];
7
+ }
8
+ interface ResolveDocsRouteOptions {
9
+ source: DocsSource;
10
+ params?: DocsRouteParams;
11
+ }
12
+ interface ResolvedDocsPageRoute {
13
+ kind: 'page';
14
+ locale: string;
15
+ slugSegments: string[];
16
+ href: string;
17
+ entry: DocEntry;
18
+ }
19
+ interface ResolvedDocsRedirectRoute {
20
+ kind: 'redirect';
21
+ locale: string;
22
+ slugSegments: string[];
23
+ href: string;
24
+ entry: DocEntry;
25
+ }
26
+ interface ResolvedDocsNotFoundRoute {
27
+ kind: 'notFound';
28
+ }
29
+ type DocsRouteResolution = ResolvedDocsPageRoute | ResolvedDocsRedirectRoute | ResolvedDocsNotFoundRoute;
30
+ declare function resolveDocsRoute({
31
+ source,
32
+ params
33
+ }: ResolveDocsRouteOptions): DocsRouteResolution;
34
+ //#endregion
35
+ export { DocsRouteParams, DocsRouteResolution, ResolveDocsRouteOptions, ResolvedDocsNotFoundRoute, ResolvedDocsPageRoute, ResolvedDocsRedirectRoute, resolveDocsRoute };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e={kind:`notFound`},t=e=>e?.filter(e=>e.length>0)??[],n=(t,n,r)=>{if(!t)return e;let i=r.getEntry(t,n);return i?{kind:`page`,locale:t,slugSegments:n,href:i.href,entry:i}:e};function r({source:r,params:i={}}){let a=r.getDefaultLocale(),o=new Set(r.getLocaleCodes()),s=t(i.slug),[c,...l]=s;if(c&&o.has(c)){if(c===a){if(!r.isDefaultLocaleRedirectEnabled())return e;let t=r.getEntry(c,l);return t?{kind:`redirect`,locale:c,slugSegments:l,href:t.href,entry:t}:e}return n(c,l,r)}return n(a,s,r)}export{r as resolveDocsRoute};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./mdx/default-docs-components.cjs`),t=require(`./mdx/merge-docs-components.cjs`);exports.defaultDocsComponents=e.defaultDocsComponents,exports.mergeDocsComponents=t.mergeDocsComponents;
@@ -0,0 +1,4 @@
1
+
2
+ import { defaultDocsComponents } from "./mdx/default-docs-components.mjs";
3
+ import { mergeDocsComponents } from "./mdx/merge-docs-components.mjs";
4
+ export { defaultDocsComponents, mergeDocsComponents };
@@ -0,0 +1,4 @@
1
+
2
+ import { defaultDocsComponents } from "./mdx/default-docs-components.js";
3
+ import { mergeDocsComponents } from "./mdx/merge-docs-components.js";
4
+ export { defaultDocsComponents, mergeDocsComponents };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{defaultDocsComponents as e}from"./mdx/default-docs-components.mjs";import{mergeDocsComponents as t}from"./mdx/merge-docs-components.mjs";export{e as defaultDocsComponents,t as mergeDocsComponents};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=e=>[...e].sort((e,t)=>{let n=e.order??1/0,r=t.order??1/0;return n===r?e.href.localeCompare(t.href):n-r}),t=(e,t=[],n)=>{let r=t.join(`/`);return e===n?r?`/${r}`:`/`:r?`/${e}/${r}`:`/${e}`},n=({defaultLocale:e,enableDefaultLocaleRedirect:t,locale:n,slugSegments:r=[]})=>{if(n!==e||!e||!t)return null;let i=r.join(`/`);return i?`/${n}/${i}`:`/${n}`},r=({defaultLocale:r,enableDefaultLocaleRedirect:i,entries:a,localeCodes:o})=>{let s=new Map;for(let t of o)s.set(t,e(a.filter(e=>e.locale===t)));let c=e=>s.get(e)??[];return{getAliasEntries(){return r?c(r).filter(e=>typeof e.legacyHref==`string`&&e.legacyHref.length>0):[]},getCanonicalHref(e,n=[]){return t(e,n,r)},getDefaultLocale(){return r},getEntries:c,getEntry(e,n=[]){let i=t(e,n,r);return c(e).find(e=>e.href===i)??null},isDefaultLocaleRedirectEnabled(){return i},getLegacyAliasHref(e,t=[]){return n({defaultLocale:r,enableDefaultLocaleRedirect:i,locale:e,slugSegments:t})},getLocaleCodes(){return[...o]}}};exports.buildDocsSource=r,exports.sortDocEntries=e;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=e=>[...e].sort((e,t)=>{let n=e.order??1/0,r=t.order??1/0;return n===r?e.href.localeCompare(t.href):n-r}),t=(e,t=[],n)=>{let r=t.join(`/`);return e===n?r?`/${r}`:`/`:r?`/${e}/${r}`:`/${e}`},n=({defaultLocale:e,enableDefaultLocaleRedirect:t,locale:n,slugSegments:r=[]})=>{if(n!==e||!e||!t)return null;let i=r.join(`/`);return i?`/${n}/${i}`:`/${n}`},r=({defaultLocale:r,enableDefaultLocaleRedirect:i,entries:a,localeCodes:o})=>{let s=new Map;for(let t of o)s.set(t,e(a.filter(e=>e.locale===t)));let c=e=>s.get(e)??[];return{getAliasEntries(){return r?c(r).filter(e=>typeof e.legacyHref==`string`&&e.legacyHref.length>0):[]},getCanonicalHref(e,n=[]){return t(e,n,r)},getDefaultLocale(){return r},getEntries:c,getEntry(e,n=[]){let i=t(e,n,r);return c(e).find(e=>e.href===i)??null},isDefaultLocaleRedirectEnabled(){return i},getLegacyAliasHref(e,t=[]){return n({defaultLocale:r,enableDefaultLocaleRedirect:i,locale:e,slugSegments:t})},getLocaleCodes(){return[...o]}}};export{r as buildDocsSource,e as sortDocEntries};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../config/define-config.cjs`),t=require(`./build-docs-source.cjs`);let n=require(`node:fs`),r=require(`node:path`),i=require(`@blackwork/machine/server`);const a=[`.mdx`,`.md`],o={md:1,mdx:2},s=e=>e.split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),c=e=>(0,n.statSync)(e,{throwIfNoEntry:!1})?.isDirectory()?(0,n.readdirSync)(e).flatMap(t=>{let i=(0,r.join)(e,t);return(0,n.statSync)(i).isDirectory()?c(i):[i]}):[],l=e=>(0,n.statSync)(e,{throwIfNoEntry:!1})?.isDirectory()?(0,n.readdirSync)(e).filter(t=>(0,n.statSync)((0,r.join)(e,t),{throwIfNoEntry:!1})?.isDirectory()):[],u=e=>e.endsWith(`.mdx`)?`mdx`:e.endsWith(`.md`)?`md`:null,d=e=>{for(let t of a)if(e.endsWith(t))return e.slice(0,-t.length);return e},f=(e,t)=>{let n=d((0,r.relative)(e,t)).split(/[/\\]/u).filter(Boolean);return n.at(-1)===`index`&&n.pop(),n},p=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}},m=(e,t,n)=>{let r=t.join(`/`);return e===n?r?`/${r}`:`/`:r?`/${e}/${r}`:`/${e}`},h=({defaultLocale:e,enableDefaultLocaleRedirect:t,locale:n,slugSegments:r})=>{if(n!==e||!e||!t)return null;let i=r.join(`/`);return i?`/${n}/${i}`:`/${n}`},g=({rootDir:a=`.`,config:d}={})=>{let g=e.defineConfig(d),_=(0,r.resolve)((0,r.resolve)(a),g.content.root),v=l(_),y=[...new Set([...g.content.defaultLocale?[g.content.defaultLocale]:[],...Object.entries(g.content.locales??{}).map(([e,t])=>t.code||e),...v])],b=[];for(let e of y){let a=(0,r.join)(_,e),l=new Map;for(let t of c(a)){let r=u(t);if(!r)continue;let{frontmatter:c}=(0,i.parseFrontmatter)((0,n.readFileSync)(t,`utf8`)),d=f(a,t),_=d.join(`/`)||`__index__`,v=typeof c.title==`string`&&c.title.trim()?c.title:d.length>0?s(d.at(-1)??`overview`):`Overview`,y=typeof c.description==`string`?c.description:typeof c.desc==`string`?c.desc:``,b={locale:e,slugSegments:d,href:m(e,d,g.content.defaultLocale),legacyHref:h({defaultLocale:g.content.defaultLocale,enableDefaultLocaleRedirect:g.content.enableDefaultLocaleRedirect,locale:e,slugSegments:d}),sourcePath:t,format:r,title:v,description:y,order:p(c.order),frontmatter:c},x=l.get(_);(!x||o[b.format]>o[x.format])&&l.set(_,b)}b.push(...t.sortDocEntries([...l.values()]))}return{defaultLocale:g.content.defaultLocale,enableDefaultLocaleRedirect:g.content.enableDefaultLocaleRedirect,entries:b,localeCodes:y}};exports.collectDocsManifest=g;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{defineConfig as e}from"../config/define-config.mjs";import{sortDocEntries as t}from"./build-docs-source.mjs";import{readFileSync as n,readdirSync as r,statSync as i}from"node:fs";import{join as a,relative as o,resolve as s}from"node:path";import{parseFrontmatter as c}from"@blackwork/machine/server";const l=[`.mdx`,`.md`],u={md:1,mdx:2},d=e=>e.split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),f=e=>i(e,{throwIfNoEntry:!1})?.isDirectory()?r(e).flatMap(t=>{let n=a(e,t);return i(n).isDirectory()?f(n):[n]}):[],p=e=>i(e,{throwIfNoEntry:!1})?.isDirectory()?r(e).filter(t=>i(a(e,t),{throwIfNoEntry:!1})?.isDirectory()):[],m=e=>e.endsWith(`.mdx`)?`mdx`:e.endsWith(`.md`)?`md`:null,h=e=>{for(let t of l)if(e.endsWith(t))return e.slice(0,-t.length);return e},g=(e,t)=>{let n=h(o(e,t)).split(/[/\\]/u).filter(Boolean);return n.at(-1)===`index`&&n.pop(),n},_=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}},v=(e,t,n)=>{let r=t.join(`/`);return e===n?r?`/${r}`:`/`:r?`/${e}/${r}`:`/${e}`},y=({defaultLocale:e,enableDefaultLocaleRedirect:t,locale:n,slugSegments:r})=>{if(n!==e||!e||!t)return null;let i=r.join(`/`);return i?`/${n}/${i}`:`/${n}`},b=({rootDir:r=`.`,config:i}={})=>{let o=e(i),l=s(s(r),o.content.root),h=p(l),b=[...new Set([...o.content.defaultLocale?[o.content.defaultLocale]:[],...Object.entries(o.content.locales??{}).map(([e,t])=>t.code||e),...h])],x=[];for(let e of b){let r=a(l,e),i=new Map;for(let t of f(r)){let a=m(t);if(!a)continue;let{frontmatter:s}=c(n(t,`utf8`)),l=g(r,t),f=l.join(`/`)||`__index__`,p=typeof s.title==`string`&&s.title.trim()?s.title:l.length>0?d(l.at(-1)??`overview`):`Overview`,h=typeof s.description==`string`?s.description:typeof s.desc==`string`?s.desc:``,b={locale:e,slugSegments:l,href:v(e,l,o.content.defaultLocale),legacyHref:y({defaultLocale:o.content.defaultLocale,enableDefaultLocaleRedirect:o.content.enableDefaultLocaleRedirect,locale:e,slugSegments:l}),sourcePath:t,format:a,title:p,description:h,order:_(s.order),frontmatter:s},x=i.get(f);(!x||u[b.format]>u[x.format])&&i.set(f,b)}x.push(...t([...i.values()]))}return{defaultLocale:o.content.defaultLocale,enableDefaultLocaleRedirect:o.content.enableDefaultLocaleRedirect,entries:x,localeCodes:b}};export{b as collectDocsManifest};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ const e=require(`./build-docs-source.cjs`),t=t=>e.buildDocsSource(t);exports.createDocsSourceFromManifest=t;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * name: @blackwork/docs
3
+ * version: v0.1.0
4
+ * description: Next-first documentation framework for Blackwork projects.
5
+ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>
6
+ * homepage: https://chengpeiquan.com
7
+ * license: MIT
8
+ */
9
+ import{buildDocsSource as e}from"./build-docs-source.mjs";const t=t=>e(t);export{t as createDocsSourceFromManifest};