@umami/shiso 0.5.0 → 0.7.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.
package/dist/index.css CHANGED
@@ -1,6 +1,6 @@
1
- /* virtual-css:css:943a368a754a0f9e78019e2a7170fc27 */
2
- /* virtual-css:css:3bad70522881721e67eb254a54940e2f */
3
- .CodeBlock_container__ZWQ3M {
1
+ /* virtual-css:css:32abd77818c5161a011a843897f34903 */
2
+ /* virtual-css:css:2dd9c1a25bf05a14c9a7ab7ce1da6aef */
3
+ .CodeBlock_container__ZTkxY {
4
4
  position: relative;
5
5
  background: var(--base-color-900);
6
6
  padding: var(--spacing-5);
@@ -8,14 +8,14 @@
8
8
  white-space: pre-wrap;
9
9
  word-wrap: break-word;
10
10
  }
11
- pre.CodeBlock_container__ZWQ3M code {
11
+ pre.CodeBlock_container__ZTkxY code {
12
12
  font-family: var(--font-family-code);
13
13
  color: var(--base-color-300);
14
14
  padding: 0;
15
15
  border: 0;
16
16
  background: transparent;
17
17
  }
18
- .CodeBlock_button__YzlkO {
18
+ .CodeBlock_button__MmZkO {
19
19
  border: 0;
20
20
  position: absolute;
21
21
  right: var(--spacing-5);
@@ -23,132 +23,132 @@ pre.CodeBlock_container__ZWQ3M code {
23
23
  cursor: pointer;
24
24
  background: transparent;
25
25
  }
26
- .CodeBlock_copy__MGRjZ {
26
+ .CodeBlock_copy__M2I0N {
27
27
  color: var(--base-color-300);
28
28
  }
29
- .CodeBlock_copy__MGRjZ:hover {
29
+ .CodeBlock_copy__M2I0N:hover {
30
30
  color: var(--base-color-50);
31
31
  }
32
- .CodeBlock_check__YTZlN {
32
+ .CodeBlock_check__MjkzY {
33
33
  color: var(--success-color);
34
34
  }
35
35
 
36
- /* virtual-css:css:bdddb2ea104dd6a71620fa4540713b02 */
37
- .PageLinks_title__NDFiN {
36
+ /* virtual-css:css:e01d9571088b882a03b91eb2755da783 */
37
+ .PageLinks_title__NTM5N {
38
38
  position: sticky;
39
39
  top: 0;
40
40
  }
41
- .PageLinks_links__NDRmO {
41
+ .PageLinks_links__ODg1Z {
42
42
  position: sticky;
43
43
  top: 30px;
44
44
  height: max-content;
45
45
  }
46
- .PageLinks_links__NDRmO a {
46
+ .PageLinks_links__ODg1Z a {
47
47
  display: block;
48
48
  color: var(--font-muted-color);
49
49
  text-wrap: nowrap;
50
50
  text-decoration: none;
51
51
  }
52
- .PageLinks_links__NDRmO a:hover {
52
+ .PageLinks_links__ODg1Z a:hover {
53
53
  color: var(--primary-color);
54
54
  }
55
- .PageLinks_indent-1__ODFiY {
55
+ .PageLinks_indent-1__OGVmN {
56
56
  margin-left: 0;
57
57
  }
58
- .PageLinks_indent-2__OTFkY {
58
+ .PageLinks_indent-2__YTFmN {
59
59
  margin-left: 0;
60
60
  }
61
- .PageLinks_indent-3__ZGM3O {
61
+ .PageLinks_indent-3__OTI0Y {
62
62
  margin-left: 10px;
63
63
  }
64
- .PageLinks_indent-4__Y2U0M {
64
+ .PageLinks_indent-4__NzhkM {
65
65
  margin-left: 20px;
66
66
  }
67
- .PageLinks_indent-5__MzUwM {
67
+ .PageLinks_indent-5__ZGViZ {
68
68
  margin-left: 30px;
69
69
  }
70
- .PageLinks_indent-6__ZTQ4M {
70
+ .PageLinks_indent-6__YjVkN {
71
71
  margin-left: 40px;
72
72
  }
73
- a.PageLinks_selected__MDVlN {
73
+ a.PageLinks_selected__YzEyZ {
74
74
  color: var(--primary-color);
75
75
  }
76
76
 
77
- /* virtual-css:css:ae384b93271e0eccb1944349dfa96582 */
78
- .SideNav_nav__NmRlZ {
77
+ /* virtual-css:css:62c31e195181c97259fa56b13d20ea6d */
78
+ .SideNav_nav__NmU4M {
79
79
  position: sticky;
80
80
  top: 30px;
81
81
  height: max-content;
82
82
  }
83
- .SideNav_item__ZmExN {
83
+ .SideNav_item__MGIzZ {
84
84
  color: var(--font-muted-color);
85
85
  padding: 0;
86
86
  border-radius: 0;
87
87
  border-left: var(--border-size-1) solid var(--border-color);
88
88
  }
89
- .SideNav_item__ZmExN a {
89
+ .SideNav_item__MGIzZ a {
90
90
  color: currentColor;
91
91
  width: 100%;
92
92
  padding: var(--padding-y) var(--padding-x);
93
93
  text-decoration: none;
94
94
  }
95
- .SideNav_item__ZmExN a:hover {
95
+ .SideNav_item__MGIzZ a:hover {
96
96
  color: var(--primary-color);
97
97
  }
98
- .SideNav_item__ZmExN.SideNav_selected__Y2U0Y {
98
+ .SideNav_item__MGIzZ.SideNav_selected__NDEwO {
99
99
  color: var(--font-color);
100
100
  border-color: var(--primary-color);
101
101
  }
102
- .SideNav_items__MWIxZ header {
102
+ .SideNav_items__ZGVhM header {
103
103
  padding: var(--padding-y) 0;
104
104
  }
105
105
 
106
- /* virtual-css:css:cfe8b8b36b207068aec9d9119cf71383 */
107
- .ContentArea_content__YzBjN {
106
+ /* virtual-css:css:71a58b2dae0a60276640236977b24d42 */
107
+ .ContentArea_content__MWQ1Z {
108
108
  font-size: 16px;
109
109
  margin-bottom: 60px;
110
110
  }
111
- .ContentArea_content__YzBjN > p {
111
+ .ContentArea_content__MWQ1Z > p {
112
112
  color: var(--font-muted-color);
113
113
  line-height: 1.8;
114
114
  }
115
- .ContentArea_content__YzBjN a {
115
+ .ContentArea_content__MWQ1Z a {
116
116
  color: var(--font-color);
117
117
  font-weight: 600;
118
118
  text-decoration: underline var(--font-faded-color);
119
119
  text-underline-offset: 4px;
120
120
  }
121
- .ContentArea_content__YzBjN a:hover {
121
+ .ContentArea_content__MWQ1Z a:hover {
122
122
  text-decoration: underline var(--font-color);
123
123
  }
124
- .ContentArea_content__YzBjN h1 {
124
+ .ContentArea_content__MWQ1Z h1 {
125
125
  font-size: var(--font-size-8);
126
126
  letter-spacing: var(--letter-spacing-1);
127
127
  margin: 0 0 var(--spacing-4) 0;
128
128
  }
129
- .ContentArea_content__YzBjN h2 {
129
+ .ContentArea_content__MWQ1Z h2 {
130
130
  font-size: var(--font-size-6);
131
131
  letter-spacing: var(--letter-spacing-1);
132
132
  margin: var(--spacing-8) 0 var(--spacing-4) 0;
133
133
  }
134
- .ContentArea_content__YzBjN h3 {
134
+ .ContentArea_content__MWQ1Z h3 {
135
135
  font-size: var(--font-size-5);
136
136
  letter-spacing: var(--letter-spacing-1);
137
137
  margin: var(--spacing-7) 0 var(--spacing-4) 0;
138
138
  }
139
- .ContentArea_content__YzBjN ul {
139
+ .ContentArea_content__MWQ1Z ul {
140
140
  list-style: disc;
141
141
  }
142
- .ContentArea_content__YzBjN ol {
142
+ .ContentArea_content__MWQ1Z ol {
143
143
  list-style: decimal;
144
144
  }
145
- .ContentArea_content__YzBjN pre {
145
+ .ContentArea_content__MWQ1Z pre {
146
146
  margin: var(--spacing-5) 0;
147
147
  }
148
- .ContentArea_content__YzBjN code {
148
+ .ContentArea_content__MWQ1Z code {
149
149
  font-size: 14px;
150
150
  }
151
- .ContentArea_content__YzBjN code:not([class]) {
151
+ .ContentArea_content__MWQ1Z code:not([class]) {
152
152
  font-family: var(--font-family-code);
153
153
  color: var(--font-color);
154
154
  padding: var(--spacing-1);
package/dist/index.d.ts CHANGED
@@ -3,17 +3,12 @@
3
3
  // ../../react
4
4
 
5
5
  declare module '@umami/shiso' {
6
- export * from '@umami/shiso/blog/Blog';
7
- export * from '@umami/shiso/docs/Callout';
8
- export * from '@umami/shiso/docs/CodeBlock';
9
- export * from '@umami/shiso/docs/Docs';
10
- export * from '@umami/shiso/docs/SideNav';
11
- export * from '@umami/shiso/docs/Note';
12
- export * from '@umami/shiso/docs/PageLinks';
13
- export * from '@umami/shiso/docs/TopNav';
6
+ import { Blog } from '@umami/shiso/Blog';
7
+ import { Docs } from '@umami/shiso/Docs';
8
+ export { Blog, Docs };
14
9
  }
15
10
 
16
- declare module '@umami/shiso/blog/Blog' {
11
+ declare module '@umami/shiso/Blog' {
17
12
  export interface BlogProps {
18
13
  content: any;
19
14
  config: any;
@@ -21,55 +16,16 @@ declare module '@umami/shiso/blog/Blog' {
21
16
  export function Blog({ content }: BlogProps): import("react").JSX.Element;
22
17
  }
23
18
 
24
- declare module '@umami/shiso/docs/Callout' {
25
- import { ReactNode } from 'react';
26
- export interface CalloutProps {
27
- variant: 'note' | 'warning' | 'info' | 'tip';
28
- icon?: ReactNode;
29
- children: ReactNode;
30
- }
31
- export default function Callout({ variant, icon, children }: CalloutProps): import("react").JSX.Element;
32
- }
33
-
34
- declare module '@umami/shiso/docs/CodeBlock' {
35
- export function CodeBlock(props: any): import("react").JSX.Element;
36
- }
37
-
38
- declare module '@umami/shiso/docs/Docs' {
19
+ declare module '@umami/shiso/Docs' {
39
20
  import { ShisoConfig } from '@umami/shiso/Shiso';
40
- export interface contentsProps {
21
+ export interface DocsProps {
41
22
  config: ShisoConfig;
42
23
  content: any;
24
+ components?: {
25
+ [key: string]: any;
26
+ };
43
27
  }
44
- export function Docs({ content, config }: contentsProps): import("react").JSX.Element;
45
- }
46
-
47
- declare module '@umami/shiso/docs/SideNav' {
48
- import React from 'react';
49
- export interface SideNavProps {
50
- tabs: any;
51
- navigation: any;
52
- }
53
- export default function SideNav({ tabs, navigation }: SideNavProps): React.JSX.Element;
54
- }
55
-
56
- declare module '@umami/shiso/docs/Note' {
57
- export function Note({ children }: {
58
- children: React.ReactNode;
59
- }): import("react").JSX.Element;
60
- }
61
-
62
- declare module '@umami/shiso/docs/PageLinks' {
63
- export default function PageLinks({ items, offset }: {
64
- items: any;
65
- offset?: number | undefined;
66
- }): import("react").JSX.Element | null;
67
- }
68
-
69
- declare module '@umami/shiso/docs/TopNav' {
70
- export default function TopNav({ tabs }: {
71
- tabs: any;
72
- }): import("react").JSX.Element;
28
+ export function Docs({ content, config, components }: DocsProps): import("react").JSX.Element;
73
29
  }
74
30
 
75
31
  declare module '@umami/shiso/Shiso' {
@@ -84,12 +40,15 @@ declare module '@umami/shiso/Shiso' {
84
40
  };
85
41
  }
86
42
  export interface ShisoProps {
43
+ content: string;
44
+ type: string;
87
45
  config: ShisoConfig;
46
+ components?: {
47
+ [key: string]: any;
48
+ };
88
49
  children: ReactNode;
89
50
  }
90
- export const ShisoContext: import("react").Context<{
91
- config: ShisoConfig;
92
- }>;
93
- export function Shiso({ config, children }: ShisoProps): import("react").JSX.Element;
51
+ export const ShisoContext: import("react").Context<any>;
52
+ export function Shiso({ content, type, config, components, children }: ShisoProps): import("react").JSX.Element;
94
53
  }
95
54
 
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -27,32 +28,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
28
  ));
28
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
30
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ // src/components/index.ts
32
+ var index_exports = {};
33
+ __export(index_exports, {
33
34
  Blog: () => Blog,
34
- Docs: () => Docs,
35
- next: () => next_default
35
+ Docs: () => Docs
36
36
  });
37
- module.exports = __toCommonJS(src_exports);
37
+ module.exports = __toCommonJS(index_exports);
38
38
 
39
- // css-modules:E:\dev\umami-shiso\src\components\blog\Blog.module.css
39
+ // css-modules:E:\dev\umami-shiso\src\components\Blog.module.css
40
40
  var Blog_default = {};
41
41
 
42
42
  // src/components/Markdown.tsx
43
- var import_rsc = require("next-mdx-remote/rsc");
44
- var import_remark_gfm = __toESM(require("remark-gfm"));
45
- var import_rehype_highlight = __toESM(require("rehype-highlight"));
46
- var import_link = __toESM(require("next/link"));
43
+ var import_next_mdx_remote = require("next-mdx-remote");
47
44
 
48
- // src/components/docs/CodeBlock.tsx
45
+ // src/components/CodeBlock.tsx
49
46
  var import_react = require("react");
50
47
  var import_react_zen = require("@umami/react-zen");
51
48
 
52
- // css-modules:E:\dev\umami-shiso\src\components\docs\CodeBlock.module.css
53
- var CodeBlock_default = { "container": "CodeBlock_container__ZWQ3M", "button": "CodeBlock_button__YzlkO", "copy": "CodeBlock_copy__MGRjZ", "check": "CodeBlock_check__YTZlN" };
49
+ // css-modules:E:\dev\umami-shiso\src\components\CodeBlock.module.css
50
+ var CodeBlock_default = { "container": "CodeBlock_container__ZTkxY", "button": "CodeBlock_button__MmZkO", "copy": "CodeBlock_copy__M2I0N", "check": "CodeBlock_check__MjkzY" };
54
51
 
55
- // src/components/docs/CodeBlock.tsx
52
+ // src/components/CodeBlock.tsx
56
53
  var import_jsx_runtime = require("react/jsx-runtime");
57
54
  function CodeBlock(props) {
58
55
  const textInput = (0, import_react.useRef)(null);
@@ -72,42 +69,44 @@ function CodeBlock(props) {
72
69
 
73
70
  // src/components/Markdown.tsx
74
71
  var import_jsx_runtime2 = require("react/jsx-runtime");
75
- var options = {
76
- mdxOptions: {
77
- remarkPlugins: [import_remark_gfm.default],
78
- rehypePlugins: [import_rehype_highlight.default]
79
- }
80
- };
81
- var components = {
82
- a: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_link.default, { ...props }),
83
- pre: CodeBlock
84
- };
85
- function Markdown({ children }) {
86
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_rsc.MDXRemote, { source: children, components, options });
72
+ function Markdown({
73
+ content,
74
+ components,
75
+ scope
76
+ }) {
77
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
78
+ import_next_mdx_remote.MDXRemote,
79
+ {
80
+ compiledSource: content.code,
81
+ frontmatter: content.frontmatter,
82
+ scope,
83
+ components: { ...components, pre: CodeBlock }
84
+ }
85
+ );
87
86
  }
88
87
 
89
- // src/components/blog/Blog.tsx
88
+ // src/components/Blog.tsx
90
89
  var import_jsx_runtime3 = require("react/jsx-runtime");
91
90
  function Blog({ content }) {
92
91
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: Blog_default.blog, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: Blog_default.main, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: Blog_default.content, children: [
93
92
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: content?.meta?.title }),
94
93
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: Blog_default.description, children: content?.meta?.description }),
95
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { children: content?.body })
94
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { content })
96
95
  ] }) }) });
97
96
  }
98
97
 
99
- // src/components/docs/Docs.tsx
98
+ // src/components/Docs.tsx
100
99
  var import_react_zen6 = require("@umami/react-zen");
101
100
 
102
- // src/components/docs/PageLinks.tsx
101
+ // src/components/PageLinks.tsx
103
102
  var import_react2 = require("react");
104
103
  var import_react_zen2 = require("@umami/react-zen");
105
104
  var import_classnames = __toESM(require("classnames"));
106
105
 
107
- // css-modules:E:\dev\umami-shiso\src\components\docs\PageLinks.module.css
108
- var PageLinks_default = { "title": "PageLinks_title__NDFiN", "links": "PageLinks_links__NDRmO", "indent-1": "PageLinks_indent-1__ODFiY", "indent-2": "PageLinks_indent-2__OTFkY", "indent-3": "PageLinks_indent-3__ZGM3O", "indent-4": "PageLinks_indent-4__Y2U0M", "indent-5": "PageLinks_indent-5__MzUwM", "indent-6": "PageLinks_indent-6__ZTQ4M", "selected": "PageLinks_selected__MDVlN" };
106
+ // css-modules:E:\dev\umami-shiso\src\components\PageLinks.module.css
107
+ var PageLinks_default = { "title": "PageLinks_title__NTM5N", "links": "PageLinks_links__ODg1Z", "indent-1": "PageLinks_indent-1__OGVmN", "indent-2": "PageLinks_indent-2__YTFmN", "indent-3": "PageLinks_indent-3__OTI0Y", "indent-4": "PageLinks_indent-4__NzhkM", "indent-5": "PageLinks_indent-5__ZGViZ", "indent-6": "PageLinks_indent-6__YjVkN", "selected": "PageLinks_selected__YzEyZ" };
109
108
 
110
- // src/components/docs/PageLinks.tsx
109
+ // src/components/PageLinks.tsx
111
110
  var import_jsx_runtime4 = require("react/jsx-runtime");
112
111
  function PageLinks({ items, offset = 0 }) {
113
112
  const [hash, setHash] = (0, import_react2.useState)(items?.[0]?.id);
@@ -143,16 +142,16 @@ function PageLinks({ items, offset = 0 }) {
143
142
  ] });
144
143
  }
145
144
 
146
- // src/components/docs/SideNav.tsx
145
+ // src/components/SideNav.tsx
147
146
  var import_react_zen3 = require("@umami/react-zen");
148
147
  var import_classnames2 = __toESM(require("classnames"));
149
148
  var import_navigation = require("next/navigation");
150
- var import_link2 = __toESM(require("next/link"));
149
+ var import_link = __toESM(require("next/link"));
151
150
 
152
- // css-modules:E:\dev\umami-shiso\src\components\docs\SideNav.module.css
153
- var SideNav_default = { "nav": "SideNav_nav__NmRlZ", "item": "SideNav_item__ZmExN", "selected": "SideNav_selected__Y2U0Y", "items": "SideNav_items__MWIxZ" };
151
+ // css-modules:E:\dev\umami-shiso\src\components\SideNav.module.css
152
+ var SideNav_default = { "nav": "SideNav_nav__NmU4M", "item": "SideNav_item__MGIzZ", "selected": "SideNav_selected__NDEwO", "items": "SideNav_items__ZGVhM" };
154
153
 
155
- // src/components/docs/SideNav.tsx
154
+ // src/components/SideNav.tsx
156
155
  var import_jsx_runtime5 = require("react/jsx-runtime");
157
156
  function SideNav({ tabs, navigation }) {
158
157
  const pathname = (0, import_navigation.usePathname)();
@@ -166,7 +165,7 @@ function SideNav({ tabs, navigation }) {
166
165
  className: (0, import_classnames2.default)(SideNav_default.item, {
167
166
  [SideNav_default.selected]: url === pathname
168
167
  }),
169
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_link2.default, { href: url, prefetch: false, children: text })
168
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_link.default, { href: url, prefetch: false, children: text })
170
169
  },
171
170
  index
172
171
  );
@@ -174,8 +173,8 @@ function SideNav({ tabs, navigation }) {
174
173
  }) }) });
175
174
  }
176
175
 
177
- // src/components/docs/TopNav.tsx
178
- var import_link3 = __toESM(require("next/link"));
176
+ // src/components/TopNav.tsx
177
+ var import_link2 = __toESM(require("next/link"));
179
178
  var import_navigation2 = require("next/navigation");
180
179
  var import_react_zen4 = require("@umami/react-zen");
181
180
  var import_jsx_runtime6 = require("react/jsx-runtime");
@@ -184,30 +183,30 @@ function TopNav({ tabs }) {
184
183
  const tab = tabs.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
185
184
  const selected = tab?.id || "docs";
186
185
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen4.Tabs, { selectedKey: selected, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen4.TabList, { items: tabs, children: ({ id, label, url }) => {
187
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen4.Tab, { id, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_link3.default, { href: url, children: label }) });
186
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen4.Tab, { id, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_link2.default, { href: url, children: label }) });
188
187
  } }) });
189
188
  }
190
189
 
191
- // src/components/docs/ContentArea.tsx
190
+ // src/components/ContentArea.tsx
192
191
  var import_react_zen5 = require("@umami/react-zen");
193
192
 
194
- // css-modules:E:\dev\umami-shiso\src\components\docs\ContentArea.module.css
195
- var ContentArea_default = { "content": "ContentArea_content__YzBjN" };
193
+ // css-modules:E:\dev\umami-shiso\src\components\ContentArea.module.css
194
+ var ContentArea_default = { "content": "ContentArea_content__MWQ1Z" };
196
195
 
197
- // src/components/docs/ContentArea.tsx
196
+ // src/components/ContentArea.tsx
198
197
  var import_jsx_runtime7 = require("react/jsx-runtime");
199
- function ContentArea({ title, description, group, body }) {
198
+ function ContentArea({ content, components }) {
200
199
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_zen5.Box, { flexGrow: 1, children: [
201
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Text, { color: "primary", weight: "bold", children: group }),
202
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Heading, { size: "8", as: "h1", children: title }),
203
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Text, { type: "muted", children: description }),
204
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Box, { className: ContentArea_default.content, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Markdown, { children: body }) })
200
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Text, { color: "primary", weight: "bold", children: content.group }),
201
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Heading, { size: "8", as: "h1", children: content.meta.title }),
202
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Text, { type: "muted", children: content.meta.description }),
203
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen5.Box, { className: ContentArea_default.content, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Markdown, { content, components }) })
205
204
  ] });
206
205
  }
207
206
 
208
- // src/components/docs/Docs.tsx
207
+ // src/components/Docs.tsx
209
208
  var import_jsx_runtime8 = require("react/jsx-runtime");
210
- function Docs({ content, config }) {
209
+ function Docs({ content, config, components }) {
211
210
  if (!content) {
212
211
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen6.Heading, { size: "6", children: "Page not found" });
213
212
  }
@@ -226,105 +225,13 @@ function Docs({ content, config }) {
226
225
  tabs && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TopNav, { tabs }),
227
226
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_zen6.Grid, { gap: "6", columns: "240px 1fr 240px", children: [
228
227
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SideNav, { tabs, navigation }),
229
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
230
- ContentArea,
231
- {
232
- title: content?.meta?.title,
233
- body: content?.body,
234
- group: content?.group,
235
- description: content?.meta?.description
236
- }
237
- ),
228
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContentArea, { content, components }),
238
229
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PageLinks, { items: content?.anchors, offset: 150 })
239
230
  ] })
