@umami/shiso 0.16.0 → 0.18.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.d.ts +1 -0
- package/dist/index.js +101 -51
- package/dist/index.mjs +97 -47
- package/dist/server.d.ts +45 -0
- package/{server/server/index.js → dist/server.js} +60 -84
- package/package.json +2 -2
- package/server/lib/types.d.ts +0 -14
- package/server/lib/types.js +0 -1
- package/server/server/index.d.ts +0 -26
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
39
|
var import_styles = require("@umami/react-zen/styles.css");
|
|
40
|
+
var import_github_dark = require("highlight.js/styles/github-dark.css");
|
|
40
41
|
|
|
41
42
|
// css-modules:/Users/mikecao/Development/umami-software/shiso/src/components/Blog.module.css
|
|
42
43
|
var Blog_default = {};
|
|
@@ -58,9 +59,9 @@ var parseMdx = (code) => {
|
|
|
58
59
|
return { error: err.message };
|
|
59
60
|
}
|
|
60
61
|
};
|
|
61
|
-
function Markdown({
|
|
62
|
+
function Markdown({ code }) {
|
|
62
63
|
const components = (0, import_react.useMDXComponents)();
|
|
63
|
-
const { Component, error } = parseMdx(
|
|
64
|
+
const { Component, error } = parseMdx(code);
|
|
64
65
|
if (error) {
|
|
65
66
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h1", { children: [
|
|
66
67
|
"Error rendering MDX: ",
|
|
@@ -73,13 +74,22 @@ function Markdown({ content }) {
|
|
|
73
74
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { components });
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
// src/components/
|
|
77
|
+
// src/components/Blogs.tsx
|
|
77
78
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
79
|
+
function Blogs() {
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: "All the blogs!" });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/components/Blog.tsx
|
|
84
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
78
85
|
function Blog({ content }) {
|
|
79
|
-
|
|
80
|
-
/* @__PURE__ */ (0,
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
if (!content) {
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Blogs, {});
|
|
88
|
+
}
|
|
89
|
+
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: [
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: content?.meta?.title }),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: Blog_default.description, children: content?.meta?.description }),
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { code: content?.code })
|
|
83
93
|
] }) }) });
|
|
84
94
|
}
|
|
85
95
|
|
|
@@ -101,7 +111,7 @@ var import_react_zen = require("@umami/react-zen");
|
|
|
101
111
|
var CodeBlock_default = { "container": "CodeBlock_container__YmFmN", "button": "CodeBlock_button__NDg0Y", "copy": "CodeBlock_copy__MmQzM", "check": "CodeBlock_check__YmI0Z" };
|
|
102
112
|
|
|
103
113
|
// src/components/CodeBlock.tsx
|
|
104
|
-
var
|
|
114
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
105
115
|
function CodeBlock(props) {
|
|
106
116
|
const textInput = (0, import_react2.useRef)(null);
|
|
107
117
|
const [copied, setCopied] = (0, import_react2.useState)(false);
|
|
@@ -112,14 +122,14 @@ function CodeBlock(props) {
|
|
|
112
122
|
setCopied(false);
|
|
113
123
|
}, 1e3);
|
|
114
124
|
};
|
|
115
|
-
return /* @__PURE__ */ (0,
|
|
125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("pre", { ref: textInput, className: CodeBlock_default.container, children: [
|
|
116
126
|
props.children,
|
|
117
|
-
/* @__PURE__ */ (0,
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { "aria-label": "Copy code", className: CodeBlock_default.button, onClick: handleCopy, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_zen.Icon, { size: "sm", className: copied ? CodeBlock_default.check : CodeBlock_default.copy, children: copied ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_zen.Icons.Check, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_zen.Icons.Copy, {}) }) })
|
|
118
128
|
] });
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
// src/components/Shiso.tsx
|
|
122
|
-
var
|
|
132
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
123
133
|
var defaultTemplates = {
|
|
124
134
|
docs: Docs,
|
|
125
135
|
blog: Blog
|
|
@@ -128,9 +138,9 @@ var ShisoContext = (0, import_react3.createContext)(null);
|
|
|
128
138
|
function Shiso({ content, type, config, components, templates }) {
|
|
129
139
|
const Component = { ...defaultTemplates, ...templates }[type];
|
|
130
140
|
if (!Component) {
|
|
131
|
-
return /* @__PURE__ */ (0,
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h1", { children: `Component not found for type: ${type}` });
|
|
132
142
|
}
|
|
133
|
-
return /* @__PURE__ */ (0,
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ShisoContext.Provider, { value: { content, type, config }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react4.MDXProvider, { components: { ...components, pre: CodeBlock }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Component, { content, config }) }) });
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
// src/components/hooks/useShiso.ts
|
|
@@ -148,7 +158,7 @@ var import_classnames = __toESM(require("classnames"));
|
|
|
148
158
|
var PageLinks_default = { "title": "PageLinks_title__YjEwN", "links": "PageLinks_links__OWRlM", "link": "PageLinks_link__NDJjM", "indent-1": "PageLinks_indent-1__MDU1M", "indent-2": "PageLinks_indent-2__MDBmY", "indent-3": "PageLinks_indent-3__ZmY2O", "indent-4": "PageLinks_indent-4__MDA4N", "indent-5": "PageLinks_indent-5__MDBlM", "indent-6": "PageLinks_indent-6__NjIwM", "selected": "PageLinks_selected__NjEyY" };
|
|
149
159
|
|
|
150
160
|
// src/components/PageLinks.tsx
|
|
151
|
-
var
|
|
161
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
152
162
|
function PageLinks({ items, offset = 0 }) {
|
|
153
163
|
const [hash, setHash] = (0, import_react6.useState)(items?.[0]?.id);
|
|
154
164
|
(0, import_react6.useEffect)(() => {
|
|
@@ -167,10 +177,10 @@ function PageLinks({ items, offset = 0 }) {
|
|
|
167
177
|
if (!items?.length) {
|
|
168
178
|
return null;
|
|
169
179
|
}
|
|
170
|
-
return /* @__PURE__ */ (0,
|
|
171
|
-
/* @__PURE__ */ (0,
|
|
180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_zen2.Column, { gap: "3", minWidth: "240px", className: PageLinks_default.links, children: [
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen2.Text, { size: "2", weight: "bold", children: "On this page" }),
|
|
172
182
|
items.map(({ name, id, size }) => {
|
|
173
|
-
return /* @__PURE__ */ (0,
|
|
183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
174
184
|
"a",
|
|
175
185
|
{
|
|
176
186
|
href: `#${id}`,
|
|
@@ -195,20 +205,20 @@ var import_link = __toESM(require("next/link"));
|
|
|
195
205
|
var SideNav_default = { "nav": "SideNav_nav__YWMxN", "item": "SideNav_item__YTQzN", "selected": "SideNav_selected__ZDI0N", "items": "SideNav_items__Y2YwZ" };
|
|
196
206
|
|
|
197
207
|
// src/components/SideNav.tsx
|
|
198
|
-
var
|
|
208
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
199
209
|
function SideNav({ tabs, navigation }) {
|
|
200
210
|
const pathname = (0, import_navigation.usePathname)();
|
|
201
211
|
const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
202
212
|
const menu = navigation[tab?.id || "docs"];
|
|
203
|
-
return /* @__PURE__ */ (0,
|
|
204
|
-
return /* @__PURE__ */ (0,
|
|
205
|
-
return /* @__PURE__ */ (0,
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.Box, { className: SideNav_default.nav, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.List, { items: navigation, "aria-label": "nav", children: menu.map(({ group, pages }) => {
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.ListSection, { title: group, className: SideNav_default.items, children: pages.map(({ label: text, url }, index) => {
|
|
215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
206
216
|
import_react_zen3.ListItem,
|
|
207
217
|
{
|
|
208
218
|
className: (0, import_classnames2.default)(SideNav_default.item, {
|
|
209
219
|
[SideNav_default.selected]: url === pathname
|
|
210
220
|
}),
|
|
211
|
-
children: /* @__PURE__ */ (0,
|
|
221
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_link.default, { href: url, prefetch: false, children: text })
|
|
212
222
|
},
|
|
213
223
|
index
|
|
214
224
|
);
|
|
@@ -220,13 +230,13 @@ function SideNav({ tabs, navigation }) {
|
|
|
220
230
|
var import_link2 = __toESM(require("next/link"));
|
|
221
231
|
var import_navigation2 = require("next/navigation");
|
|
222
232
|
var import_react_zen4 = require("@umami/react-zen");
|
|
223
|
-
var
|
|
233
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
224
234
|
function TopNav({ tabs }) {
|
|
225
235
|
const pathname = (0, import_navigation2.usePathname)();
|
|
226
236
|
const tab = tabs?.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
227
237
|
const selected = tab?.id || "docs";
|
|
228
|
-
return /* @__PURE__ */ (0,
|
|
229
|
-
return /* @__PURE__ */ (0,
|
|
238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen4.Tabs, { selectedKey: selected, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen4.TabList, { items: tabs, children: ({ id, label, url }) => {
|
|
239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen4.Tab, { id, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_link2.default, { href: url, children: label }) });
|
|
230
240
|
} }) });
|
|
231
241
|
}
|
|
232
242
|
|
|
@@ -237,40 +247,80 @@ var import_react_zen5 = require("@umami/react-zen");
|
|
|
237
247
|
var ContentArea_default = { "content": "ContentArea_content__OTBiZ" };
|
|
238
248
|
|
|
239
249
|
// src/components/ContentArea.tsx
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
/* @__PURE__ */ (0,
|
|
245
|
-
/* @__PURE__ */ (0,
|
|
246
|
-
/* @__PURE__ */ (0,
|
|
250
|
+
var import_link3 = __toESM(require("next/link"));
|
|
251
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
252
|
+
function ContentArea({ group, title, description, code, next, prev }) {
|
|
253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_zen5.Box, { flexGrow: 1, children: [
|
|
254
|
+
group && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Text, { color: "primary", weight: "bold", children: group }),
|
|
255
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Heading, { size: "8", as: "h1", children: title }),
|
|
256
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Text, { color: "muted", children: description }),
|
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Box, { className: ContentArea_default.content, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Markdown, { code }) }),
|
|
258
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_zen5.Row, { justifyContent: "space-between", children: [
|
|
259
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(NavigationButton, { ...prev, isPrev: true }),
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(NavigationButton, { ...next })
|
|
261
|
+
] })
|
|
247
262
|
] });
|
|
248
263
|
}
|
|
264
|
+
var NavigationButton = ({
|
|
265
|
+
label,
|
|
266
|
+
url,
|
|
267
|
+
isPrev
|
|
268
|
+
}) => {
|
|
269
|
+
if (!url || !label) {
|
|
270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Box, {});
|
|
271
|
+
}
|
|
272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_link3.default, { href: url, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_zen5.Row, { alignItems: "center", gap: "3", marginY: "3", children: [
|
|
273
|
+
isPrev && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Icon, { size: "sm", rotate: 180, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Icons.Chevron, {}) }),
|
|
274
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Text, { size: "3", weight: "bold", children: label }),
|
|
275
|
+
!isPrev && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Icons.Chevron, {}) })
|
|
276
|
+
] }) });
|
|
277
|
+
};
|
|
249
278
|
|
|
250
279
|
// src/components/Docs.tsx
|
|
251
|
-
var
|
|
280
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
281
|
+
function parseContent(content, config = {}) {
|
|
282
|
+
const { tabs, navigation } = config;
|
|
283
|
+
let next, prev, group, prevKey, found = false;
|
|
284
|
+
for (const key in navigation) {
|
|
285
|
+
if (!group) {
|
|
286
|
+
group = navigation[key]?.find((section, sectionIndex) => {
|
|
287
|
+
return section.pages.find((page, pageIndex) => {
|
|
288
|
+
const found2 = content.path.replace(/(\/index)?\.mdx$/, "").endsWith(page.url);
|
|
289
|
+
if (found2) {
|
|
290
|
+
prev = section.pages[pageIndex - 1] || section[prevKey]?.pages?.[sectionIndex - 1];
|
|
291
|
+
next = section.pages[pageIndex + 1];
|
|
292
|
+
}
|
|
293
|
+
return found2;
|
|
294
|
+
});
|
|
295
|
+
})?.group;
|
|
296
|
+
prevKey = key;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return { ...content, tabs, navigation, group, next, prev };
|
|
300
|
+
}
|
|
252
301
|
function Docs() {
|
|
253
302
|
const { content, config } = useShiso();
|
|
254
303
|
if (!content) {
|
|
255
|
-
return /* @__PURE__ */ (0,
|
|
304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_zen6.Heading, { size: "6", children: "Page not found" });
|
|
256
305
|
}
|
|
257
|
-
const { tabs, navigation } = config?.docs
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
306
|
+
const { tabs, navigation, group, next, prev } = parseContent(content, config?.docs);
|
|
307
|
+
console.log({ content, next, prev, group });
|
|
308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_zen6.Box, { flexGrow: "1", children: [
|
|
309
|
+
tabs && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TopNav, { tabs }),
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_zen6.Grid, { gap: "6", columns: "240px 1fr 240px", children: [
|
|
311
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SideNav, { tabs, navigation }),
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
313
|
+
ContentArea,
|
|
314
|
+
{
|
|
315
|
+
group,
|
|
316
|
+
title: content.meta?.title,
|
|
317
|
+
description: content.meta?.description,
|
|
318
|
+
code: content.code,
|
|
319
|
+
next,
|
|
320
|
+
prev
|
|
321
|
+
}
|
|
322
|
+
),
|
|
323
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PageLinks, { items: content?.anchors, offset: 150 })
|
|
274
324
|
] })
|
|
275
325
|
] });
|
|
276
326
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/components/index.ts
|
|
4
4
|
import "@umami/react-zen/styles.css";
|
|
5
|
+
import "highlight.js/styles/github-dark.css";
|
|
5
6
|
|
|
6
7
|
// css-modules:/Users/mikecao/Development/umami-software/shiso/src/components/Blog.module.css
|
|
7
8
|
var Blog_default = {};
|
|
@@ -22,9 +23,9 @@ var parseMdx = (code) => {
|
|
|
22
23
|
return { error: err.message };
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
|
-
function Markdown({
|
|
26
|
+
function Markdown({ code }) {
|
|
26
27
|
const components = useMDXComponents();
|
|
27
|
-
const { Component, error } = parseMdx(
|
|
28
|
+
const { Component, error } = parseMdx(code);
|
|
28
29
|
if (error) {
|
|
29
30
|
return /* @__PURE__ */ jsxs("h1", { children: [
|
|
30
31
|
"Error rendering MDX: ",
|
|
@@ -37,13 +38,22 @@ function Markdown({ content }) {
|
|
|
37
38
|
return /* @__PURE__ */ jsx(Component, { components });
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// src/components/Blogs.tsx
|
|
42
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
43
|
+
function Blogs() {
|
|
44
|
+
return /* @__PURE__ */ jsx2("h1", { children: "All the blogs!" });
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
// src/components/Blog.tsx
|
|
41
|
-
import { jsx as
|
|
48
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
42
49
|
function Blog({ content }) {
|
|
43
|
-
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
if (!content) {
|
|
51
|
+
return /* @__PURE__ */ jsx3(Blogs, {});
|
|
52
|
+
}
|
|
53
|
+
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: [
|
|
54
|
+
/* @__PURE__ */ jsx3("h1", { children: content?.meta?.title }),
|
|
55
|
+
/* @__PURE__ */ jsx3("p", { className: Blog_default.description, children: content?.meta?.description }),
|
|
56
|
+
/* @__PURE__ */ jsx3(Markdown, { code: content?.code })
|
|
47
57
|
] }) }) });
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -65,7 +75,7 @@ import { Icon, Icons } from "@umami/react-zen";
|
|
|
65
75
|
var CodeBlock_default = { "container": "CodeBlock_container__YmFmN", "button": "CodeBlock_button__NDg0Y", "copy": "CodeBlock_copy__MmQzM", "check": "CodeBlock_check__YmI0Z" };
|
|
66
76
|
|
|
67
77
|
// src/components/CodeBlock.tsx
|
|
68
|
-
import { jsx as
|
|
78
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
69
79
|
function CodeBlock(props) {
|
|
70
80
|
const textInput = useRef(null);
|
|
71
81
|
const [copied, setCopied] = useState(false);
|
|
@@ -78,12 +88,12 @@ function CodeBlock(props) {
|
|
|
78
88
|
};
|
|
79
89
|
return /* @__PURE__ */ jsxs3("pre", { ref: textInput, className: CodeBlock_default.container, children: [
|
|
80
90
|
props.children,
|
|
81
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ jsx4("button", { "aria-label": "Copy code", className: CodeBlock_default.button, onClick: handleCopy, children: /* @__PURE__ */ jsx4(Icon, { size: "sm", className: copied ? CodeBlock_default.check : CodeBlock_default.copy, children: copied ? /* @__PURE__ */ jsx4(Icons.Check, {}) : /* @__PURE__ */ jsx4(Icons.Copy, {}) }) })
|
|
82
92
|
] });
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
// src/components/Shiso.tsx
|
|
86
|
-
import { jsx as
|
|
96
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
87
97
|
var defaultTemplates = {
|
|
88
98
|
docs: Docs,
|
|
89
99
|
blog: Blog
|
|
@@ -92,9 +102,9 @@ var ShisoContext = createContext(null);
|
|
|
92
102
|
function Shiso({ content, type, config, components, templates }) {
|
|
93
103
|
const Component = { ...defaultTemplates, ...templates }[type];
|
|
94
104
|
if (!Component) {
|
|
95
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ jsx5("h1", { children: `Component not found for type: ${type}` });
|
|
96
106
|
}
|
|
97
|
-
return /* @__PURE__ */
|
|
107
|
+
return /* @__PURE__ */ jsx5(ShisoContext.Provider, { value: { content, type, config }, children: /* @__PURE__ */ jsx5(MDXProvider, { components: { ...components, pre: CodeBlock }, children: /* @__PURE__ */ jsx5(Component, { content, config }) }) });
|
|
98
108
|
}
|
|
99
109
|
|
|
100
110
|
// src/components/hooks/useShiso.ts
|
|
@@ -112,7 +122,7 @@ import classNames from "classnames";
|
|
|
112
122
|
var PageLinks_default = { "title": "PageLinks_title__YjEwN", "links": "PageLinks_links__OWRlM", "link": "PageLinks_link__NDJjM", "indent-1": "PageLinks_indent-1__MDU1M", "indent-2": "PageLinks_indent-2__MDBmY", "indent-3": "PageLinks_indent-3__ZmY2O", "indent-4": "PageLinks_indent-4__MDA4N", "indent-5": "PageLinks_indent-5__MDBlM", "indent-6": "PageLinks_indent-6__NjIwM", "selected": "PageLinks_selected__NjEyY" };
|
|
113
123
|
|
|
114
124
|
// src/components/PageLinks.tsx
|
|
115
|
-
import { jsx as
|
|
125
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
116
126
|
function PageLinks({ items, offset = 0 }) {
|
|
117
127
|
const [hash, setHash] = useState2(items?.[0]?.id);
|
|
118
128
|
useEffect(() => {
|
|
@@ -132,9 +142,9 @@ function PageLinks({ items, offset = 0 }) {
|
|
|
132
142
|
return null;
|
|
133
143
|
}
|
|
134
144
|
return /* @__PURE__ */ jsxs4(Column, { gap: "3", minWidth: "240px", className: PageLinks_default.links, children: [
|
|
135
|
-
/* @__PURE__ */
|
|
145
|
+
/* @__PURE__ */ jsx6(Text, { size: "2", weight: "bold", children: "On this page" }),
|
|
136
146
|
items.map(({ name, id, size }) => {
|
|
137
|
-
return /* @__PURE__ */
|
|
147
|
+
return /* @__PURE__ */ jsx6(
|
|
138
148
|
"a",
|
|
139
149
|
{
|
|
140
150
|
href: `#${id}`,
|
|
@@ -159,20 +169,20 @@ import Link from "next/link";
|
|
|
159
169
|
var SideNav_default = { "nav": "SideNav_nav__YWMxN", "item": "SideNav_item__YTQzN", "selected": "SideNav_selected__ZDI0N", "items": "SideNav_items__Y2YwZ" };
|
|
160
170
|
|
|
161
171
|
// src/components/SideNav.tsx
|
|
162
|
-
import { jsx as
|
|
172
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
163
173
|
function SideNav({ tabs, navigation }) {
|
|
164
174
|
const pathname = usePathname();
|
|
165
175
|
const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
166
176
|
const menu = navigation[tab?.id || "docs"];
|
|
167
|
-
return /* @__PURE__ */
|
|
168
|
-
return /* @__PURE__ */
|
|
169
|
-
return /* @__PURE__ */
|
|
177
|
+
return /* @__PURE__ */ jsx7(Box, { className: SideNav_default.nav, children: /* @__PURE__ */ jsx7(List, { items: navigation, "aria-label": "nav", children: menu.map(({ group, pages }) => {
|
|
178
|
+
return /* @__PURE__ */ jsx7(ListSection, { title: group, className: SideNav_default.items, children: pages.map(({ label: text, url }, index) => {
|
|
179
|
+
return /* @__PURE__ */ jsx7(
|
|
170
180
|
ListItem,
|
|
171
181
|
{
|
|
172
182
|
className: classNames2(SideNav_default.item, {
|
|
173
183
|
[SideNav_default.selected]: url === pathname
|
|
174
184
|
}),
|
|
175
|
-
children: /* @__PURE__ */
|
|
185
|
+
children: /* @__PURE__ */ jsx7(Link, { href: url, prefetch: false, children: text })
|
|
176
186
|
},
|
|
177
187
|
index
|
|
178
188
|
);
|
|
@@ -184,57 +194,97 @@ function SideNav({ tabs, navigation }) {
|
|
|
184
194
|
import Link2 from "next/link";
|
|
185
195
|
import { usePathname as usePathname2 } from "next/navigation";
|
|
186
196
|
import { Tabs, TabList, Tab } from "@umami/react-zen";
|
|
187
|
-
import { jsx as
|
|
197
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
188
198
|
function TopNav({ tabs }) {
|
|
189
199
|
const pathname = usePathname2();
|
|
190
200
|
const tab = tabs?.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
191
201
|
const selected = tab?.id || "docs";
|
|
192
|
-
return /* @__PURE__ */
|
|
193
|
-
return /* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ jsx8(Tabs, { selectedKey: selected, children: /* @__PURE__ */ jsx8(TabList, { items: tabs, children: ({ id, label, url }) => {
|
|
203
|
+
return /* @__PURE__ */ jsx8(Tab, { id, children: /* @__PURE__ */ jsx8(Link2, { href: url, children: label }) });
|
|
194
204
|
} }) });
|
|
195
205
|
}
|
|
196
206
|
|
|
197
207
|
// src/components/ContentArea.tsx
|
|
198
|
-
import { Heading, Box as Box2, Text as Text2 } from "@umami/react-zen";
|
|
208
|
+
import { Heading, Box as Box2, Text as Text2, Row, Icon as Icon2, Icons as Icons2 } from "@umami/react-zen";
|
|
199
209
|
|
|
200
210
|
// css-modules:/Users/mikecao/Development/umami-software/shiso/src/components/ContentArea.module.css
|
|
201
211
|
var ContentArea_default = { "content": "ContentArea_content__OTBiZ" };
|
|
202
212
|
|
|
203
213
|
// src/components/ContentArea.tsx
|
|
204
|
-
import
|
|
205
|
-
|
|
214
|
+
import Link3 from "next/link";
|
|
215
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
216
|
+
function ContentArea({ group, title, description, code, next, prev }) {
|
|
206
217
|
return /* @__PURE__ */ jsxs5(Box2, { flexGrow: 1, children: [
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
-
/* @__PURE__ */
|
|
218
|
+
group && /* @__PURE__ */ jsx9(Text2, { color: "primary", weight: "bold", children: group }),
|
|
219
|
+
title && /* @__PURE__ */ jsx9(Heading, { size: "8", as: "h1", children: title }),
|
|
220
|
+
description && /* @__PURE__ */ jsx9(Text2, { color: "muted", children: description }),
|
|
221
|
+
/* @__PURE__ */ jsx9(Box2, { className: ContentArea_default.content, children: /* @__PURE__ */ jsx9(Markdown, { code }) }),
|
|
222
|
+
/* @__PURE__ */ jsxs5(Row, { justifyContent: "space-between", children: [
|
|
223
|
+
/* @__PURE__ */ jsx9(NavigationButton, { ...prev, isPrev: true }),
|
|
224
|
+
/* @__PURE__ */ jsx9(NavigationButton, { ...next })
|
|
225
|
+
] })
|
|
211
226
|
] });
|
|
212
227
|
}
|
|
228
|
+
var NavigationButton = ({
|
|
229
|
+
label,
|
|
230
|
+
url,
|
|
231
|
+
isPrev
|
|
232
|
+
}) => {
|
|
233
|
+
if (!url || !label) {
|
|
234
|
+
return /* @__PURE__ */ jsx9(Box2, {});
|
|
235
|
+
}
|
|
236
|
+
return /* @__PURE__ */ jsx9(Link3, { href: url, children: /* @__PURE__ */ jsxs5(Row, { alignItems: "center", gap: "3", marginY: "3", children: [
|
|
237
|
+
isPrev && /* @__PURE__ */ jsx9(Icon2, { size: "sm", rotate: 180, children: /* @__PURE__ */ jsx9(Icons2.Chevron, {}) }),
|
|
238
|
+
/* @__PURE__ */ jsx9(Text2, { size: "3", weight: "bold", children: label }),
|
|
239
|
+
!isPrev && /* @__PURE__ */ jsx9(Icon2, { size: "sm", children: /* @__PURE__ */ jsx9(Icons2.Chevron, {}) })
|
|
240
|
+
] }) });
|
|
241
|
+
};
|
|
213
242
|
|
|
214
243
|
// src/components/Docs.tsx
|
|
215
|
-
import { jsx as
|
|
244
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
245
|
+
function parseContent(content, config = {}) {
|
|
246
|
+
const { tabs, navigation } = config;
|
|
247
|
+
let next, prev, group, prevKey, found = false;
|
|
248
|
+
for (const key in navigation) {
|
|
249
|
+
if (!group) {
|
|
250
|
+
group = navigation[key]?.find((section, sectionIndex) => {
|
|
251
|
+
return section.pages.find((page, pageIndex) => {
|
|
252
|
+
const found2 = content.path.replace(/(\/index)?\.mdx$/, "").endsWith(page.url);
|
|
253
|
+
if (found2) {
|
|
254
|
+
prev = section.pages[pageIndex - 1] || section[prevKey]?.pages?.[sectionIndex - 1];
|
|
255
|
+
next = section.pages[pageIndex + 1];
|
|
256
|
+
}
|
|
257
|
+
return found2;
|
|
258
|
+
});
|
|
259
|
+
})?.group;
|
|
260
|
+
prevKey = key;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return { ...content, tabs, navigation, group, next, prev };
|
|
264
|
+
}
|
|
216
265
|
function Docs() {
|
|
217
266
|
const { content, config } = useShiso();
|
|
218
267
|
if (!content) {
|
|
219
|
-
return /* @__PURE__ */
|
|
268
|
+
return /* @__PURE__ */ jsx10(Heading2, { size: "6", children: "Page not found" });
|
|
220
269
|
}
|
|
221
|
-
const { tabs, navigation } = config?.docs
|
|
222
|
-
|
|
223
|
-
if (!name) {
|
|
224
|
-
return navigation[key]?.find((section) => {
|
|
225
|
-
return section.pages.find(
|
|
226
|
-
(page) => page.url === `/docs/${content.id}` || page.url === `/docs` && content.id === "index"
|
|
227
|
-
);
|
|
228
|
-
})?.group;
|
|
229
|
-
}
|
|
230
|
-
return name;
|
|
231
|
-
}, null);
|
|
270
|
+
const { tabs, navigation, group, next, prev } = parseContent(content, config?.docs);
|
|
271
|
+
console.log({ content, next, prev, group });
|
|
232
272
|
return /* @__PURE__ */ jsxs6(Box3, { flexGrow: "1", children: [
|
|
233
|
-
tabs && /* @__PURE__ */
|
|
273
|
+
tabs && /* @__PURE__ */ jsx10(TopNav, { tabs }),
|
|
234
274
|
/* @__PURE__ */ jsxs6(Grid, { gap: "6", columns: "240px 1fr 240px", children: [
|
|
235
|
-
/* @__PURE__ */
|
|
236
|
-
/* @__PURE__ */
|
|
237
|
-
|
|
275
|
+
/* @__PURE__ */ jsx10(SideNav, { tabs, navigation }),
|
|
276
|
+
/* @__PURE__ */ jsx10(
|
|
277
|
+
ContentArea,
|
|
278
|
+
{
|
|
279
|
+
group,
|
|
280
|
+
title: content.meta?.title,
|
|
281
|
+
description: content.meta?.description,
|
|
282
|
+
code: content.code,
|
|
283
|
+
next,
|
|
284
|
+
prev
|
|
285
|
+
}
|
|
286
|
+
),
|
|
287
|
+
/* @__PURE__ */ jsx10(PageLinks, { items: content?.anchors, offset: 150 })
|
|
238
288
|
] })
|
|
239
289
|
] });
|
|
240
290
|
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Generated by dts-bundle v0.7.3
|
|
2
|
+
// Dependencies for this module:
|
|
3
|
+
// ../../react
|
|
4
|
+
// ../../@/lib/types
|
|
5
|
+
|
|
6
|
+
declare module '@umami/shiso/server' {
|
|
7
|
+
import { ReactElement } from 'react';
|
|
8
|
+
import type { ShisoConfig } from '@/lib/types';
|
|
9
|
+
export const getContent: (file: string) => Promise<{
|
|
10
|
+
path: string;
|
|
11
|
+
meta: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
content: string;
|
|
15
|
+
code: string;
|
|
16
|
+
anchors: {
|
|
17
|
+
name: string;
|
|
18
|
+
id: string;
|
|
19
|
+
size: number;
|
|
20
|
+
}[];
|
|
21
|
+
} | null>;
|
|
22
|
+
export function next(type: string, config: ShisoConfig): {
|
|
23
|
+
generateMetadata: ({ params }: {
|
|
24
|
+
params: Promise<{
|
|
25
|
+
slug: string[];
|
|
26
|
+
}>;
|
|
27
|
+
}) => Promise<{
|
|
28
|
+
title: {
|
|
29
|
+
absolute: string;
|
|
30
|
+
default: any;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
generateStaticParams: () => Promise<any>;
|
|
34
|
+
renderPage: (render: ({ type, content, config, }: {
|
|
35
|
+
type: string;
|
|
36
|
+
content: any;
|
|
37
|
+
config: ShisoConfig;
|
|
38
|
+
}) => ReactElement) => ({ params }: {
|
|
39
|
+
params: Promise<{
|
|
40
|
+
slug: string[];
|
|
41
|
+
}>;
|
|
42
|
+
}) => Promise<ReactElement<unknown, string | import("react").JSXElementConstructor<any>>>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
@@ -34,15 +34,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
-
if (ar || !(i in from)) {
|
|
40
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
-
ar[i] = from[i];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
-
};
|
|
46
37
|
import { cache } from 'react';
|
|
47
38
|
import { compile } from '@mdx-js/mdx';
|
|
48
39
|
import remarkGfm from 'remark-gfm';
|
|
@@ -51,94 +42,74 @@ import matter from 'gray-matter';
|
|
|
51
42
|
import fs from 'node:fs/promises';
|
|
52
43
|
import path from 'node:path';
|
|
53
44
|
import recursive from 'recursive-readdir';
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var args_1 = [];
|
|
59
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
60
|
-
args_1[_i] = arguments[_i];
|
|
61
|
-
}
|
|
62
|
-
return __awaiter(void 0, __spreadArray([], args_1, true), void 0, function (name, folder) {
|
|
63
|
-
var file, postContent, _a, frontmatter, mdxContent, id, anchors, modifiedContent, code, _b;
|
|
64
|
-
if (name === void 0) { name = 'index'; }
|
|
65
|
-
return __generator(this, function (_c) {
|
|
66
|
-
switch (_c.label) {
|
|
67
|
-
case 0:
|
|
68
|
-
file = path.join(folder, "".concat(name, ".mdx"));
|
|
69
|
-
return [4 /*yield*/, fs.readFile(file, 'utf8')];
|
|
70
|
-
case 1:
|
|
71
|
-
postContent = _c.sent();
|
|
72
|
-
_a = matter(postContent), frontmatter = _a.data, mdxContent = _a.content;
|
|
73
|
-
id = getId(name, folder);
|
|
74
|
-
anchors = [];
|
|
75
|
-
modifiedContent = mdxContent
|
|
76
|
-
.split('\n')
|
|
77
|
-
.map(function (line) {
|
|
78
|
-
var match = line.match(/^(#+)\s+(.*)/);
|
|
79
|
-
if (match) {
|
|
80
|
-
var num = match[1], name_1 = match[2];
|
|
81
|
-
var id_1 = name_1.toLowerCase().replace(/\s+/g, '-');
|
|
82
|
-
var size = num.length;
|
|
83
|
-
anchors.push({ name: name_1, id: id_1, size: size });
|
|
84
|
-
return "<h".concat(size, " id=\"").concat(id_1, "\">").concat(name_1.replace(/\{|\}/g, ''), "</h").concat(size, ">");
|
|
85
|
-
}
|
|
86
|
-
return line;
|
|
87
|
-
})
|
|
88
|
-
.join('\n');
|
|
89
|
-
_b = String;
|
|
90
|
-
return [4 /*yield*/, compile(modifiedContent, {
|
|
91
|
-
outputFormat: 'function-body',
|
|
92
|
-
remarkPlugins: [remarkGfm],
|
|
93
|
-
rehypePlugins: [rehypeHighlight],
|
|
94
|
-
})];
|
|
95
|
-
case 2:
|
|
96
|
-
code = _b.apply(void 0, [_c.sent()]);
|
|
97
|
-
return [2 /*return*/, {
|
|
98
|
-
id: id,
|
|
99
|
-
meta: frontmatter,
|
|
100
|
-
content: postContent,
|
|
101
|
-
code: code,
|
|
102
|
-
anchors: anchors,
|
|
103
|
-
}];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
export var getContentIds = cache(function (folder) { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
-
var dir, files;
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
45
|
+
export var getContent = cache(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var postContent, _a, frontmatter, mdxContent, anchors_1, modifiedContent, code, _b, _c;
|
|
47
|
+
return __generator(this, function (_d) {
|
|
48
|
+
switch (_d.label) {
|
|
112
49
|
case 0:
|
|
113
|
-
|
|
114
|
-
return [4 /*yield*/,
|
|
50
|
+
_d.trys.push([0, 3, , 4]);
|
|
51
|
+
return [4 /*yield*/, fs.readFile(file, 'utf8')];
|
|
115
52
|
case 1:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
53
|
+
postContent = _d.sent();
|
|
54
|
+
_a = matter(postContent), frontmatter = _a.data, mdxContent = _a.content;
|
|
55
|
+
anchors_1 = [];
|
|
56
|
+
modifiedContent = mdxContent
|
|
57
|
+
.split('\n')
|
|
58
|
+
.map(function (line) {
|
|
59
|
+
var match = line.match(/^(#+)\s+(.*)/);
|
|
60
|
+
if (match) {
|
|
61
|
+
var num = match[1], name_1 = match[2];
|
|
62
|
+
var id = name_1.toLowerCase().replace(/\s+/g, '-');
|
|
63
|
+
var size = num.length;
|
|
64
|
+
anchors_1.push({ name: name_1, id: id, size: size });
|
|
65
|
+
return "<h".concat(size, " id=\"").concat(id, "\">").concat(name_1.replace(/\{|\}/g, ''), "</h").concat(size, ">");
|
|
66
|
+
}
|
|
67
|
+
return line;
|
|
68
|
+
})
|
|
69
|
+
.join('\n');
|
|
70
|
+
_b = String;
|
|
71
|
+
return [4 /*yield*/, compile(modifiedContent, {
|
|
72
|
+
outputFormat: 'function-body',
|
|
73
|
+
remarkPlugins: [remarkGfm],
|
|
74
|
+
rehypePlugins: [rehypeHighlight],
|
|
119
75
|
})];
|
|
76
|
+
case 2:
|
|
77
|
+
code = _b.apply(void 0, [_d.sent()]);
|
|
78
|
+
return [2 /*return*/, {
|
|
79
|
+
path: file,
|
|
80
|
+
meta: frontmatter,
|
|
81
|
+
content: postContent,
|
|
82
|
+
code: code,
|
|
83
|
+
anchors: anchors_1,
|
|
84
|
+
}];
|
|
85
|
+
case 3:
|
|
86
|
+
_c = _d.sent();
|
|
87
|
+
return [2 /*return*/, null];
|
|
88
|
+
case 4: return [2 /*return*/];
|
|
120
89
|
}
|
|
121
90
|
});
|
|
122
91
|
}); });
|
|
123
92
|
export function next(type, config) {
|
|
124
93
|
var dir = path.join(config.contentDir, type);
|
|
94
|
+
var _a = config[type].title, title = _a === void 0 ? 'Shiso' : _a;
|
|
125
95
|
function generateMetadata(_a) {
|
|
126
96
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
127
|
-
var name, content;
|
|
97
|
+
var name, file, content;
|
|
128
98
|
var _c, _d, _e;
|
|
129
99
|
var params = _b.params;
|
|
130
100
|
return __generator(this, function (_f) {
|
|
131
101
|
switch (_f.label) {
|
|
132
102
|
case 0: return [4 /*yield*/, params];
|
|
133
103
|
case 1:
|
|
134
|
-
name = (_d = (_c = (_f.sent())) === null || _c === void 0 ? void 0 : _c.
|
|
135
|
-
|
|
104
|
+
name = ((_d = (_c = (_f.sent())) === null || _c === void 0 ? void 0 : _c.slug) === null || _d === void 0 ? void 0 : _d.join('/')) || 'index';
|
|
105
|
+
file = path.join(dir, "".concat(name, ".mdx"));
|
|
106
|
+
return [4 /*yield*/, getContent(file)];
|
|
136
107
|
case 2:
|
|
137
108
|
content = _f.sent();
|
|
138
109
|
return [2 /*return*/, {
|
|
139
110
|
title: {
|
|
140
|
-
absolute: "".concat((_e = content === null || content === void 0 ? void 0 : content.meta) === null || _e === void 0 ? void 0 : _e.title, " \u2013
|
|
141
|
-
default:
|
|
111
|
+
absolute: "".concat((_e = content === null || content === void 0 ? void 0 : content.meta) === null || _e === void 0 ? void 0 : _e.title, " \u2013 ").concat(title),
|
|
112
|
+
default: title,
|
|
142
113
|
},
|
|
143
114
|
}];
|
|
144
115
|
}
|
|
@@ -147,13 +118,17 @@ export function next(type, config) {
|
|
|
147
118
|
}
|
|
148
119
|
function generateStaticParams() {
|
|
149
120
|
return __awaiter(this, void 0, void 0, function () {
|
|
150
|
-
var
|
|
121
|
+
var files;
|
|
151
122
|
return __generator(this, function (_a) {
|
|
152
123
|
switch (_a.label) {
|
|
153
|
-
case 0: return [4 /*yield*/,
|
|
124
|
+
case 0: return [4 /*yield*/, recursive(dir)];
|
|
154
125
|
case 1:
|
|
155
|
-
|
|
156
|
-
return [2 /*return*/,
|
|
126
|
+
files = _a.sent();
|
|
127
|
+
return [2 /*return*/, files
|
|
128
|
+
.map(function (file) {
|
|
129
|
+
return file.replace('.mdx', '').replace(dir, '').replace(/\\/g, '/').replace(/^\//, '');
|
|
130
|
+
})
|
|
131
|
+
.map(function (id) { return ({
|
|
157
132
|
id: id.split('/'),
|
|
158
133
|
}); })];
|
|
159
134
|
}
|
|
@@ -163,15 +138,16 @@ export function next(type, config) {
|
|
|
163
138
|
function renderPage(render) {
|
|
164
139
|
var _this = this;
|
|
165
140
|
return function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
166
|
-
var name, content;
|
|
141
|
+
var name, file, content;
|
|
167
142
|
var _c, _d;
|
|
168
143
|
var params = _b.params;
|
|
169
144
|
return __generator(this, function (_e) {
|
|
170
145
|
switch (_e.label) {
|
|
171
146
|
case 0: return [4 /*yield*/, params];
|
|
172
147
|
case 1:
|
|
173
|
-
name = (_d = (_c = (_e.sent())) === null || _c === void 0 ? void 0 : _c.
|
|
174
|
-
|
|
148
|
+
name = ((_d = (_c = (_e.sent())) === null || _c === void 0 ? void 0 : _c.slug) === null || _d === void 0 ? void 0 : _d.join('/')) || 'index';
|
|
149
|
+
file = path.join(dir, "".concat(name, ".mdx"));
|
|
150
|
+
return [4 /*yield*/, getContent(file)];
|
|
175
151
|
case 2:
|
|
176
152
|
content = _e.sent();
|
|
177
153
|
return [2 /*return*/, render({ type: type, content: content, config: config })];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umami/shiso",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "A content layer for Next.js",
|
|
5
5
|
"homepage": "https://umami.is/shiso",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@mdx-js/loader": "^3.0.0",
|
|
47
47
|
"@mdx-js/mdx": "^3.1.0",
|
|
48
48
|
"@mdx-js/react": "^3.0.0",
|
|
49
|
-
"@umami/react-zen": "^0.
|
|
49
|
+
"@umami/react-zen": "^0.32.0",
|
|
50
50
|
"classnames": "^2.5.1",
|
|
51
51
|
"glob": "^10.3.10",
|
|
52
52
|
"gray-matter": "^4.0.3",
|
package/server/lib/types.d.ts
DELETED
package/server/lib/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/server/server/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import type { ShisoConfig } from '@/lib/types';
|
|
3
|
-
export declare const getContent: (name: string | undefined, folder: string) => Promise<any>;
|
|
4
|
-
export declare const getContentIds: (folder: string) => Promise<any>;
|
|
5
|
-
export declare function next(type: string, config: ShisoConfig): {
|
|
6
|
-
generateMetadata: ({ params }: {
|
|
7
|
-
params: Promise<{
|
|
8
|
-
id: string[];
|
|
9
|
-
}>;
|
|
10
|
-
}) => Promise<{
|
|
11
|
-
title: {
|
|
12
|
-
absolute: string;
|
|
13
|
-
default: string;
|
|
14
|
-
};
|
|
15
|
-
}>;
|
|
16
|
-
generateStaticParams: () => Promise<any>;
|
|
17
|
-
renderPage: (render: ({ type, content, config, }: {
|
|
18
|
-
type: string;
|
|
19
|
-
content: any;
|
|
20
|
-
config: ShisoConfig;
|
|
21
|
-
}) => ReactElement) => ({ params }: {
|
|
22
|
-
params: Promise<{
|
|
23
|
-
id: string[];
|
|
24
|
-
}>;
|
|
25
|
-
}) => Promise<ReactElement<unknown, string | import("react").JSXElementConstructor<any>>>;
|
|
26
|
-
};
|