@umami/shiso 0.30.0 → 0.32.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 +94 -93
- package/dist/index.d.ts +14 -6
- package/dist/index.js +231 -207
- package/dist/index.mjs +236 -213
- package/package.json +3 -2
- package/server/index.d.ts +3 -19
- package/server/index.js +35 -13
package/dist/index.mjs
CHANGED
|
@@ -5,16 +5,66 @@ import "@umami/react-zen/styles.css";
|
|
|
5
5
|
import "highlight.js/styles/github-dark.css";
|
|
6
6
|
|
|
7
7
|
// src/components/Blog.tsx
|
|
8
|
-
import { Column as Column2 } from "@umami/react-zen";
|
|
8
|
+
import { Heading, Box as Box3, Text as Text2, Row, Column as Column2, Image } from "@umami/react-zen";
|
|
9
|
+
import { format } from "date-fns";
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
-
|
|
11
|
+
// src/components/PageLinks.tsx
|
|
12
|
+
import { useEffect, useState } from "react";
|
|
13
|
+
import { Column, Text, Box } from "@umami/react-zen";
|
|
14
|
+
import classNames from "classnames";
|
|
15
|
+
|
|
16
|
+
// css-modules:E:\dev\umami-shiso\src\components\PageLinks.module.css
|
|
17
|
+
var PageLinks_default = { "links": "PageLinks_links__ZWUxN", "link": "PageLinks_link__MTJmN", "indent-1": "PageLinks_indent-1__MGExM", "indent-2": "PageLinks_indent-2__NDM3O", "indent-3": "PageLinks_indent-3__YmJlN", "indent-4": "PageLinks_indent-4__OTNjM", "indent-5": "PageLinks_indent-5__YTIwM", "indent-6": "PageLinks_indent-6__MjQwY", "selected": "PageLinks_selected__NDA0Y" };
|
|
18
|
+
|
|
19
|
+
// src/components/PageLinks.tsx
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
function PageLinks({ items = [], className, ...props }) {
|
|
22
|
+
const [hash, setHash] = useState(items?.[0]?.id);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const callback = () => {
|
|
25
|
+
const x = [...items].reverse().find(({ id }) => {
|
|
26
|
+
const rect = document.getElementById(id)?.getBoundingClientRect();
|
|
27
|
+
return rect && rect.top <= 0;
|
|
28
|
+
});
|
|
29
|
+
if (x) setHash(x.id);
|
|
30
|
+
};
|
|
31
|
+
window.addEventListener("scroll", callback, false);
|
|
32
|
+
return () => {
|
|
33
|
+
window.removeEventListener("scroll", callback, false);
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
if (!items?.length) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ jsx(Box, { ...props, className: classNames(PageLinks_default.links, className), children: /* @__PURE__ */ jsxs(Column, { gap: "3", minWidth: "240px", children: [
|
|
40
|
+
/* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: "On this page" }),
|
|
41
|
+
items.map(({ name, id, size }) => {
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
"a",
|
|
44
|
+
{
|
|
45
|
+
href: `#${id}`,
|
|
46
|
+
className: classNames(PageLinks_default.link, PageLinks_default[`indent-${size}`], {
|
|
47
|
+
[PageLinks_default.selected]: hash === id
|
|
48
|
+
}),
|
|
49
|
+
children: name
|
|
50
|
+
},
|
|
51
|
+
id
|
|
52
|
+
);
|
|
53
|
+
})
|
|
54
|
+
] }) });
|
|
55
|
+
}
|
|
12
56
|
|
|
13
57
|
// src/components/Markdown.tsx
|
|
58
|
+
import { Box as Box2 } from "@umami/react-zen";
|
|
14
59
|
import { runSync } from "@mdx-js/mdx";
|
|
15
60
|
import { useMDXComponents } from "@mdx-js/react";
|
|
16
61
|
import * as runtime from "react/jsx-runtime";
|
|
17
|
-
|
|
62
|
+
|
|
63
|
+
// css-modules:E:\dev\umami-shiso\src\components\Markdown.module.css
|
|
64
|
+
var Markdown_default = { "content": "Markdown_content__ZDlhO" };
|
|
65
|
+
|
|
66
|
+
// src/components/Markdown.tsx
|
|
67
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
18
68
|
var parseMdx = (code) => {
|
|
19
69
|
try {
|
|
20
70
|
const result = runSync(code, {
|
|
@@ -30,7 +80,7 @@ function Markdown({ code }) {
|
|
|
30
80
|
const components = useMDXComponents();
|
|
31
81
|
const { Component, error } = parseMdx(code);
|
|
32
82
|
if (error) {
|
|
33
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ jsxs2("h1", { children: [
|
|
34
84
|
"Error rendering MDX: ",
|
|
35
85
|
error
|
|
36
86
|
] });
|
|
@@ -38,156 +88,60 @@ function Markdown({ code }) {
|
|
|
38
88
|
if (!Component) {
|
|
39
89
|
return null;
|
|
40
90
|
}
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/components/Blogs.tsx
|
|
45
|
-
import { Column } from "@umami/react-zen";
|
|
46
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
47
|
-
function Blogs() {
|
|
48
|
-
return /* @__PURE__ */ jsx2(Column, { flexGrow: 1, children: /* @__PURE__ */ jsx2("h1", { children: "All the blogs!" }) });
|
|
91
|
+
return /* @__PURE__ */ jsx2(Box2, { className: Markdown_default.content, children: /* @__PURE__ */ jsx2(Component, { components }) });
|
|
49
92
|
}
|
|
50
93
|
|
|
51
94
|
// src/components/Blog.tsx
|
|
52
|
-
import { jsx as jsx3, jsxs as
|
|
53
|
-
function Blog({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
95
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
96
|
+
function Blog({ title, description, code, author, date, image, anchors }) {
|
|
97
|
+
const linksDisplay = {
|
|
98
|
+
default: "none",
|
|
99
|
+
xs: "none",
|
|
100
|
+
sm: "none",
|
|
101
|
+
md: "none",
|
|
102
|
+
lg: "block",
|
|
103
|
+
xl: "block"
|
|
104
|
+
};
|
|
105
|
+
return /* @__PURE__ */ jsxs3(Column2, { gap: "8", maxWidth: "900px", style: { margin: "0 auto" }, children: [
|
|
106
|
+
/* @__PURE__ */ jsx3(Box3, { flexGrow: 1, children: title && /* @__PURE__ */ jsx3(Heading, { size: "1", as: "h1", align: "center", children: title }) }),
|
|
107
|
+
image && /* @__PURE__ */ jsx3(Box3, { height: "480px", children: /* @__PURE__ */ jsx3(Image, { src: image, alt: title, objectFit: "cover", borderRadius: "3" }) }),
|
|
108
|
+
/* @__PURE__ */ jsxs3(Row, { justifyContent: "space-between", children: [
|
|
109
|
+
/* @__PURE__ */ jsx3(Text2, { children: author }),
|
|
110
|
+
/* @__PURE__ */ jsx3(Text2, { children: date && format(new Date(date), "PP") })
|
|
111
|
+
] }),
|
|
112
|
+
/* @__PURE__ */ jsxs3(Row, { gap: "6", children: [
|
|
113
|
+
/* @__PURE__ */ jsx3(Markdown, { code }),
|
|
114
|
+
/* @__PURE__ */ jsx3(PageLinks, { display: linksDisplay, items: anchors })
|
|
115
|
+
] })
|
|
116
|
+
] });
|
|
62
117
|
}
|
|
63
118
|
|
|
64
119
|
// src/components/Docs.tsx
|
|
65
120
|
import {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Heading as Heading2,
|
|
121
|
+
Box as Box6,
|
|
122
|
+
Heading as Heading3,
|
|
69
123
|
Button,
|
|
70
|
-
Icon as
|
|
71
|
-
Icons as
|
|
72
|
-
Row as
|
|
124
|
+
Icon as Icon2,
|
|
125
|
+
Icons as Icons2,
|
|
126
|
+
Row as Row3,
|
|
73
127
|
Modal,
|
|
74
128
|
DialogTrigger,
|
|
75
129
|
Dialog,
|
|
76
|
-
Text as
|
|
130
|
+
Text as Text4
|
|
77
131
|
} from "@umami/react-zen";
|
|
78
132
|
|
|
79
|
-
// src/components/hooks/useShiso.ts
|
|
80
|
-
import { useContext } from "react";
|
|
81
|
-
|
|
82
|
-
// src/components/Shiso.tsx
|
|
83
|
-
import { createContext } from "react";
|
|
84
|
-
import { MDXProvider } from "@mdx-js/react";
|
|
85
|
-
import { Code } from "@umami/react-zen";
|
|
86
|
-
|
|
87
|
-
// src/components/CodeBlock.tsx
|
|
88
|
-
import { useState, useRef } from "react";
|
|
89
|
-
import { Icon, Icons } from "@umami/react-zen";
|
|
90
|
-
|
|
91
|
-
// css-modules:E:\dev\umami-shiso\src\components\CodeBlock.module.css
|
|
92
|
-
var CodeBlock_default = { "container": "CodeBlock_container__ZTkxY", "button": "CodeBlock_button__MmZkO", "copy": "CodeBlock_copy__M2I0N", "check": "CodeBlock_check__MjkzY" };
|
|
93
|
-
|
|
94
|
-
// src/components/CodeBlock.tsx
|
|
95
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
96
|
-
function CodeBlock(props) {
|
|
97
|
-
const textInput = useRef(null);
|
|
98
|
-
const [copied, setCopied] = useState(false);
|
|
99
|
-
const handleCopy = () => {
|
|
100
|
-
setCopied(true);
|
|
101
|
-
navigator?.clipboard?.writeText(textInput?.current?.textContent);
|
|
102
|
-
setTimeout(() => {
|
|
103
|
-
setCopied(false);
|
|
104
|
-
}, 1e3);
|
|
105
|
-
};
|
|
106
|
-
return /* @__PURE__ */ jsxs3("pre", { ref: textInput, className: CodeBlock_default.container, children: [
|
|
107
|
-
props.children,
|
|
108
|
-
/* @__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, {}) }) })
|
|
109
|
-
] });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// src/components/Shiso.tsx
|
|
113
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
114
|
-
var defaultTemplates = {
|
|
115
|
-
docs: Docs,
|
|
116
|
-
blog: Blog
|
|
117
|
-
};
|
|
118
|
-
var ShisoContext = createContext(null);
|
|
119
|
-
function Shiso({ content, type, config, components, templates }) {
|
|
120
|
-
const Component = { ...defaultTemplates, ...templates }[type];
|
|
121
|
-
if (!Component) {
|
|
122
|
-
return /* @__PURE__ */ jsx5("h1", { children: `Component not found for type: ${type}` });
|
|
123
|
-
}
|
|
124
|
-
return /* @__PURE__ */ jsx5(ShisoContext.Provider, { value: { content, type, config }, children: /* @__PURE__ */ jsx5(MDXProvider, { components: { ...components, pre: CodeBlock, code: Code }, children: /* @__PURE__ */ jsx5(Component, { content, config }) }) });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// src/components/hooks/useShiso.ts
|
|
128
|
-
function useShiso() {
|
|
129
|
-
const { content, config } = useContext(ShisoContext);
|
|
130
|
-
return { content, config };
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/components/PageLinks.tsx
|
|
134
|
-
import { useEffect, useState as useState2 } from "react";
|
|
135
|
-
import { Column as Column3, Text, Box } from "@umami/react-zen";
|
|
136
|
-
import classNames from "classnames";
|
|
137
|
-
|
|
138
|
-
// css-modules:E:\dev\umami-shiso\src\components\PageLinks.module.css
|
|
139
|
-
var PageLinks_default = { "links": "PageLinks_links__YmMzM", "link": "PageLinks_link__MjIyN", "indent-1": "PageLinks_indent-1__MDg5M", "indent-2": "PageLinks_indent-2__YTU4M", "indent-3": "PageLinks_indent-3__NTYxY", "indent-4": "PageLinks_indent-4__NjhmY", "indent-5": "PageLinks_indent-5__ZmFiY", "indent-6": "PageLinks_indent-6__MmRkN", "selected": "PageLinks_selected__NDQxY" };
|
|
140
|
-
|
|
141
|
-
// src/components/PageLinks.tsx
|
|
142
|
-
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
143
|
-
function PageLinks({ items = [], className, ...props }) {
|
|
144
|
-
const [hash, setHash] = useState2(items?.[0]?.id);
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
const callback = () => {
|
|
147
|
-
const x = [...items].reverse().find(({ id }) => {
|
|
148
|
-
const rect = document.getElementById(id)?.getBoundingClientRect();
|
|
149
|
-
return rect && rect.top <= 0;
|
|
150
|
-
});
|
|
151
|
-
if (x) setHash(x.id);
|
|
152
|
-
};
|
|
153
|
-
window.addEventListener("scroll", callback, false);
|
|
154
|
-
return () => {
|
|
155
|
-
window.removeEventListener("scroll", callback, false);
|
|
156
|
-
};
|
|
157
|
-
}, []);
|
|
158
|
-
if (!items?.length) {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
return /* @__PURE__ */ jsx6(Box, { ...props, className: classNames(PageLinks_default.links, className), children: /* @__PURE__ */ jsxs4(Column3, { gap: "3", minWidth: "240px", children: [
|
|
162
|
-
/* @__PURE__ */ jsx6(Text, { size: "2", weight: "bold", children: "On this page" }),
|
|
163
|
-
items.map(({ name, id, size }) => {
|
|
164
|
-
return /* @__PURE__ */ jsx6(
|
|
165
|
-
"a",
|
|
166
|
-
{
|
|
167
|
-
href: `#${id}`,
|
|
168
|
-
className: classNames(PageLinks_default.link, PageLinks_default[`indent-${size}`], {
|
|
169
|
-
[PageLinks_default.selected]: hash === id
|
|
170
|
-
}),
|
|
171
|
-
children: name
|
|
172
|
-
},
|
|
173
|
-
id
|
|
174
|
-
);
|
|
175
|
-
})
|
|
176
|
-
] }) });
|
|
177
|
-
}
|
|
178
|
-
|
|
179
133
|
// src/components/SideNav.tsx
|
|
180
|
-
import { useEffect as useEffect2, useState as
|
|
181
|
-
import { Box as
|
|
134
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
135
|
+
import { Box as Box4, List, ListItem, ListSection } from "@umami/react-zen";
|
|
182
136
|
import classNames2 from "classnames";
|
|
183
137
|
import { usePathname } from "next/navigation";
|
|
184
138
|
import Link from "next/link";
|
|
185
139
|
|
|
186
140
|
// css-modules:E:\dev\umami-shiso\src\components\SideNav.module.css
|
|
187
|
-
var SideNav_default = { "nav": "
|
|
141
|
+
var SideNav_default = { "nav": "SideNav_nav__ZDkzM", "sticky": "SideNav_sticky__YzM2M", "item": "SideNav_item__ZWQwY", "selected": "SideNav_selected__OGVhZ", "items": "SideNav_items__OWFkN" };
|
|
188
142
|
|
|
189
143
|
// src/components/SideNav.tsx
|
|
190
|
-
import { jsx as
|
|
144
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
191
145
|
function SideNav({
|
|
192
146
|
tabs,
|
|
193
147
|
navigation,
|
|
@@ -200,7 +154,7 @@ function SideNav({
|
|
|
200
154
|
const pathname = usePathname();
|
|
201
155
|
const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
202
156
|
const menu = navigation[tab?.id || "docs"];
|
|
203
|
-
const [height, setHeight] =
|
|
157
|
+
const [height, setHeight] = useState2();
|
|
204
158
|
useEffect2(() => {
|
|
205
159
|
if (autoHeight) {
|
|
206
160
|
const rect = document.getElementById("shiso_docs_sidenav")?.getBoundingClientRect();
|
|
@@ -209,22 +163,22 @@ function SideNav({
|
|
|
209
163
|
}
|
|
210
164
|
}
|
|
211
165
|
}, [autoHeight]);
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
-
|
|
166
|
+
return /* @__PURE__ */ jsx4(
|
|
167
|
+
Box4,
|
|
214
168
|
{
|
|
215
169
|
...props,
|
|
216
170
|
id: "shiso_docs_sidenav",
|
|
217
171
|
className: classNames2(SideNav_default.nav, isSticky && SideNav_default.sticky, className),
|
|
218
172
|
style: { ...style, height },
|
|
219
|
-
children: /* @__PURE__ */
|
|
220
|
-
return /* @__PURE__ */
|
|
221
|
-
return /* @__PURE__ */
|
|
173
|
+
children: /* @__PURE__ */ jsx4(List, { items: navigation, "aria-label": "nav", children: menu.map(({ section, pages }) => {
|
|
174
|
+
return /* @__PURE__ */ jsx4(ListSection, { title: section, className: SideNav_default.items, children: pages.map(({ label: text, url }, index) => {
|
|
175
|
+
return /* @__PURE__ */ jsx4(
|
|
222
176
|
ListItem,
|
|
223
177
|
{
|
|
224
178
|
className: classNames2(SideNav_default.item, {
|
|
225
179
|
[SideNav_default.selected]: url === pathname
|
|
226
180
|
}),
|
|
227
|
-
children: /* @__PURE__ */
|
|
181
|
+
children: /* @__PURE__ */ jsx4(Link, { href: url, prefetch: false, children: text })
|
|
228
182
|
},
|
|
229
183
|
index
|
|
230
184
|
);
|
|
@@ -238,34 +192,29 @@ function SideNav({
|
|
|
238
192
|
import Link2 from "next/link";
|
|
239
193
|
import { usePathname as usePathname2 } from "next/navigation";
|
|
240
194
|
import { Tabs, TabList, Tab } from "@umami/react-zen";
|
|
241
|
-
import { jsx as
|
|
195
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
242
196
|
function TopNav({ tabs }) {
|
|
243
197
|
const pathname = usePathname2();
|
|
244
198
|
const tab = tabs?.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
245
199
|
const selected = tab?.id || "docs";
|
|
246
|
-
return /* @__PURE__ */
|
|
247
|
-
return /* @__PURE__ */
|
|
200
|
+
return /* @__PURE__ */ jsx5(Tabs, { selectedKey: selected, children: /* @__PURE__ */ jsx5(TabList, { items: tabs, children: ({ id, label, url }) => {
|
|
201
|
+
return /* @__PURE__ */ jsx5(Tab, { id, children: /* @__PURE__ */ jsx5(Link2, { href: url, children: label }) });
|
|
248
202
|
} }) });
|
|
249
203
|
}
|
|
250
204
|
|
|
251
|
-
// src/components/
|
|
252
|
-
import { Heading, Box as
|
|
253
|
-
|
|
254
|
-
// css-modules:E:\dev\umami-shiso\src\components\ContentArea.module.css
|
|
255
|
-
var ContentArea_default = { "content": "ContentArea_content__MTM4Z" };
|
|
256
|
-
|
|
257
|
-
// src/components/ContentArea.tsx
|
|
205
|
+
// src/components/DocContent.tsx
|
|
206
|
+
import { Heading as Heading2, Box as Box5, Text as Text3, Row as Row2, Icon, Icons } from "@umami/react-zen";
|
|
258
207
|
import Link3 from "next/link";
|
|
259
|
-
import { jsx as
|
|
260
|
-
function
|
|
261
|
-
return /* @__PURE__ */
|
|
262
|
-
section && /* @__PURE__ */
|
|
263
|
-
title && /* @__PURE__ */
|
|
264
|
-
description && /* @__PURE__ */
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
-
/* @__PURE__ */
|
|
268
|
-
/* @__PURE__ */
|
|
208
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
209
|
+
function DocContent({ section, title, description, code, next, prev }) {
|
|
210
|
+
return /* @__PURE__ */ jsxs4(Box5, { flexGrow: 1, children: [
|
|
211
|
+
section && /* @__PURE__ */ jsx6(Text3, { color: "primary", weight: "bold", children: section }),
|
|
212
|
+
title && /* @__PURE__ */ jsx6(Heading2, { size: "2", as: "h1", marginY: "3", children: title }),
|
|
213
|
+
description && /* @__PURE__ */ jsx6(Text3, { color: "muted", size: "3", children: description }),
|
|
214
|
+
/* @__PURE__ */ jsx6(Markdown, { code }),
|
|
215
|
+
/* @__PURE__ */ jsxs4(Row2, { justifyContent: "space-between", children: [
|
|
216
|
+
/* @__PURE__ */ jsx6(NavigationButton, { ...prev, isPrev: true }),
|
|
217
|
+
/* @__PURE__ */ jsx6(NavigationButton, { ...next })
|
|
269
218
|
] })
|
|
270
219
|
] });
|
|
271
220
|
}
|
|
@@ -275,17 +224,17 @@ var NavigationButton = ({
|
|
|
275
224
|
isPrev
|
|
276
225
|
}) => {
|
|
277
226
|
if (!url || !label) {
|
|
278
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ jsx6(Box5, {});
|
|
279
228
|
}
|
|
280
|
-
return /* @__PURE__ */
|
|
281
|
-
isPrev && /* @__PURE__ */
|
|
282
|
-
/* @__PURE__ */
|
|
283
|
-
!isPrev && /* @__PURE__ */
|
|
229
|
+
return /* @__PURE__ */ jsx6(Link3, { href: url, children: /* @__PURE__ */ jsxs4(Row2, { alignItems: "center", gap: "3", marginY: "3", children: [
|
|
230
|
+
isPrev && /* @__PURE__ */ jsx6(Icon, { size: "sm", rotate: 180, children: /* @__PURE__ */ jsx6(Icons.Chevron, {}) }),
|
|
231
|
+
/* @__PURE__ */ jsx6(Text3, { size: "3", weight: "bold", children: label }),
|
|
232
|
+
!isPrev && /* @__PURE__ */ jsx6(Icon, { size: "sm", children: /* @__PURE__ */ jsx6(Icons.Chevron, {}) })
|
|
284
233
|
] }) });
|
|
285
234
|
};
|
|
286
235
|
|
|
287
236
|
// src/components/Docs.tsx
|
|
288
|
-
import { Fragment, jsx as
|
|
237
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
289
238
|
function parseContent(content, config = {}) {
|
|
290
239
|
const { tabs, navigation } = config;
|
|
291
240
|
const keys = Object.keys(navigation);
|
|
@@ -310,10 +259,9 @@ function parseContent(content, config = {}) {
|
|
|
310
259
|
});
|
|
311
260
|
return { ...content, tabs, navigation, section, next, prev };
|
|
312
261
|
}
|
|
313
|
-
function Docs() {
|
|
314
|
-
const { content, config } = useShiso();
|
|
262
|
+
function Docs({ content, config }) {
|
|
315
263
|
if (!content) {
|
|
316
|
-
return /* @__PURE__ */
|
|
264
|
+
return /* @__PURE__ */ jsx7(Heading3, { children: "Page not found" });
|
|
317
265
|
}
|
|
318
266
|
const { tabs, navigation, code, meta, section, next, prev, anchors } = parseContent(
|
|
319
267
|
content,
|
|
@@ -340,55 +288,130 @@ function Docs() {
|
|
|
340
288
|
lg: "none",
|
|
341
289
|
xl: "none"
|
|
342
290
|
};
|
|
343
|
-
const MobileMenuButton = () => /* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */
|
|
291
|
+
const MobileMenuButton = () => /* @__PURE__ */ jsxs5(DialogTrigger, { children: [
|
|
292
|
+
/* @__PURE__ */ jsxs5(Button, { children: [
|
|
293
|
+
/* @__PURE__ */ jsx7(Icon2, { children: /* @__PURE__ */ jsx7(Icons2.Menu, {}) }),
|
|
294
|
+
/* @__PURE__ */ jsx7(Text4, { children: "Menu" })
|
|
347
295
|
] }),
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
return /* @__PURE__ */
|
|
350
|
-
/* @__PURE__ */
|
|
351
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ jsx7(Modal, { position: "bottom", offset: "40px", children: /* @__PURE__ */ jsx7(Dialog, { variant: "sheet", children: ({ close }) => {
|
|
297
|
+
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
298
|
+
/* @__PURE__ */ jsx7(Row3, { justifyContent: "flex-end", children: /* @__PURE__ */ jsx7(Button, { onPress: () => close(), variant: "quiet", children: /* @__PURE__ */ jsx7(Icon2, { size: "sm", children: /* @__PURE__ */ jsx7(Icons2.Close, {}) }) }) }),
|
|
299
|
+
/* @__PURE__ */ jsx7(Box6, { height: "100%", overflow: "auto", children: /* @__PURE__ */ jsx7(SideNav, { tabs, navigation }) })
|
|
352
300
|
] });
|
|
353
301
|
} }) })
|
|
354
302
|
] });
|
|
355
|
-
return /* @__PURE__ */
|
|
356
|
-
/* @__PURE__ */
|
|
357
|
-
tabs && /* @__PURE__ */
|
|
358
|
-
/* @__PURE__ */
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
prev
|
|
384
|
-
}
|
|
385
|
-
),
|
|
386
|
-
/* @__PURE__ */ jsx10(PageLinks, { display: linksDisplay, items: anchors, style: { top } })
|
|
387
|
-
]
|
|
388
|
-
}
|
|
389
|
-
)
|
|
303
|
+
return /* @__PURE__ */ jsxs5(Box6, { flexGrow: "1", children: [
|
|
304
|
+
/* @__PURE__ */ jsx7(Row3, { display: menuDisplay, justifyContent: "flex-end", children: /* @__PURE__ */ jsx7(MobileMenuButton, {}) }),
|
|
305
|
+
tabs && /* @__PURE__ */ jsx7(TopNav, { tabs }),
|
|
306
|
+
/* @__PURE__ */ jsxs5(Row3, { gap: "6", children: [
|
|
307
|
+
/* @__PURE__ */ jsx7(
|
|
308
|
+
SideNav,
|
|
309
|
+
{
|
|
310
|
+
display: navDisplay,
|
|
311
|
+
tabs,
|
|
312
|
+
navigation,
|
|
313
|
+
style: { top },
|
|
314
|
+
isSticky: true,
|
|
315
|
+
autoHeight: true
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
/* @__PURE__ */ jsx7(
|
|
319
|
+
DocContent,
|
|
320
|
+
{
|
|
321
|
+
section,
|
|
322
|
+
title: meta?.title,
|
|
323
|
+
description: meta?.description,
|
|
324
|
+
code,
|
|
325
|
+
next,
|
|
326
|
+
prev
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ jsx7(PageLinks, { display: linksDisplay, items: anchors, style: { top } })
|
|
330
|
+
] })
|
|
390
331
|
] });
|
|
391
332
|
}
|
|
333
|
+
|
|
334
|
+
// src/components/Shiso.tsx
|
|
335
|
+
import { createContext } from "react";
|
|
336
|
+
import { MDXProvider } from "@mdx-js/react";
|
|
337
|
+
import { Code } from "@umami/react-zen";
|
|
338
|
+
|
|
339
|
+
// src/components/CodeBlock.tsx
|
|
340
|
+
import { useState as useState3, useRef } from "react";
|
|
341
|
+
import { Icon as Icon3, Icons as Icons3 } from "@umami/react-zen";
|
|
342
|
+
|
|
343
|
+
// css-modules:E:\dev\umami-shiso\src\components\CodeBlock.module.css
|
|
344
|
+
var CodeBlock_default = { "container": "CodeBlock_container__ZTkxY", "button": "CodeBlock_button__MmZkO", "copy": "CodeBlock_copy__M2I0N", "check": "CodeBlock_check__MjkzY" };
|
|
345
|
+
|
|
346
|
+
// src/components/CodeBlock.tsx
|
|
347
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
348
|
+
function CodeBlock(props) {
|
|
349
|
+
const textInput = useRef(null);
|
|
350
|
+
const [copied, setCopied] = useState3(false);
|
|
351
|
+
const handleCopy = () => {
|
|
352
|
+
setCopied(true);
|
|
353
|
+
navigator?.clipboard?.writeText(textInput?.current?.textContent);
|
|
354
|
+
setTimeout(() => {
|
|
355
|
+
setCopied(false);
|
|
356
|
+
}, 1e3);
|
|
357
|
+
};
|
|
358
|
+
return /* @__PURE__ */ jsxs6("pre", { ref: textInput, className: CodeBlock_default.container, children: [
|
|
359
|
+
props.children,
|
|
360
|
+
/* @__PURE__ */ jsx8("button", { "aria-label": "Copy code", className: CodeBlock_default.button, onClick: handleCopy, children: /* @__PURE__ */ jsx8(Icon3, { size: "sm", className: copied ? CodeBlock_default.check : CodeBlock_default.copy, children: copied ? /* @__PURE__ */ jsx8(Icons3.Check, {}) : /* @__PURE__ */ jsx8(Icons3.Copy, {}) }) })
|
|
361
|
+
] });
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/components/Blogs.tsx
|
|
365
|
+
import { Grid } from "@umami/react-zen";
|
|
366
|
+
|
|
367
|
+
// src/components/Card.tsx
|
|
368
|
+
import { Box as Box7, Image as Image2, Column as Column3, Row as Row4, Heading as Heading4, Text as Text5, Button as Button2, Icon as Icon4, Icons as Icons4 } from "@umami/react-zen";
|
|
369
|
+
import Link4 from "next/link";
|
|
370
|
+
import { format as format2 } from "date-fns";
|
|
371
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
372
|
+
function Card({ title, description, date, author, url, image }) {
|
|
373
|
+
return /* @__PURE__ */ jsxs7(Column3, { borderSize: "1", borderRadius: "3", overflow: "hidden", children: [
|
|
374
|
+
image && /* @__PURE__ */ jsx9(Box7, { height: "240px", children: /* @__PURE__ */ jsx9(Image2, { src: image, alt: title, objectFit: "cover" }) }),
|
|
375
|
+
/* @__PURE__ */ jsxs7(Column3, { padding: "6", gap: "4", children: [
|
|
376
|
+
/* @__PURE__ */ jsx9(Heading4, { size: "4", as: "header", children: /* @__PURE__ */ jsx9(Link4, { href: url, children: title }) }),
|
|
377
|
+
/* @__PURE__ */ jsxs7(Row4, { justifyContent: "space-between", children: [
|
|
378
|
+
/* @__PURE__ */ jsx9(Text5, { color: "muted", children: date && format2(new Date(date), "PP") }),
|
|
379
|
+
/* @__PURE__ */ jsx9(Text5, { color: "muted", children: author })
|
|
380
|
+
] }),
|
|
381
|
+
/* @__PURE__ */ jsx9(Box7, { marginY: "5", as: "p", children: /* @__PURE__ */ jsx9(Text5, { size: "3", children: description }) }),
|
|
382
|
+
/* @__PURE__ */ jsx9(Button2, { asChild: true, children: /* @__PURE__ */ jsxs7(Link4, { href: url, children: [
|
|
383
|
+
/* @__PURE__ */ jsx9(Text5, { children: "Read more" }),
|
|
384
|
+
/* @__PURE__ */ jsx9(Icon4, { children: /* @__PURE__ */ jsx9(Icons4.Arrow, {}) })
|
|
385
|
+
] }) })
|
|
386
|
+
] })
|
|
387
|
+
] });
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/components/Blogs.tsx
|
|
391
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
392
|
+
function Blogs({ content, config }) {
|
|
393
|
+
if (!Array.isArray(content)) {
|
|
394
|
+
const { meta, code, anchors, slug } = content;
|
|
395
|
+
return /* @__PURE__ */ jsx10(Blog, { ...meta, code, anchors });
|
|
396
|
+
}
|
|
397
|
+
console.log({ content });
|
|
398
|
+
return /* @__PURE__ */ jsx10(Grid, { gap: "5", columns: "repeat(auto-fit, minmax(400px, 1fr)", children: content?.sort((a, b) => new Date(b.meta.date).getTime() - new Date(a.meta.date).getTime()).map(({ meta, slug }) => /* @__PURE__ */ jsx10(Card, { url: `/blog/${slug}`, ...meta }, slug)) });
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// src/components/Shiso.tsx
|
|
402
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
403
|
+
var defaultTemplates = {
|
|
404
|
+
docs: Docs,
|
|
405
|
+
blog: Blogs
|
|
406
|
+
};
|
|
407
|
+
var ShisoContext = createContext(null);
|
|
408
|
+
function Shiso({ type, config, content, components, templates }) {
|
|
409
|
+
const Component = { ...defaultTemplates, ...templates }[type];
|
|
410
|
+
if (!Component) {
|
|
411
|
+
return /* @__PURE__ */ jsx11("h1", { children: `Component not found for type: ${type}` });
|
|
412
|
+
}
|
|
413
|
+
return /* @__PURE__ */ jsx11(ShisoContext.Provider, { value: { type, config, content, components, templates }, children: /* @__PURE__ */ jsx11(MDXProvider, { components: { ...components, pre: CodeBlock, code: Code }, children: /* @__PURE__ */ jsx11(Component, { config, content }) }) });
|
|
414
|
+
}
|
|
392
415
|
export {
|
|
393
416
|
Blog,
|
|
394
417
|
Docs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umami/shiso",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "A content layer for Next.js",
|
|
5
5
|
"homepage": "https://umami.is/shiso",
|
|
6
6
|
"repository": {
|
|
@@ -46,8 +46,9 @@
|
|
|
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.42.0",
|
|
50
50
|
"classnames": "^2.5.1",
|
|
51
|
+
"date-fns": "^4.1.0",
|
|
51
52
|
"glob": "^10.3.10",
|
|
52
53
|
"gray-matter": "^4.0.3",
|
|
53
54
|
"highlight.js": "^11.11.1",
|
package/server/index.d.ts
CHANGED
|
@@ -5,20 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
declare module '@umami/shiso/server' {
|
|
7
7
|
import { ReactElement } from 'react';
|
|
8
|
-
import type { ShisoConfig } from '@/lib/types';
|
|
9
|
-
export const
|
|
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>;
|
|
8
|
+
import type { ShisoConfig, ShisoRenderProps, ShisoContent } from '@/lib/types';
|
|
9
|
+
export const parseFile: (file: string) => Promise<ShisoContent | null>;
|
|
22
10
|
export function next(type: string, config: ShisoConfig): {
|
|
23
11
|
generateMetadata: ({ params }: {
|
|
24
12
|
params: Promise<{
|
|
@@ -31,11 +19,7 @@ declare module '@umami/shiso/server' {
|
|
|
31
19
|
};
|
|
32
20
|
}>;
|
|
33
21
|
generateStaticParams: () => Promise<any>;
|
|
34
|
-
renderPage: (render: (
|
|
35
|
-
type: string;
|
|
36
|
-
content: any;
|
|
37
|
-
config: ShisoConfig;
|
|
38
|
-
}) => ReactElement) => ({ params }: {
|
|
22
|
+
renderPage: (render: (props: ShisoRenderProps) => ReactElement) => ({ params }: {
|
|
39
23
|
params: Promise<{
|
|
40
24
|
slug: string[];
|
|
41
25
|
}>;
|