240
231
  ] });
241
232
  }
242
-
243
- // src/lib/next.tsx
244
- var import_node_path2 = __toESM(require("node:path"));
245
-
246
- // src/lib/content.ts
247
- var import_react3 = require("react");
248
- var import_gray_matter = __toESM(require("gray-matter"));
249
- var import_recursive_readdir = __toESM(require("recursive-readdir"));
250
- var import_thenby = require("thenby");
251
- var import_promises = __toESM(require("node:fs/promises"));
252
- var import_node_path = __toESM(require("node:path"));
253
- var getFiles = (0, import_react3.cache)(async (folder) => {
254
- const dir = import_node_path.default.resolve(folder);
255
- const files = await (0, import_recursive_readdir.default)(dir);
256
- return Promise.all(
257
- files.filter((file) => import_node_path.default.extname(file) === ".mdx").map(async (file) => {
258
- const postContent = await import_promises.default.readFile(file, "utf8");
259
- const { data, content } = (0, import_gray_matter.default)(postContent);
260
- const id = file.replace(".mdx", "").replace(dir, "").replace(/\\/g, "/").replace(/^\//, "");
261
- const anchors = [];
262
- const body = content.split("\n").map((line) => {
263
- const match = line.match(/(#+)\s+(.*)/);
264
- if (match) {
265
- const [, num, name] = match;
266
- const id2 = name.toLowerCase().replace(/\s+/g, "-");
267
- const size = num.length;
268
- anchors.push({ name, id: id2, size });
269
- return `<h${size} id="${id2}">${name.replace(/\{|\}/g, "")}</h${size}>`;
270
- }
271
- return line;
272
- }).join("\n");
273
- return {
274
- meta: data,
275
- id,
276
- body,
277
- anchors
278
- };
279
- })
280
- ).then((posts) => posts.sort((0, import_thenby.firstBy)("date", "desc")));
281
- });
282
- async function getFile(id, folder) {
283
- const files = await getFiles(folder);
284
- return files.find((file) => file?.id === id);
285
- }
286
- async function getContent(params, folder) {
287
- const { id = [] } = params;
288
- const name = id?.length ? id.join("/") : "index";
289
- return getFile(name, folder);
290
- }
291
-
292
- // src/lib/next.tsx
293
- var import_jsx_runtime9 = require("react/jsx-runtime");
294
- var DEFAULT_CONTENT_DIR = "./src/content";
295
- var components2 = {
296
- docs: Docs,
297
- blog: Blog
298
- };
299
- var next_default = (config) => {
300
- const { contentDir = DEFAULT_CONTENT_DIR } = config || {};
301
- const getMetadata = ({ title }) => {
302
- return async ({ params }) => {
303
- const content = await getContent(await params, contentDir);
304
- return {
305
- title: {
306
- absolute: `${content?.meta?.title} \u2013 ${title}`,
307
- default: title
308
- }
309
- };
310
- };
311
- };
312
- const renderPage = ({ type }) => {
313
- const folder = import_node_path2.default.resolve(process.cwd(), contentDir, type);
314
- return async ({ params }) => {
315
- const content = await getContent(await params, folder);
316
- const Component = components2[type];
317
- return Component && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Component, { content, config });
318
- };
319
- };
320
- return {
321
- getMetadata,
322
- renderPage
323
- };
324
- };
325
233
  // Annotate the CommonJS export names for ESM import in node:
326
234
  0 && (module.exports = {
327
235
  Blog,
328
- Docs,
329
- next
236
+ Docs
330
237
  });
package/dist/index.mjs CHANGED
@@ -1,20 +1,19 @@
1
- // css-modules:E:\dev\umami-shiso\src\components\blog\Blog.module.css
1
+ "use client";
2
+
3
+ // css-modules:E:\dev\umami-shiso\src\components\Blog.module.css
2
4
  var Blog_default = {};
3
5
 
4
6
  // src/components/Markdown.tsx
5
- import { MDXRemote } from "next-mdx-remote/rsc";
6
- import remarkGfm from "remark-gfm";
7
- import rehypeHighlight from "rehype-highlight";
8
- import Link from "next/link";
7
+ import { MDXRemote } from "next-mdx-remote";
9
8
 
10
- // src/components/docs/CodeBlock.tsx
9
+ // src/components/CodeBlock.tsx
11
10
  import { useState, useRef } from "react";
12
11
  import { Icon, Icons } from "@umami/react-zen";
13
12
 
14
- // css-modules:E:\dev\umami-shiso\src\components\docs\CodeBlock.module.css
15
- var CodeBlock_default = { "container": "CodeBlock_container__ZWQ3M", "button": "CodeBlock_button__YzlkO", "copy": "CodeBlock_copy__MGRjZ", "check": "CodeBlock_check__YTZlN" };
13
+ // css-modules:E:\dev\umami-shiso\src\components\CodeBlock.module.css
14
+ var CodeBlock_default = { "container": "CodeBlock_container__ZTkxY", "button": "CodeBlock_button__MmZkO", "copy": "CodeBlock_copy__M2I0N", "check": "CodeBlock_check__MjkzY" };
16
15
 
17
- // src/components/docs/CodeBlock.tsx
16
+ // src/components/CodeBlock.tsx
18
17
  import { jsx, jsxs } from "react/jsx-runtime";
19
18
  function CodeBlock(props) {
20
19
  const textInput = useRef(null);
@@ -34,42 +33,44 @@ function CodeBlock(props) {
34
33
 
35
34
  // src/components/Markdown.tsx
36
35
  import { jsx as jsx2 } from "react/jsx-runtime";
37
- var options = {
38
- mdxOptions: {
39
- remarkPlugins: [remarkGfm],
40
- rehypePlugins: [rehypeHighlight]
41
- }
42
- };
43
- var components = {
44
- a: (props) => /* @__PURE__ */ jsx2(Link, { ...props }),
45
- pre: CodeBlock
46
- };
47
- function Markdown({ children }) {
48
- return /* @__PURE__ */ jsx2(MDXRemote, { source: children, components, options });
36
+ function Markdown({
37
+ content,
38
+ components,
39
+ scope
40
+ }) {
41
+ return /* @__PURE__ */ jsx2(
42
+ MDXRemote,
43
+ {
44
+ compiledSource: content.code,
45
+ frontmatter: content.frontmatter,
46
+ scope,
47
+ components: { ...components, pre: CodeBlock }
48
+ }
49
+ );
49
50
  }
50
51
 
51
- // src/components/blog/Blog.tsx
52
+ // src/components/Blog.tsx
52
53
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
53
54
  function Blog({ content }) {
54
55
  return /* @__PURE__ */ jsx3("div", { className: Blog_default.blog, children: /* @__PURE__ */ jsx3("div", { className: Blog_default.main, children: /* @__PURE__ */ jsxs2("div", { className: Blog_default.content, children: [
55
56
  /* @__PURE__ */ jsx3("h1", { children: content?.meta?.title }),
56
57
  /* @__PURE__ */ jsx3("p", { className: Blog_default.description, children: content?.meta?.description }),
57
- /* @__PURE__ */ jsx3(Markdown, { children: content?.body })
58
+ /* @__PURE__ */ jsx3(Markdown, { content })
58
59
  ] }) }) });
59
60
  }
60
61
 
61
- // src/components/docs/Docs.tsx
62
+ // src/components/Docs.tsx
62
63
  import { Grid, Box as Box3, Heading as Heading2 } from "@umami/react-zen";
63
64
 
64
- // src/components/docs/PageLinks.tsx
65
+ // src/components/PageLinks.tsx
65
66
  import { useEffect, useState as useState2 } from "react";
66
67
  import { Column, Text } from "@umami/react-zen";
67
68
  import classNames from "classnames";
68
69
 
69
- // css-modules:E:\dev\umami-shiso\src\components\docs\PageLinks.module.css
70
- var PageLinks_default = { "title": "PageLinks_title__NDFiN", "links": "PageLinks_links__NDRmO", "indent-1": "PageLinks_indent-1__ODFiY", "indent-2": "PageLinks_indent-2__OTFkY", "indent-3": "PageLinks_indent-3__ZGM3O", "indent-4": "PageLinks_indent-4__Y2U0M", "indent-5": "PageLinks_indent-5__MzUwM", "indent-6": "PageLinks_indent-6__ZTQ4M", "selected": "PageLinks_selected__MDVlN" };
70
+ // css-modules:E:\dev\umami-shiso\src\components\PageLinks.module.css
71
+ var PageLinks_default = { "title": "PageLinks_title__NTM5N", "links": "PageLinks_links__ODg1Z", "indent-1": "PageLinks_indent-1__OGVmN", "indent-2": "PageLinks_indent-2__YTFmN", "indent-3": "PageLinks_indent-3__OTI0Y", "indent-4": "PageLinks_indent-4__NzhkM", "indent-5": "PageLinks_indent-5__ZGViZ", "indent-6": "PageLinks_indent-6__YjVkN", "selected": "PageLinks_selected__YzEyZ" };
71
72
 
72
- // src/components/docs/PageLinks.tsx
73
+ // src/components/PageLinks.tsx
73
74
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
74
75
  function PageLinks({ items, offset = 0 }) {
75
76
  const [hash, setHash] = useState2(items?.[0]?.id);
@@ -105,16 +106,16 @@ function PageLinks({ items, offset = 0 }) {
105
106
  ] });
106
107
  }
107
108
 
108
- // src/components/docs/SideNav.tsx
109
+ // src/components/SideNav.tsx
109
110
  import { Box, List, ListItem, ListSection } from "@umami/react-zen";
110
111
  import classNames2 from "classnames";
111
112
  import { usePathname } from "next/navigation";
112
- import Link2 from "next/link";
113
+ import Link from "next/link";
113
114
 
114
- // css-modules:E:\dev\umami-shiso\src\components\docs\SideNav.module.css
115
- var SideNav_default = { "nav": "SideNav_nav__NmRlZ", "item": "SideNav_item__ZmExN", "selected": "SideNav_selected__Y2U0Y", "items": "SideNav_items__MWIxZ" };
115
+ // css-modules:E:\dev\umami-shiso\src\components\SideNav.module.css
116
+ var SideNav_default = { "nav": "SideNav_nav__NmU4M", "item": "SideNav_item__MGIzZ", "selected": "SideNav_selected__NDEwO", "items": "SideNav_items__ZGVhM" };
116
117
 
117
- // src/components/docs/SideNav.tsx
118
+ // src/components/SideNav.tsx
118
119
  import { jsx as jsx5 } from "react/jsx-runtime";
119
120
  function SideNav({ tabs, navigation }) {
120
121
  const pathname = usePathname();
@@ -128,7 +129,7 @@ function SideNav({ tabs, navigation }) {
128
129
  className: classNames2(SideNav_default.item, {
129
130
  [SideNav_default.selected]: url === pathname
130
131
  }),
131
- children: /* @__PURE__ */ jsx5(Link2, { href: url, prefetch: false, children: text })
132
+ children: /* @__PURE__ */ jsx5(Link, { href: url, prefetch: false, children: text })
132
133
  },
133
134
  index
134
135
  );
@@ -136,8 +137,8 @@ function SideNav({ tabs, navigation }) {
136
137
  }) }) });
