@umami/shiso 0.55.0 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +9 -49
  3. package/bin/shiso.mjs +132 -0
  4. package/docs.schema.json +835 -0
  5. package/mdx.config.ts +143 -0
  6. package/package.json +73 -83
  7. package/scripts/check-package.mjs +18 -0
  8. package/scripts/generate-icon-registry.mjs +196 -0
  9. package/scripts/generate-last-modified.mjs +128 -0
  10. package/scripts/generate-search-index.mjs +252 -0
  11. package/scripts/load-docs-config.mjs +244 -0
  12. package/scripts/prerender.mjs +187 -0
  13. package/scripts/validate-config.mjs +104 -0
  14. package/scripts/vite-docs-config.mjs +60 -0
  15. package/src/App.tsx +39 -0
  16. package/src/components/Banner.tsx +69 -0
  17. package/src/components/CodeBlock.tsx +46 -0
  18. package/src/components/ConfiguredIcon.tsx +15 -0
  19. package/src/components/ContextualMenu.tsx +93 -0
  20. package/src/components/DocContent.tsx +100 -0
  21. package/src/components/Docs.tsx +126 -0
  22. package/src/components/Footer.tsx +84 -0
  23. package/src/components/Header.tsx +72 -0
  24. package/src/components/Layout.tsx +16 -0
  25. package/src/components/PageLinks.tsx +71 -0
  26. package/src/components/Search.tsx +208 -0
  27. package/src/components/SideNav.tsx +347 -0
  28. package/src/components/SocialIcon.tsx +88 -0
  29. package/src/components/ThemeToggle.tsx +34 -0
  30. package/src/components/TopNav.tsx +127 -0
  31. package/src/components/docs/Accordion.tsx +68 -0
  32. package/src/components/docs/Badge.tsx +171 -0
  33. package/src/components/docs/Callout.tsx +73 -0
  34. package/src/components/docs/Card.tsx +158 -0
  35. package/src/components/docs/CodeGroup.tsx +73 -0
  36. package/src/components/docs/Columns.tsx +20 -0
  37. package/src/components/docs/Expandable.tsx +28 -0
  38. package/src/components/docs/Frame.tsx +56 -0
  39. package/src/components/docs/Icon.tsx +30 -0
  40. package/src/components/docs/ParamField.tsx +45 -0
  41. package/src/components/docs/PropertiesTable.tsx +84 -0
  42. package/src/components/docs/ResponseField.tsx +36 -0
  43. package/src/components/docs/Steps.tsx +47 -0
  44. package/src/components/docs/Tabs.tsx +116 -0
  45. package/src/components/docs/Tooltip.tsx +21 -0
  46. package/src/components/docs/index.ts +15 -0
  47. package/src/components/docs/styles.ts +82 -0
  48. package/src/components/docs/utils.ts +118 -0
  49. package/src/components/icons/index.ts +17 -0
  50. package/src/components/ui/accordion.tsx +69 -0
  51. package/src/components/ui/alert.tsx +69 -0
  52. package/src/components/ui/badge.tsx +49 -0
  53. package/src/components/ui/button.tsx +58 -0
  54. package/src/components/ui/card.tsx +88 -0
  55. package/src/components/ui/collapsible.tsx +15 -0
  56. package/src/components/ui/command.tsx +173 -0
  57. package/src/components/ui/dialog.tsx +137 -0
  58. package/src/components/ui/dropdown-menu.tsx +257 -0
  59. package/src/components/ui/scroll-area.tsx +71 -0
  60. package/src/components/ui/sheet.tsx +124 -0
  61. package/src/components/ui/tabs.tsx +73 -0
  62. package/src/components/ui/tooltip.tsx +52 -0
  63. package/src/declarations.d.ts +9 -0
  64. package/src/entry-client.tsx +17 -0
  65. package/src/entry-server.tsx +77 -0
  66. package/src/generated/last-modified.ts +2 -0
  67. package/src/lib/content.ts +44 -0
  68. package/src/lib/docs-config.ts +682 -0
  69. package/src/lib/head.ts +220 -0
  70. package/src/lib/icon-registry.generated.ts +4 -0
  71. package/src/lib/icons.ts +29 -0
  72. package/src/lib/inline-markdown.tsx +86 -0
  73. package/src/lib/mdast.ts +56 -0
  74. package/src/lib/paths.ts +86 -0
  75. package/src/lib/remark-toc.ts +71 -0
  76. package/src/lib/search/config.ts +43 -0
  77. package/src/lib/search/provider.ts +80 -0
  78. package/src/lib/search/providers/local.ts +15 -0
  79. package/src/lib/search-index.generated.ts +4 -0
  80. package/src/lib/search.ts +100 -0
  81. package/src/lib/site-config.ts +104 -0
  82. package/src/lib/site-model.ts +221 -0
  83. package/src/lib/slug.ts +38 -0
  84. package/src/lib/types.ts +478 -0
  85. package/src/lib/utils.ts +6 -0
  86. package/src/pages/DocPage.tsx +33 -0
  87. package/src/styles/global.css +268 -0
  88. package/src/styles/tokens.css +114 -0
  89. package/types/client.d.ts +3 -0
  90. package/types/search.d.ts +17 -0
  91. package/vite.config.ts +342 -0
  92. package/LICENSE +0 -21
  93. package/dist/index.css +0 -189
  94. package/dist/index.d.ts +0 -57
  95. package/dist/index.js +0 -464
  96. package/dist/index.mjs +0 -437
  97. package/server/index.d.ts +0 -30
  98. package/server/index.js +0 -189
  99. package/styles.css +0 -4766