137
138
  }
138
139
 
139
- // src/components/docs/TopNav.tsx
140
- import Link3 from "next/link";
140
+ // src/components/TopNav.tsx
141
+ import Link2 from "next/link";
141
142
  import { usePathname as usePathname2 } from "next/navigation";
142
143
  import { Tabs, TabList, Tab } from "@umami/react-zen";
143
144
  import { jsx as jsx6 } from "react/jsx-runtime";
@@ -146,30 +147,30 @@ function TopNav({ tabs }) {
146
147
  const tab = tabs.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
147
148
  const selected = tab?.id || "docs";
148
149
  return /* @__PURE__ */ jsx6(Tabs, { selectedKey: selected, children: /* @__PURE__ */ jsx6(TabList, { items: tabs, children: ({ id, label, url }) => {
149
- return /* @__PURE__ */ jsx6(Tab, { id, children: /* @__PURE__ */ jsx6(Link3, { href: url, children: label }) });
150
+ return /* @__PURE__ */ jsx6(Tab, { id, children: /* @__PURE__ */ jsx6(Link2, { href: url, children: label }) });
150
151
  } }) });
151
152
  }
152
153
 
153
- // src/components/docs/ContentArea.tsx
154
+ // src/components/ContentArea.tsx
154
155
  import { Heading, Box as Box2, Text as Text2 } from "@umami/react-zen";