package/dist/index.mjs DELETED
@@ -1,437 +0,0 @@
1
- "use client";
2
-
3
- // src/components/Blog.tsx
4
- import { Heading as Heading4, Box as Box7, Text as Text6, Row as Row4, Column as Column5, Image as Image2, Icon as Icon5, Icons as Icons5, Button as Button3 } from "@umami/react-zen";
5
- import { format as format2 } from "date-fns";
6
-
7
- // src/components/PageLinks.tsx
8
- import { useEffect, useState } from "react";
9
- import { Column, Text, Box } from "@umami/react-zen";
10
- import classNames from "classnames";
11
-
12
- // css-modules:E:\dev\umami-shiso\src\components\PageLinks.module.css
13
- var PageLinks_default = { "links": "PageLinks_links__NmJhO", "link": "PageLinks_link__OGI3M", "indent-1": "PageLinks_indent-1__M2IxZ", "indent-2": "PageLinks_indent-2__YTBlM", "indent-3": "PageLinks_indent-3__YzJlZ", "indent-4": "PageLinks_indent-4__NDg3Z", "indent-5": "PageLinks_indent-5__ZTE4M", "indent-6": "PageLinks_indent-6__NTRjM", "selected": "PageLinks_selected__ZjhkN" };
14
-
15
- // src/components/PageLinks.tsx
16
- import { jsx, jsxs } from "react/jsx-runtime";
17
- function PageLinks({ items = [], className, ...props }) {
18
- const [hash, setHash] = useState(items?.[0]?.id);
19
- useEffect(() => {
20
- const callback = () => {
21
- const x = [...items].reverse().find(({ id }) => {
22
- const rect = document.getElementById(id)?.getBoundingClientRect();
23
- return rect && rect.top <= 0;
24
- });
25
- if (x) setHash(x.id);
26
- };
27
- window.addEventListener("scroll", callback, false);
28
- return () => {
29
- window.removeEventListener("scroll", callback, false);
30
- };
31
- }, []);
32
- if (!items?.length) {
33
- return null;
34
- }
35
- return /* @__PURE__ */ jsx(Box, { ...props, className: classNames(PageLinks_default.links, className), children: /* @__PURE__ */ jsxs(Column, { gap: "3", minWidth: "240px", children: [
36
- /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: "On this page" }),
37
- items.map(({ name, id, size }) => {
38
- return /* @__PURE__ */ jsx(
39
- "a",
40
- {
41
- href: `#${id}`,
42
- className: classNames(PageLinks_default.link, PageLinks_default[`indent-${size}`], {
43
- [PageLinks_default.selected]: hash === id
44
- }),
45
- children: name
46
- },
47
- id
48
- );
49
- })
50
- ] }) });
51
- }
52
-
53
- // src/components/hooks/useShiso.ts
54
- import { useContext } from "react";
55
-
56
- // src/components/Shiso.tsx
57
- import { createContext } from "react";
58
- import { MDXProvider } from "@mdx-js/react";
59
- import { Code } from "@umami/react-zen";
60
-
61
- // src/components/CodeBlock.tsx
62
- import { useState as useState2, useRef } from "react";
63
- import classNames2 from "classnames";
64
- import { Icon, Icons } from "@umami/react-zen";
65
-
66
- // css-modules:E:\dev\umami-shiso\src\components\CodeBlock.module.css
67
- var CodeBlock_default = { "container": "CodeBlock_container__OGZlM", "button": "CodeBlock_button__Y2Y2Z", "copy": "CodeBlock_copy__NWI2Y", "check": "CodeBlock_check__YzQzO" };
68
-
69
- // src/components/CodeBlock.tsx
70
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
71
- function CodeBlock(props) {
72
- const textInput = useRef(null);
73
- const [copied, setCopied] = useState2(false);
74
- const handleCopy = () => {
75
- setCopied(true);
76
- navigator?.clipboard?.writeText(textInput?.current?.textContent);
77
- setTimeout(() => {
78
- setCopied(false);
79
- }, 1e3);
80
- };
81
- return /* @__PURE__ */ jsxs2("pre", { ref: textInput, className: classNames2(CodeBlock_default.container, "dark-theme"), children: [
82
- props.children,
83
- /* @__PURE__ */ jsx2("button", { "aria-label": "Copy code", className: CodeBlock_default.button, onClick: handleCopy, children: /* @__PURE__ */ jsx2(Icon, { size: "sm", className: copied ? CodeBlock_default.check : CodeBlock_default.copy, children: copied ? /* @__PURE__ */ jsx2(Icons.Check, {}) : /* @__PURE__ */ jsx2(Icons.Copy, {}) }) })
84
- ] });
85
- }
86
-
87
- // src/components/Docs.tsx
88
- import {
89
- Box as Box5,
90
- Heading as Heading2,
91
- Button,
92
- Icon as Icon3,
93
- Icons as Icons3,
94
- Row as Row2,
95
- Column as Column3,
96
- Modal,
97
- DialogTrigger,
98
- Dialog,
99
- Text as Text4
100
- } from "@umami/react-zen";
101
-
102
- // src/components/SideNav.tsx
103
- import { useEffect as useEffect2, useState as useState3 } from "react";
104
- import { Text as Text2, Column as Column2 } from "@umami/react-zen";
105
- import classNames3 from "classnames";
106
- import { usePathname } from "next/navigation";
107
- import Link from "next/link";
108
-
109
- // css-modules:E:\dev\umami-shiso\src\components\SideNav.module.css
110
- var SideNav_default = { "nav": "SideNav_nav__YjQxN", "sticky": "SideNav_sticky__ZTI5N", "item": "SideNav_item__NWU0N", "selected": "SideNav_selected__OTY3O", "header": "SideNav_header__NDZjN" };
111
-
112
- // src/components/SideNav.tsx
113
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
114
- function SideNav({
115
- tabs,
116
- navigation,
117
- isSticky,
118
- autoHeight,
119
- className,
120
- style,
121
- ...props
122
- }) {
123
- const pathname = usePathname();
124
- const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
125
- const menu = navigation[tab?.id || "docs"];
126
- const [height, setHeight] = useState3();
127
- useEffect2(() => {
128
- if (autoHeight) {
129
- const rect = document.getElementById("shiso_docs_sidenav")?.getBoundingClientRect();
130
- if (rect) {
131
- setHeight(`${window.innerHeight - rect.top - 10}px`);
132
- }
133
- }
134
- }, [autoHeight]);
135
- return /* @__PURE__ */ jsx3(
136
- Column2,
137
- {
138
- ...props,
139
- id: "shiso_docs_sidenav",
140
- className: classNames3(SideNav_default.nav, isSticky && SideNav_default.sticky, className),
141
- style: { ...style, height },
142
- children: /* @__PURE__ */ jsx3(Column2, { "aria-label": "nav", gap: "6", children: menu.map(({ section, pages }) => {
143
- return /* @__PURE__ */ jsxs3(Column2, { title: section, className: SideNav_default.items, children: [
144
- /* @__PURE__ */ jsx3(Text2, { weight: "bold", className: SideNav_default.header, children: section }),
145
- pages.map(({ label: text, url }, index) => {
146
- return /* @__PURE__ */ jsx3(
147
- Link,
148
- {
149
- className: classNames3(SideNav_default.item, {
150
- [SideNav_default.selected]: url === pathname
151
- }),
152
- href: url,
153
- children: text
154
- },
155
- index
156
- );
157
- })
158
- ] }, section);
159
- }) })
160
- }
161
- );
162
- }
163
-
164
- // src/components/TopNav.tsx
165
- import { usePathname as usePathname2 } from "next/navigation";
166
- import { Box as Box2, Tabs, TabList, Tab } from "@umami/react-zen";
167
- import Link2 from "next/link";
168
- import { jsx as jsx4 } from "react/jsx-runtime";
169
- function TopNav({ tabs }) {
170
- const pathname = usePathname2();
171
- const tab = tabs?.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
172
- const selected = tab?.id || "docs";
173
- return /* @__PURE__ */ jsx4(Box2, { maxWidth: "100vw", overflowX: "auto", overflowY: "hidden", children: /* @__PURE__ */ jsx4(Tabs, { selectedKey: selected, children: /* @__PURE__ */ jsx4(TabList, { items: tabs, children: ({ id, label, url }) => {
174
- return /* @__PURE__ */ jsx4(Tab, { id, children: /* @__PURE__ */ jsx4(Link2, { href: url, children: label }) });
175
- } }) }) });
176
- }
177
-
178
- // src/components/DocContent.tsx
179
- import { Heading, Box as Box4, Text as Text3, Row, Icon as Icon2, Icons as Icons2 } from "@umami/react-zen";
180
- import Link3 from "next/link";
181
-
182
- // src/components/Markdown.tsx
183
- import { Box as Box3 } from "@umami/react-zen";
184
- import { runSync } from "@mdx-js/mdx";
185
- import { useMDXComponents } from "@mdx-js/react";
186
- import * as runtime from "react/jsx-runtime";
187
-
188
- // css-modules:E:\dev\umami-shiso\src\components\Markdown.module.css
189
- var Markdown_default = { "content": "Markdown_content__YzRmN" };
190
-
191
- // src/components/Markdown.tsx
192
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
193
- var parseMdx = (code) => {
194
- try {
195
- const result = runSync(code, {
196
- ...runtime,
197
- baseUrl: import.meta.url
198
- });
199
- return { Component: result.default };
200
- } catch (err) {
201
- return { error: err.message };
202
- }
203
- };
204
- function Markdown({ code }) {
205
- const components = useMDXComponents();
206
- const { Component, error } = parseMdx(code);
207
- if (error) {
208
- return /* @__PURE__ */ jsxs4("h1", { children: [
209
- "Error rendering MDX: ",
210
- error
211
- ] });
212
- }
213
- if (!Component) {
214
- return null;
215
- }
216
- return /* @__PURE__ */ jsx5(Box3, { className: Markdown_default.content, children: /* @__PURE__ */ jsx5(Component, { components }) });
217
- }
218
-
219
- // src/components/DocContent.tsx
220
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
221
- function DocContent({ section, title, description, code, next, prev }) {
222
- return /* @__PURE__ */ jsxs5(Box4, { flexGrow: "1", children: [
223
- section && /* @__PURE__ */ jsx6(Text3, { color: "primary", weight: "bold", children: section }),
224
- title && /* @__PURE__ */ jsx6(Heading, { size: "5", as: "h1", marginY: "3", children: title }),
225
- description && /* @__PURE__ */ jsx6(Text3, { color: "muted", size: "3", children: description }),
226
- /* @__PURE__ */ jsx6(Markdown, { code }),
227
- /* @__PURE__ */ jsxs5(Row, { justifyContent: "space-between", children: [
228
- /* @__PURE__ */ jsx6(NavigationButton, { ...prev, isPrev: true }),
229
- /* @__PURE__ */ jsx6(NavigationButton, { ...next })
230
- ] })
231
- ] });
232
- }
233
- var NavigationButton = ({
234
- label,
235
- url,
236
- isPrev
237
- }) => {
238
- if (!url || !label) {
239
- return /* @__PURE__ */ jsx6(Box4, {});
240
- }
241
- return /* @__PURE__ */ jsx6(Link3, { href: url, children: /* @__PURE__ */ jsxs5(Row, { alignItems: "center", gap: "3", marginY: "3", children: [
242
- isPrev && /* @__PURE__ */ jsx6(Icon2, { size: "sm", rotate: 180, children: /* @__PURE__ */ jsx6(Icons2.Chevron, {}) }),
243
- /* @__PURE__ */ jsx6(Text3, { size: "3", weight: "bold", children: label }),
244
- !isPrev && /* @__PURE__ */ jsx6(Icon2, { size: "sm", children: /* @__PURE__ */ jsx6(Icons2.Chevron, {}) })
245
- ] }) });
246
- };
247
-
248
- // src/components/Docs.tsx
249
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
250
- function parseContent(content, config = {}) {
251
- const { tabs, navigation } = config;
252
- const keys = Object.keys(navigation);
253
- let next, prev, section, found;
254
- keys.forEach((key) => {
255
- if (!found) {
256
- const groups = navigation[key];
257
- found = groups?.find((group, groupIndex) => {
258
- return group.pages.find((page, pageIndex) => {
259
- const match = page.url.endsWith(content.slug) || content.slug === "index" && content.path.endsWith("index.mdx");
260
- if (match) {
261
- const prevGroup = groups[groupIndex - 1];
262
- const nextGroup = groups[groupIndex + 1];
263
- prev = group.pages[pageIndex - 1] || prevGroup?.pages?.at(-1);
264
- next = group.pages[pageIndex + 1] || nextGroup?.pages?.[0];
265
- section = group.section;
266
- }
267
- return match;
268
- });
269
- });
270
- }
271
- });
272
- return { ...content, tabs, navigation, section, next, prev };
273
- }
274
- function Docs({ content, config }) {
275
- if (!content) {
276
- return /* @__PURE__ */ jsx7(Heading2, { children: "Page not found" });
277
- }
278
- const { tabs, navigation, code, meta, section, next, prev, anchors } = parseContent(
279
- content,
280
- config?.docs
281
- );
282
- const { top } = config?.docs || {};
283
- const navDisplay = {
284
- xs: "none",
285
- lg: "block"
286
- };
287
- const linksDisplay = {
288
- xs: "none",
289
- lg: "block"
290
- };
291
- const menuDisplay = {
292
- lg: "none"
293
- };
294
- const MobileMenuButton = () => /* @__PURE__ */ jsxs6(DialogTrigger, { children: [
295
- /* @__PURE__ */ jsxs6(Button, { children: [
296
- /* @__PURE__ */ jsx7(Icon3, { children: /* @__PURE__ */ jsx7(Icons3.Menu, {}) }),
297
- /* @__PURE__ */ jsx7(Text4, { children: "Menu" })
298
- ] }),
299
- /* @__PURE__ */ jsx7(Modal, { position: "left", offset: "70px", children: /* @__PURE__ */ jsx7(Dialog, { variant: "sheet", children: ({ close }) => {
300
- return /* @__PURE__ */ jsx7(Box5, { overflow: "auto", padding: "4", onClick: close, children: /* @__PURE__ */ jsx7(SideNav, { tabs, navigation }) });
301
- } }) })
302
- ] });
303
- return /* @__PURE__ */ jsxs6(Column3, { gap: "6", children: [
304
- tabs && /* @__PURE__ */ jsx7(TopNav, { tabs }),
305
- /* @__PURE__ */ jsx7(Row2, { display: menuDisplay, justifyContent: "flex-end", children: /* @__PURE__ */ jsx7(MobileMenuButton, {}) }),
306
- /* @__PURE__ */ jsxs6(Row2, { 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
- ] })
331
- ] });
332
- }
333
-
334
- // src/components/Blogs.tsx
335
- import { Grid } from "@umami/react-zen";
336
-
337
- // src/components/Card.tsx
338
- import { Box as Box6, Image, Column as Column4, Row as Row3, Heading as Heading3, Text as Text5, Button as Button2, Icon as Icon4, Icons as Icons4 } from "@umami/react-zen";
339
- import Link4 from "next/link";
340
- import { format } from "date-fns";
341
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
342
- function Card({ title, description, date, author, url, image }) {
343
- return /* @__PURE__ */ jsxs7(Column4, { border: true, borderRadius: "3", overflow: "hidden", children: [
344
- image && /* @__PURE__ */ jsx8(Box6, { height: "240px", children: /* @__PURE__ */ jsx8(Image, { src: image, alt: title, objectFit: "cover" }) }),
345
- /* @__PURE__ */ jsxs7(Column4, { padding: "6", gap: "4", flexGrow: "1", children: [
346
- /* @__PURE__ */ jsxs7(Row3, { justifyContent: "space-between", children: [
347
- /* @__PURE__ */ jsx8(Text5, { color: "muted", children: date && format(new Date(date), "PP") }),
348
- /* @__PURE__ */ jsxs7(Text5, { color: "muted", children: [
349
- "Posted by ",
350
- author
351
- ] })
352
- ] }),
353
- /* @__PURE__ */ jsxs7(Column4, { gap: "4", flexGrow: "1", children: [
354
- /* @__PURE__ */ jsx8(Heading3, { size: "3", as: "header", children: /* @__PURE__ */ jsx8(Link4, { href: url, children: title }) }),
355
- /* @__PURE__ */ jsx8(Box6, { marginY: "5", as: "p", children: /* @__PURE__ */ jsx8(Text5, { color: "muted", size: "3", children: description }) })
356
- ] }),
357
- /* @__PURE__ */ jsx8(Button2, { asChild: true, children: /* @__PURE__ */ jsxs7(Link4, { href: url, children: [
358
- /* @__PURE__ */ jsx8(Text5, { children: "Read more" }),
359
- /* @__PURE__ */ jsx8(Icon4, { children: /* @__PURE__ */ jsx8(Icons4.Arrow, {}) })
360
- ] }) })
361
- ] })
362
- ] });
363
- }
364
-
365
- // src/components/Blogs.tsx
366
- import { jsx as jsx9 } from "react/jsx-runtime";
367
- function Blogs({ content, config, ...props }) {
368
- if (!Array.isArray(content)) {
369
- const { meta, code, anchors, slug } = content;
370
- return /* @__PURE__ */ jsx9(Blog, { ...props, ...meta, slug, code, anchors, backUrl: "/blog" });
371
- }
372
- const items = content.sort(
373
- (a, b) => new Date(b?.meta?.date).getTime() - new Date(a?.meta?.date).getTime()
374
- );
375
- return /* @__PURE__ */ jsx9(Grid, { gap: "5", columns: { xs: "1fr", lg: "repeat(auto-fit, minmax(400px, 1fr))" }, children: items?.map(({ meta, slug }) => /* @__PURE__ */ jsx9(Card, { url: `/blog/${slug}`, ...meta }, slug)) });
376
- }
377
-
378
- // src/components/Shiso.tsx
379
- import { jsx as jsx10 } from "react/jsx-runtime";
380
- var defaultTemplates = {
381
- docs: Docs,
382
- blog: Blogs
383
- };
384
- var shisoComponents = {
385
- pre: CodeBlock,
386
- code: Code
387
- };
388
- var ShisoContext = createContext(null);
389
- function Shiso({ type, config, content, components, templates }) {
390
- const Component = { ...defaultTemplates, ...templates }[type];
391
- if (!Component) {
392
- return /* @__PURE__ */ jsx10("h1", { children: `Component not found for type: ${type}` });
393
- }
394
- return /* @__PURE__ */ jsx10(ShisoContext.Provider, { value: { type, config, content, components, templates }, children: /* @__PURE__ */ jsx10(MDXProvider, { components: { ...shisoComponents, ...components }, children: /* @__PURE__ */ jsx10(Component, { config, content }) }) });
395
- }
396
-
397
- // src/components/hooks/useShiso.ts
398
- function useShiso() {
399
- const { content, config } = useContext(ShisoContext);
400
- return { content, config };
401
- }
402
-
403
- // src/components/Blog.tsx
404
- import Link5 from "next/link";
405
- import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
406
- function Blog({ title, code, author, date, image, anchors, backUrl }) {
407
- const { config } = useShiso();
408
- const { top } = config?.blog || {};
409
- const linksDisplay = {
410
- xs: "none",
411
- lg: "block"
412
- };
413
- return /* @__PURE__ */ jsxs8(Column5, { gap: "8", maxWidth: "960px", style: { margin: "0 auto" }, children: [
414
- /* @__PURE__ */ jsx11(Box7, { flexGrow: "1", paddingY: "6", children: title && /* @__PURE__ */ jsx11(Heading4, { size: "6", as: "h1", align: "center", children: title }) }),
415
- /* @__PURE__ */ jsxs8(Row4, { justifyContent: "space-between", children: [
416
- /* @__PURE__ */ jsx11(Text6, { color: "muted", children: date && format2(new Date(date), "PPP") }),
417
- /* @__PURE__ */ jsxs8(Text6, { color: "muted", children: [
418
- "Posted by ",
419
- author
420
- ] })
421
- ] }),
422
- image && /* @__PURE__ */ jsx11(Box7, { height: "480px", children: /* @__PURE__ */ jsx11(Image2, { src: image, alt: title, objectFit: "cover", borderRadius: "3" }) }),
423
- /* @__PURE__ */ jsxs8(Row4, { gap: "6", children: [
424
- /* @__PURE__ */ jsx11(Markdown, { code }),
425
- /* @__PURE__ */ jsx11(PageLinks, { display: linksDisplay, items: anchors, style: { top } })
426
- ] }),
427
- backUrl && /* @__PURE__ */ jsx11(Row4, { justifyContent: "flex-start", children: /* @__PURE__ */ jsx11(Button3, { style: { width: "auto" }, asChild: true, children: /* @__PURE__ */ jsxs8(Link5, { href: backUrl, children: [
428
- /* @__PURE__ */ jsx11(Icon5, { rotate: 180, children: /* @__PURE__ */ jsx11(Icons5.Arrow, {}) }),
429
- /* @__PURE__ */ jsx11(Text6, { children: "Back" })
430
- ] }) }) })
431
- ] });
432
- }
433
- export {
434
- Blog,
435
- Docs,
436
- Shiso
437
- };
package/server/index.d.ts DELETED
@@ -1,30 +0,0 @@
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, ShisoRenderProps, ShisoContent } from '@/lib/types';
9
- export const parseFile: (file: string) => Promise<ShisoContent | null>;
10
- export function next(type: string, config: ShisoConfig): {
11
- generateMetadata: ({ params }: {
12
- params: Promise<{
13
- slug: string[];
14
- }>;
15
- }) => Promise<{
16
- title: {
17
- absolute: any;
18
- default: any;
19
- };
20
- }>;
21
- generateStaticParams: () => Promise<any>;
22
- renderPage: (render: (props: ShisoRenderProps) => ReactElement) => ({ params }: {
23
- params: Promise<{
24
- slug: string[];
25
- }>;
26
- }) => Promise<ReactElement<unknown, string | import("react").JSXElementConstructor<any>>>;
27
- renderCollection: (render: (props: ShisoRenderProps) => ReactElement) => () => Promise<ReactElement<unknown, string | import("react").JSXElementConstructor<any>>>;
28
- };
29
- }
30
-
package/server/index.js DELETED
@@ -1,189 +0,0 @@
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 { compile } from '@mdx-js/mdx';
39
- import remarkGfm from 'remark-gfm';
40
- import rehypeSlug from 'rehype-slug';
41
- import rehypeHighlight from 'rehype-highlight';
42
- import matter from 'gray-matter';
43
- import recursive from 'recursive-readdir';
44
- import fs from 'node:fs/promises';
45
- import path from 'node:path';
46
- export var parseFile = cache(function (file) { return __awaiter(void 0, void 0, void 0, function () {
47
- var postContent, _a, frontmatter, mdxContent, anchors_1, code, _b, _c;
48
- return __generator(this, function (_d) {
49
- switch (_d.label) {
50
- case 0:
51
- _d.trys.push([0, 3, , 4]);
52
- return [4 /*yield*/, fs.readFile(file, 'utf8')];
53
- case 1:
54
- postContent = _d.sent();
55
- _a = matter(postContent), frontmatter = _a.data, mdxContent = _a.content;
56
- anchors_1 = [];
57
- mdxContent.split('\n').forEach(function (line) {
58
- var match = line.match(/^(#+)\s+(.*)/);
59
- if (match) {
60
- var num = match[1], name_1 = match[2];
61
- var id = name_1
62
- .toLowerCase()
63
- .replace(/\s+/g, '-')
64
- .replace(/[^\w-]+/g, '');
65
- var size = num.length;
66
- anchors_1.push({ name: name_1, id: id, size: size });
67
- }
68
- });
69
- _b = String;
70
- return [4 /*yield*/, compile(mdxContent, {
71
- outputFormat: 'function-body',
72
- remarkPlugins: [remarkGfm],
73
- rehypePlugins: [rehypeHighlight, rehypeSlug],
74
- })];
75
- case 2:
76
- code = _b.apply(void 0, [_d.sent()]);
77
- return [2 /*return*/, {
78
- path: file,
79
- meta: frontmatter,
80
- content: postContent,
81
- code: code,
82
- anchors: anchors_1,
83
- }];
84
- case 3:
85
- _c = _d.sent();
86
- return [2 /*return*/, null];
87
- case 4: return [2 /*return*/];
88
- }
89
- });
90
- }); });
91
- export function next(type, config) {
92
- var _this = this;
93
- var dir = path.resolve(config.contentDir, type);
94
- var _a = config[type].title, title = _a === void 0 ? 'Shiso' : _a;
95
- var getContent = function (file) { return __awaiter(_this, void 0, void 0, function () {
96
- var content;
97
- return __generator(this, function (_a) {
98
- switch (_a.label) {
99
- case 0: return [4 /*yield*/, parseFile(file)];
100
- case 1:
101
- content = _a.sent();
102
- if (content) {
103
- content['slug'] = getSlug(file, dir);
104
- }
105
- return [2 /*return*/, content];
106
- }
107
- });
108
- }); };
109
- function generateMetadata(_a) {
110
- return __awaiter(this, arguments, void 0, function (_b) {
111
- var name, file, content;
112
- var _c, _d, _e, _f;
113
- var params = _b.params;
114
- return __generator(this, function (_g) {
115
- switch (_g.label) {
116
- case 0: return [4 /*yield*/, params];
117
- case 1:
118
- name = ((_d = (_c = (_g.sent())) === null || _c === void 0 ? void 0 : _c.slug) === null || _d === void 0 ? void 0 : _d.join('/')) || 'index';
119
- file = path.join(dir, "".concat(name, ".mdx"));
120
- return [4 /*yield*/, getContent(file)];
121
- case 2:
122
- content = _g.sent();
123
- return [2 /*return*/, {
124
- title: {
125
- absolute: ((_e = content === null || content === void 0 ? void 0 : content.meta) === null || _e === void 0 ? void 0 : _e.title) ? "".concat((_f = content === null || content === void 0 ? void 0 : content.meta) === null || _f === void 0 ? void 0 : _f.title, " \u2013 ").concat(title) : title,
126
- default: title,
127
- },
128
- }];
129
- }
130
- });
131
- });
132
- }
133
- function getSlug(file, dir) {
134
- return file.replace('.mdx', '').replace(dir, '').replace(/\\/g, '/').replace(/^\//, '');
135
- }
136
- function generateStaticParams() {
137
- return __awaiter(this, void 0, void 0, function () {
138
- var files;
139
- return __generator(this, function (_a) {
140
- switch (_a.label) {
141
- case 0: return [4 /*yield*/, recursive(dir)];
142
- case 1:
143
- files = _a.sent();
144
- return [2 /*return*/, files.map(function (file) { return ({
145
- slug: getSlug(file, dir).split('/'),
146
- }); })];
147
- }
148
- });
149
- });
150
- }
151
- function renderPage(render) {
152
- var _this = this;
153
- return function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
154
- var slug, file, content;
155
- var _c, _d;
156
- var params = _b.params;
157
- return __generator(this, function (_e) {
158
- switch (_e.label) {
159
- case 0: return [4 /*yield*/, params];
160
- case 1:
161
- slug = ((_d = (_c = (_e.sent())) === null || _c === void 0 ? void 0 : _c.slug) === null || _d === void 0 ? void 0 : _d.join('/')) || 'index';
162
- file = path.join(dir, "".concat(slug, ".mdx"));
163
- return [4 /*yield*/, getContent(file)];
164
- case 2:
165
- content = _e.sent();
166
- return [2 /*return*/, render({ type: type, config: config, content: content })];
167
- }
168
- });
169
- }); };
170
- }
171
- function renderCollection(render) {
172
- var _this = this;
173
- return function () { return __awaiter(_this, void 0, void 0, function () {
174
- var files, content;
175
- return __generator(this, function (_a) {
176
- switch (_a.label) {
177
- case 0: return [4 /*yield*/, recursive(dir)];
178
- case 1:
179
- files = _a.sent();
180
- return [4 /*yield*/, Promise.all(files.map(function (file) { return getContent(file); }))];
181
- case 2:
182
- content = _a.sent();
183
- return [2 /*return*/, render({ type: type, config: config, content: content })];
184
- }
185
- });
186
- }); };
187
- }
188
- return { generateMetadata: generateMetadata, generateStaticParams: generateStaticParams, renderPage: renderPage, renderCollection: renderCollection };
189
- }