155
156
 
156
- // css-modules:E:\dev\umami-shiso\src\components\docs\ContentArea.module.css
157
- var ContentArea_default = { "content": "ContentArea_content__YzBjN" };
157
+ // css-modules:E:\dev\umami-shiso\src\components\ContentArea.module.css
158
+ var ContentArea_default = { "content": "ContentArea_content__MWQ1Z" };
158
159
 
159
- // src/components/docs/ContentArea.tsx
160
+ // src/components/ContentArea.tsx
160
161
  import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
161
- function ContentArea({ title, description, group, body }) {
162
+ function ContentArea({ content, components }) {
162
163
  return /* @__PURE__ */ jsxs4(Box2, { flexGrow: 1, children: [
163
- /* @__PURE__ */ jsx7(Text2, { color: "primary", weight: "bold", children: group }),
164
- /* @__PURE__ */ jsx7(Heading, { size: "8", as: "h1", children: title }),
165
- /* @__PURE__ */ jsx7(Text2, { type: "muted", children: description }),
166
- /* @__PURE__ */ jsx7(Box2, { className: ContentArea_default.content, children: /* @__PURE__ */ jsx7(Markdown, { children: body }) })
164
+ /* @__PURE__ */ jsx7(Text2, { color: "primary", weight: "bold", children: content.group }),
165
+ /* @__PURE__ */ jsx7(Heading, { size: "8", as: "h1", children: content.meta.title }),
166
+ /* @__PURE__ */ jsx7(Text2, { type: "muted", children: content.meta.description }),
167
+ /* @__PURE__ */ jsx7(Box2, { className: ContentArea_default.content, children: /* @__PURE__ */ jsx7(Markdown, { content, components }) })
167
168
  ] });
168
169
  }
169
170
 
170
- // src/components/docs/Docs.tsx
171
+ // src/components/Docs.tsx
171
172
  import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
172
- function Docs({ content, config }) {
173
+ function Docs({ content, config, components }) {
173
174
  if (!content) {
174
175
  return /* @__PURE__ */ jsx8(Heading2, { size: "6", children: "Page not found" });
175
176
  }
@@ -188,104 +189,12 @@ function Docs({ content, config }) {
188
189
  tabs && /* @__PURE__ */ jsx8(TopNav, { tabs }),
189
190
  /* @__PURE__ */ jsxs5(Grid, { gap: "6", columns: "240px 1fr 240px", children: [
190
191
  /* @__PURE__ */ jsx8(SideNav, { tabs, navigation }),
191
- /* @__PURE__ */ jsx8(
192
- ContentArea,
193
- {
194
- title: content?.meta?.title,
195
- body: content?.body,
196
- group: content?.group,
197
- description: content?.meta?.description
198
- }
199
- ),
192
+ /* @__PURE__ */ jsx8(ContentArea, { content, components }),
200
193
  /* @__PURE__ */ jsx8(PageLinks, { items: content?.anchors, offset: 150 })
201
194
  ] })
202
195
  ] });
203
196
  }
204
-
205
- // src/lib/next.tsx
206
- import path2 from "node:path";
207
-
208
- // src/lib/content.ts
209
- import { cache } from "react";
210
- import matter from "gray-matter";
211
- import recursive from "recursive-readdir";
212
- import { firstBy } from "thenby";
213
- import fs from "node:fs/promises";
214
- import path from "node:path";
215
- var getFiles = cache(async (folder) => {
216
- const dir = path.resolve(folder);
217
- const files = await recursive(dir);
218
- return Promise.all(
219
- files.filter((file) => path.extname(file) === ".mdx").map(async (file) => {
220
- const postContent = await fs.readFile(file, "utf8");
221
- const { data, content } = matter(postContent);
222
- const id = file.replace(".mdx", "").replace(dir, "").replace(/\\/g, "/").replace(/^\//, "");
223
- const anchors = [];
224
- const body = content.split("\n").map((line) => {
225
- const match = line.match(/(#+)\s+(.*)/);
226
- if (match) {
227
- const [, num, name] = match;
228
- const id2 = name.toLowerCase().replace(/\s+/g, "-");
229
- const size = num.length;
230
- anchors.push({ name, id: id2, size });
231
- return `<h${size} id="${id2}">${name.replace(/\{|\}/g, "")}</h${size}>`;
232
- }
233
- return line;
234
- }).join("\n");
235
- return {
236
- meta: data,
237
- id,
238
- body,
239
- anchors
240
- };
241
- })
242
- ).then((posts) => posts.sort(firstBy("date", "desc")));
243
- });
244
- async function getFile(id, folder) {
245
- const files = await getFiles(folder);
246
- return files.find((file) => file?.id === id);
247
- }
248
- async function getContent(params, folder) {
249
- const { id = [] } = params;
250
- const name = id?.length ? id.join("/") : "index";
251
- return getFile(name, folder);
252
- }
253
-
254
- // src/lib/next.tsx
255
- import { jsx as jsx9 } from "react/jsx-runtime";
256
- var DEFAULT_CONTENT_DIR = "./src/content";
257
- var components2 = {
258
- docs: Docs,
259
- blog: Blog
260
- };
261
- var next_default = (config) => {
262
- const { contentDir = DEFAULT_CONTENT_DIR } = config || {};
263
- const getMetadata = ({ title }) => {
264
- return async ({ params }) => {
265
- const content = await getContent(await params, contentDir);
266
- return {
267
- title: {
268
- absolute: `${content?.meta?.title} \u2013 ${title}`,
269
- default: title
270
- }
271
- };
272
- };
273
- };
274
- const renderPage = ({ type }) => {
275
- const folder = path2.resolve(process.cwd(), contentDir, type);
276
- return async ({ params }) => {
277
- const content = await getContent(await params, folder);
278
- const Component = components2[type];
279
- return Component && /* @__PURE__ */ jsx9(Component, { content, config });
280
- };
281
- };
282
- return {
283
- getMetadata,
284
- renderPage
285
- };
286
- };
287
197
  export {
288
198
  Blog,
289
- Docs,
290
- next_default as next
199
+ Docs
291
200
  };
package/package.json CHANGED
@@ -1,31 +1,33 @@
1
1
  {
2
2
  "name": "@umami/shiso",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "A content layer for Next.js",
5
5
  "homepage": "https://umami.is/shiso",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/umami-software/shiso.git"
9
9
  },
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
10
  "main": "dist/index.js",
14
11
  "module": "dist/index.mjs",
15
12
  "types": "dist/index.d.ts",
16
13
  "files": [
17
- "dist"
14
+ "dist",
15
+ "server"
18
16
  ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
19
20
  "scripts": {
20
- "dev": "next dev --port 3100",
21
+ "dev": "next dev --port 3100 --turbo",
21
22
  "build": "next build",
22
23
  "start": "next start",
23
24
  "lint": "next lint",
24
25
  "icons": "svgr ./src/assets --out-dir ./src/components/icons --typescript",
25
- "types": "tsc -p tsconfig.build.json",
26
+ "components": "tsc -p tsconfig.components.json",
27
+ "server": "tsc -p tsconfig.server.json",
26
28
  "esbuild": "node esbuild.mjs",
27
29
  "dts": "node dts.mjs",
28
- "bundle": "npm-run-all types dts esbuild"
30
+ "bundle": "npm-run-all components server dts esbuild"
29
31
  },
30
32
  "lint-staged": {
31
33
  "**/*.{js,jsx,ts,tsx}": [
@@ -40,15 +42,20 @@
40
42
  "prettier --write"
41
43
  ]
42
44
  },
45
+ "peerDependencies": {
46
+ "@umami/react-zen": "^0.27.0"
47
+ },
43
48
  "dependencies": {
44
49
  "@mdx-js/loader": "^3.0.0",
50
+ "@mdx-js/mdx": "^3.1.0",
45
51
  "@mdx-js/react": "^3.0.0",
46
52
  "@umami/react-zen": "^0.27.0",
47
53
  "classnames": "^2.5.1",
48
54
  "glob": "^10.3.10",
49
55
  "gray-matter": "^4.0.3",
50
56
  "highlight.js": "^11.11.0",
51
- "next": "15.1.0",
57
+ "mdx-bundler": "^10.0.3",
58
+ "next": "15.1.2",
52
59
  "next-mdx-remote": "^5.0.0",
53
60
  "react": "19.0.0",
54
61
  "react-dom": "19.0.0",
@@ -66,7 +73,7 @@
66
73
  "@types/react-dom": "^19.0.2",
67
74
  "@umami/esbuild-plugin-css-modules": "^0.4.0",
68
75
  "dts-bundle": "^0.7.3",
69
- "esbuild": "^0.24.0",
76
+ "esbuild": "^0.24.2",
70
77
  "esbuild-plugin-css-modules": "^0.3.0",
71
78
  "eslint": "^8",
72
79
  "eslint-config-next": "15.0.2",
@@ -0,0 +1,5 @@
1
+ export declare const getFiles: (folder: string) => Promise<any>;
2
+ export declare function getFile(id: string, folder: string): Promise<any>;
3
+ export declare function getContent(params: {
4
+ id: string[];
5
+ }, folder: string): Promise<any>;
@@ -0,0 +1,124 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { cache } from 'react';
38
+ import recursive from 'recursive-readdir';
39
+ import { firstBy } from 'thenby';
40
+ import remarkGfm from 'remark-gfm';
41
+ import rehypeHighlight from 'rehype-highlight';
42
+ import { serialize } from 'next-mdx-remote/serialize';
43
+ import fs from 'node:fs/promises';
44
+ import path from 'node:path';
45
+ var mdxOptions = {
46
+ remarkPlugins: [remarkGfm],
47
+ rehypePlugins: [rehypeHighlight],
48
+ };
49
+ export var getFiles = cache(function (folder) { return __awaiter(void 0, void 0, void 0, function () {
50
+ var dir, files;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ dir = path.resolve(folder);
55
+ return [4 /*yield*/, recursive(dir)];
56
+ case 1:
57
+ files = _a.sent();
58
+ return [2 /*return*/, Promise.all(files
59
+ .filter(function (file) { return path.extname(file) === '.mdx'; })
60
+ .map(function (file) { return __awaiter(void 0, void 0, void 0, function () {
61
+ var postContent, id, anchors, body, _a, compiledSource, frontmatter;
62
+ return __generator(this, function (_b) {
63
+ switch (_b.label) {
64
+ case 0: return [4 /*yield*/, fs.readFile(file, 'utf8')];
65
+ case 1:
66
+ postContent = _b.sent();
67
+ id = file.replace('.mdx', '').replace(dir, '').replace(/\\/g, '/').replace(/^\//, '');
68
+ anchors = [];
69
+ body = postContent
70
+ .split('\n')
71
+ .map(function (line) {
72
+ var match = line.match(/^(#+)\s+(.*)/);
73
+ if (match) {
74
+ var num = match[1], name_1 = match[2];
75
+ var id_1 = name_1.toLowerCase().replace(/\s+/g, '-');
76
+ var size = num.length;
77
+ anchors.push({ name: name_1, id: id_1, size: size });
78
+ return "<h".concat(size, " id=\"").concat(id_1, "\">").concat(name_1.replace(/\{|\}/g, ''), "</h").concat(size, ">");
79
+ }
80
+ return line;
81
+ })
82
+ .join('\n');
83
+ return [4 /*yield*/, serialize(body, {
84
+ mdxOptions: mdxOptions,
85
+ parseFrontmatter: true,
86
+ })];
87
+ case 2:
88
+ _a = _b.sent(), compiledSource = _a.compiledSource, frontmatter = _a.frontmatter;
89
+ return [2 /*return*/, {
90
+ meta: frontmatter,
91
+ id: id,
92
+ content: postContent,
93
+ code: compiledSource,
94
+ anchors: anchors,
95
+ }];
96
+ }
97
+ });
98
+ }); })).then(function (posts) { return posts.sort(firstBy('date', 'desc')); })];
99
+ }
100
+ });
101
+ }); });
102
+ export function getFile(id, folder) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var files;
105
+ return __generator(this, function (_a) {
106
+ switch (_a.label) {
107
+ case 0: return [4 /*yield*/, getFiles(folder)];
108
+ case 1:
109
+ files = _a.sent();
110
+ return [2 /*return*/, files.find(function (file) { return (file === null || file === void 0 ? void 0 : file.id) === id; })];
111
+ }
112
+ });
113
+ });
114
+ }
115
+ export function getContent(params, folder) {
116
+ return __awaiter(this, void 0, void 0, function () {
117
+ var _a, id, name;
118
+ return __generator(this, function (_b) {
119
+ _a = params.id, id = _a === void 0 ? [] : _a;
120
+ name = (id === null || id === void 0 ? void 0 : id.length) ? id.join('/') : 'index';
121
+ return [2 /*return*/, getFile(name, folder)];
122
+ });
123
+ });
124
+ }