@umami/shiso 0.7.0 → 0.8.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 +6 -6
- package/dist/index.d.ts +14 -14
- package/dist/index.js +110 -70
- package/dist/index.mjs +99 -59
- package/package.json +6 -4
- package/server/index.d.ts +1 -2
- package/server/index.js +41 -70
package/dist/index.css
CHANGED
|
@@ -75,31 +75,31 @@ a.PageLinks_selected__YzEyZ {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/* virtual-css:css:62c31e195181c97259fa56b13d20ea6d */
|
|
78
|
-
.
|
|
78
|
+
.SideNav_nav__MDc0N {
|
|
79
79
|
position: sticky;
|
|
80
80
|
top: 30px;
|
|
81
81
|
height: max-content;
|
|
82
82
|
}
|
|
83
|
-
.
|
|
83
|
+
.SideNav_nav__MDc0N .SideNav_item__NDJkN {
|
|
84
84
|
color: var(--font-muted-color);
|
|
85
85
|
padding: 0;
|
|
86
86
|
border-radius: 0;
|
|
87
87
|
border-left: var(--border-size-1) solid var(--border-color);
|
|
88
88
|
}
|
|
89
|
-
.
|
|
89
|
+
.SideNav_nav__MDc0N .SideNav_item__NDJkN a {
|
|
90
90
|
color: currentColor;
|
|
91
91
|
width: 100%;
|
|
92
92
|
padding: var(--padding-y) var(--padding-x);
|
|
93
93
|
text-decoration: none;
|
|
94
94
|
}
|
|
95
|
-
.
|
|
95
|
+
.SideNav_nav__MDc0N .SideNav_item__NDJkN a:hover {
|
|
96
96
|
color: var(--primary-color);
|
|
97
97
|
}
|
|
98
|
-
.
|
|
98
|
+
.SideNav_nav__MDc0N .SideNav_item__NDJkN.SideNav_selected__ZThhN {
|
|
99
99
|
color: var(--font-color);
|
|
100
100
|
border-color: var(--primary-color);
|
|
101
101
|
}
|
|
102
|
-
.
|
|
102
|
+
.SideNav_items__NzRlZ header {
|
|
103
103
|
padding: var(--padding-y) 0;
|
|
104
104
|
}
|
|
105
105
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
// ../../react
|
|
4
4
|
|
|
5
5
|
declare module '@umami/shiso' {
|
|
6
|
+
import '@umami/react-zen/dist/styles.css';
|
|
6
7
|
import { Blog } from '@umami/shiso/Blog';
|
|
7
8
|
import { Docs } from '@umami/shiso/Docs';
|
|
8
|
-
|
|
9
|
+
import { Shiso } from '@umami/shiso/Shiso';
|
|
10
|
+
export { Blog, Docs, Shiso };
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
declare module '@umami/shiso/Blog' {
|
|
@@ -17,19 +19,11 @@ declare module '@umami/shiso/Blog' {
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
declare module '@umami/shiso/Docs' {
|
|
20
|
-
|
|
21
|
-
export interface DocsProps {
|
|
22
|
-
config: ShisoConfig;
|
|
23
|
-
content: any;
|
|
24
|
-
components?: {
|
|
25
|
-
[key: string]: any;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export function Docs({ content, config, components }: DocsProps): import("react").JSX.Element;
|
|
22
|
+
export function Docs(): import("react").JSX.Element;
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
declare module '@umami/shiso/Shiso' {
|
|
32
|
-
import {
|
|
26
|
+
import { JSX } from 'react';
|
|
33
27
|
export interface ShisoConfig {
|
|
34
28
|
contentDir: string;
|
|
35
29
|
docs?: {
|
|
@@ -40,15 +34,21 @@ declare module '@umami/shiso/Shiso' {
|
|
|
40
34
|
};
|
|
41
35
|
}
|
|
42
36
|
export interface ShisoProps {
|
|
43
|
-
content:
|
|
37
|
+
content: any;
|
|
44
38
|
type: string;
|
|
45
39
|
config: ShisoConfig;
|
|
46
40
|
components?: {
|
|
47
41
|
[key: string]: any;
|
|
48
42
|
};
|
|
49
|
-
|
|
43
|
+
templates?: {
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
};
|
|
50
46
|
}
|
|
47
|
+
export type ShisoTemplateComponent = ({ content, config, }: {
|
|
48
|
+
content: any;
|
|
49
|
+
config: ShisoConfig;
|
|
50
|
+
}) => JSX.Element;
|
|
51
51
|
export const ShisoContext: import("react").Context<any>;
|
|
52
|
-
export function Shiso({ content, type, config, components,
|
|
52
|
+
export function Shiso({ content, type, config, components, templates }: ShisoProps): JSX.Element;
|
|
53
53
|
}
|
|
54
54
|
|
package/dist/index.js
CHANGED
|
@@ -32,28 +32,76 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
34
|
Blog: () => Blog,
|
|
35
|
-
Docs: () => Docs
|
|
35
|
+
Docs: () => Docs,
|
|
36
|
+
Shiso: () => Shiso
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
var import_styles = require("@umami/react-zen/dist/styles.css");
|
|
38
40
|
|
|
39
41
|
// css-modules:E:\dev\umami-shiso\src\components\Blog.module.css
|
|
40
42
|
var Blog_default = {};
|
|
41
43
|
|
|
42
44
|
// src/components/Markdown.tsx
|
|
43
|
-
var
|
|
45
|
+
var import_mdx = require("@mdx-js/mdx");
|
|
46
|
+
var import_react = require("@mdx-js/react");
|
|
47
|
+
var runtime = __toESM(require("react/jsx-runtime"));
|
|
48
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
+
var import_meta = {};
|
|
50
|
+
var compileMDX = (code) => {
|
|
51
|
+
try {
|
|
52
|
+
const { default: Component } = (0, import_mdx.runSync)(code, {
|
|
53
|
+
...runtime,
|
|
54
|
+
baseUrl: import_meta.url
|
|
55
|
+
});
|
|
56
|
+
return { Component };
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return { error };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function Markdown({ content }) {
|
|
62
|
+
const components = (0, import_react.useMDXComponents)();
|
|
63
|
+
const { Component, error } = compileMDX(content.code);
|
|
64
|
+
if (error) {
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: `Error rendering MDX: ${error}` });
|
|
66
|
+
}
|
|
67
|
+
if (!Component) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { components });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/components/Blog.tsx
|
|
74
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
75
|
+
function Blog({ content }) {
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: Blog_default.blog, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: Blog_default.main, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: Blog_default.content, children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: content?.meta?.title }),
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Blog_default.description, children: content?.meta?.description }),
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Markdown, { content })
|
|
80
|
+
] }) }) });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/components/Docs.tsx
|
|
84
|
+
var import_react_zen6 = require("@umami/react-zen");
|
|
85
|
+
|
|
86
|
+
// src/components/hooks/useShiso.ts
|
|
87
|
+
var import_react5 = require("react");
|
|
88
|
+
|
|
89
|
+
// src/components/Shiso.tsx
|
|
90
|
+
var import_react3 = require("react");
|
|
91
|
+
var import_react4 = require("@mdx-js/react");
|
|
44
92
|
|
|
45
93
|
// src/components/CodeBlock.tsx
|
|
46
|
-
var
|
|
94
|
+
var import_react2 = require("react");
|
|
47
95
|
var import_react_zen = require("@umami/react-zen");
|
|
48
96
|
|
|
49
97
|
// css-modules:E:\dev\umami-shiso\src\components\CodeBlock.module.css
|
|
50
98
|
var CodeBlock_default = { "container": "CodeBlock_container__ZTkxY", "button": "CodeBlock_button__MmZkO", "copy": "CodeBlock_copy__M2I0N", "check": "CodeBlock_check__MjkzY" };
|
|
51
99
|
|
|
52
100
|
// src/components/CodeBlock.tsx
|
|
53
|
-
var
|
|
101
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
54
102
|
function CodeBlock(props) {
|
|
55
|
-
const textInput = (0,
|
|
56
|
-
const [copied, setCopied] = (0,
|
|
103
|
+
const textInput = (0, import_react2.useRef)(null);
|
|
104
|
+
const [copied, setCopied] = (0, import_react2.useState)(false);
|
|
57
105
|
const handleCopy = () => {
|
|
58
106
|
setCopied(true);
|
|
59
107
|
navigator?.clipboard?.writeText(textInput?.current?.textContent);
|
|
@@ -61,45 +109,35 @@ function CodeBlock(props) {
|
|
|
61
109
|
setCopied(false);
|
|
62
110
|
}, 1e3);
|
|
63
111
|
};
|
|
64
|
-
return /* @__PURE__ */ (0,
|
|
112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("pre", { ref: textInput, className: CodeBlock_default.container, children: [
|
|
65
113
|
props.children,
|
|
66
|
-
/* @__PURE__ */ (0,
|
|
114
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { "aria-label": "Copy code", className: CodeBlock_default.button, onClick: handleCopy, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_zen.Icon, { size: "sm", className: copied ? CodeBlock_default.check : CodeBlock_default.copy, children: copied ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_zen.Icons.Check, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_zen.Icons.Copy, {}) }) })
|
|
67
115
|
] });
|
|
68
116
|
}
|
|
69
117
|
|
|
70
|
-
// src/components/
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
components: { ...components, pre: CodeBlock }
|
|
84
|
-
}
|
|
85
|
-
);
|
|
118
|
+
// src/components/Shiso.tsx
|
|
119
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
120
|
+
var defaultTemplates = {
|
|
121
|
+
docs: Docs,
|
|
122
|
+
blog: Blog
|
|
123
|
+
};
|
|
124
|
+
var ShisoContext = (0, import_react3.createContext)(null);
|
|
125
|
+
function Shiso({ content, type, config, components, templates }) {
|
|
126
|
+
const Component = { ...defaultTemplates, ...templates }[type];
|
|
127
|
+
if (!Component) {
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h1", { children: `Component not found: ${type}` });
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ShisoContext.Provider, { value: { content, type, config }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react4.MDXProvider, { components: { ...components, pre: CodeBlock }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, { content, config }) }) });
|
|
86
131
|
}
|
|
87
132
|
|
|
88
|
-
// src/components/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: content?.meta?.title }),
|
|
93
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: Blog_default.description, children: content?.meta?.description }),
|
|
94
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { content })
|
|
95
|
-
] }) }) });
|
|
133
|
+
// src/components/hooks/useShiso.ts
|
|
134
|
+
function useShiso() {
|
|
135
|
+
const { content, config } = (0, import_react5.useContext)(ShisoContext);
|
|
136
|
+
return { content, config };
|
|
96
137
|
}
|
|
97
138
|
|
|
98
|
-
// src/components/Docs.tsx
|
|
99
|
-
var import_react_zen6 = require("@umami/react-zen");
|
|
100
|
-
|
|
101
139
|
// src/components/PageLinks.tsx
|
|
102
|
-
var
|
|
140
|
+
var import_react6 = require("react");
|
|
103
141
|
var import_react_zen2 = require("@umami/react-zen");
|
|
104
142
|
var import_classnames = __toESM(require("classnames"));
|
|
105
143
|
|
|
@@ -107,10 +145,10 @@ var import_classnames = __toESM(require("classnames"));
|
|
|
107
145
|
var PageLinks_default = { "title": "PageLinks_title__NTM5N", "links": "PageLinks_links__ODg1Z", "indent-1": "PageLinks_indent-1__OGVmN", "indent-2": "PageLinks_indent-2__YTFmN", "indent-3": "PageLinks_indent-3__OTI0Y", "indent-4": "PageLinks_indent-4__NzhkM", "indent-5": "PageLinks_indent-5__ZGViZ", "indent-6": "PageLinks_indent-6__YjVkN", "selected": "PageLinks_selected__YzEyZ" };
|
|
108
146
|
|
|
109
147
|
// src/components/PageLinks.tsx
|
|
110
|
-
var
|
|
148
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
111
149
|
function PageLinks({ items, offset = 0 }) {
|
|
112
|
-
const [hash, setHash] = (0,
|
|
113
|
-
(0,
|
|
150
|
+
const [hash, setHash] = (0, import_react6.useState)(items?.[0]?.id);
|
|
151
|
+
(0, import_react6.useEffect)(() => {
|
|
114
152
|
const callback = () => {
|
|
115
153
|
const x = [...items].reverse().find(({ id }) => {
|
|
116
154
|
const rect = document.getElementById(id)?.getBoundingClientRect();
|
|
@@ -126,10 +164,10 @@ function PageLinks({ items, offset = 0 }) {
|
|
|
126
164
|
if (!items?.length) {
|
|
127
165
|
return null;
|
|
128
166
|
}
|
|
129
|
-
return /* @__PURE__ */ (0,
|
|
130
|
-
/* @__PURE__ */ (0,
|
|
167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_zen2.Column, { gap: "3", minWidth: "240px", className: PageLinks_default.links, children: [
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_zen2.Text, { size: "2", weight: "bold", children: "On this page" }),
|
|
131
169
|
items.map(({ name, id, size }) => {
|
|
132
|
-
return /* @__PURE__ */ (0,
|
|
170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
133
171
|
"a",
|
|
134
172
|
{
|
|
135
173
|
href: `#${id}`,
|
|
@@ -149,23 +187,23 @@ var import_navigation = require("next/navigation");
|
|
|
149
187
|
var import_link = __toESM(require("next/link"));
|
|
150
188
|
|
|
151
189
|
// css-modules:E:\dev\umami-shiso\src\components\SideNav.module.css
|
|
152
|
-
var SideNav_default = { "nav": "
|
|
190
|
+
var SideNav_default = { "nav": "SideNav_nav__MDc0N", "item": "SideNav_item__NDJkN", "selected": "SideNav_selected__ZThhN", "items": "SideNav_items__NzRlZ" };
|
|
153
191
|
|
|
154
192
|
// src/components/SideNav.tsx
|
|
155
|
-
var
|
|
193
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
156
194
|
function SideNav({ tabs, navigation }) {
|
|
157
195
|
const pathname = (0, import_navigation.usePathname)();
|
|
158
|
-
const tab = tabs
|
|
196
|
+
const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
159
197
|
const menu = navigation[tab?.id || "docs"];
|
|
160
|
-
return /* @__PURE__ */ (0,
|
|
161
|
-
return /* @__PURE__ */ (0,
|
|
162
|
-
return /* @__PURE__ */ (0,
|
|
198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen3.Box, { className: SideNav_default.nav, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen3.List, { items: navigation, "aria-label": "nav", children: menu.map(({ group, pages }) => {
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_zen3.ListSection, { title: group, className: SideNav_default.items, children: pages.map(({ label: text, url }, index) => {
|
|
200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
163
201
|
import_react_zen3.ListItem,
|
|
164
202
|
{
|
|
165
203
|
className: (0, import_classnames2.default)(SideNav_default.item, {
|
|
166
204
|
[SideNav_default.selected]: url === pathname
|
|
167
205
|
}),
|
|
168
|
-
children: /* @__PURE__ */ (0,
|
|
206
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_link.default, { href: url, prefetch: false, children: text })
|
|
169
207
|
},
|
|
170
208
|
index
|
|
171
209
|
);
|
|
@@ -177,13 +215,13 @@ function SideNav({ tabs, navigation }) {
|
|
|
177
215
|
var import_link2 = __toESM(require("next/link"));
|
|
178
216
|
var import_navigation2 = require("next/navigation");
|
|
179
217
|
var import_react_zen4 = require("@umami/react-zen");
|
|
180
|
-
var
|
|
218
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
181
219
|
function TopNav({ tabs }) {
|
|
182
220
|
const pathname = (0, import_navigation2.usePathname)();
|
|
183
|
-
const tab = tabs
|
|
221
|
+
const tab = tabs?.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
184
222
|
const selected = tab?.id || "docs";
|
|
185
|
-
return /* @__PURE__ */ (0,
|
|
186
|
-
return /* @__PURE__ */ (0,
|
|
223
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen4.Tabs, { selectedKey: selected, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen4.TabList, { items: tabs, children: ({ id, label, url }) => {
|
|
224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen4.Tab, { id, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_link2.default, { href: url, children: label }) });
|
|
187
225
|
} }) });
|
|
188
226
|
}
|
|
189
227
|
|
|
@@ -194,21 +232,22 @@ var import_react_zen5 = require("@umami/react-zen");
|
|
|
194
232
|
var ContentArea_default = { "content": "ContentArea_content__MWQ1Z" };
|
|
195
233
|
|
|
196
234
|
// src/components/ContentArea.tsx
|
|
197
|
-
var
|
|
198
|
-
function ContentArea({ content
|
|
199
|
-
return /* @__PURE__ */ (0,
|
|
200
|
-
/* @__PURE__ */ (0,
|
|
201
|
-
/* @__PURE__ */ (0,
|
|
202
|
-
/* @__PURE__ */ (0,
|
|
203
|
-
/* @__PURE__ */ (0,
|
|
235
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
236
|
+
function ContentArea({ content }) {
|
|
237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_zen5.Box, { flexGrow: 1, children: [
|
|
238
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen5.Text, { color: "primary", weight: "bold", children: content.group }),
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen5.Heading, { size: "8", as: "h1", children: content?.meta?.title }),
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen5.Text, { type: "muted", children: content?.meta?.description }),
|
|
241
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_zen5.Box, { className: ContentArea_default.content, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Markdown, { content }) })
|
|
204
242
|
] });
|
|
205
243
|
}
|
|
206
244
|
|
|
207
245
|
// src/components/Docs.tsx
|
|
208
|
-
var
|
|
209
|
-
function Docs(
|
|
246
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
247
|
+
function Docs() {
|
|
248
|
+
const { content, config } = useShiso();
|
|
210
249
|
if (!content) {
|
|
211
|
-
return /* @__PURE__ */ (0,
|
|
250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen6.Heading, { size: "6", children: "Page not found" });
|
|
212
251
|
}
|
|
213
252
|
const { tabs, navigation } = config?.docs || {};
|
|
214
253
|
content.group = Object.keys(navigation).reduce((name, key) => {
|
|
@@ -221,17 +260,18 @@ function Docs({ content, config, components }) {
|
|
|
221
260
|
}
|
|
222
261
|
return name;
|
|
223
262
|
}, null);
|
|
224
|
-
return /* @__PURE__ */ (0,
|
|
225
|
-
tabs && /* @__PURE__ */ (0,
|
|
226
|
-
/* @__PURE__ */ (0,
|
|
227
|
-
/* @__PURE__ */ (0,
|
|
228
|
-
/* @__PURE__ */ (0,
|
|
229
|
-
/* @__PURE__ */ (0,
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_zen6.Box, { flexGrow: "1", children: [
|
|
264
|
+
tabs && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TopNav, { tabs }),
|
|
265
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_zen6.Grid, { gap: "6", columns: "240px 1fr 240px", children: [
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SideNav, { tabs, navigation }),
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ContentArea, { content }),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PageLinks, { items: content?.anchors, offset: 150 })
|
|
230
269
|
] })
|
|
231
270
|
] });
|
|
232
271
|
}
|
|
233
272
|
// Annotate the CommonJS export names for ESM import in node:
|
|
234
273
|
0 && (module.exports = {
|
|
235
274
|
Blog,
|
|
236
|
-
Docs
|
|
275
|
+
Docs,
|
|
276
|
+
Shiso
|
|
237
277
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
// src/components/index.ts
|
|
4
|
+
import "@umami/react-zen/dist/styles.css";
|
|
5
|
+
|
|
3
6
|
// css-modules:E:\dev\umami-shiso\src\components\Blog.module.css
|
|
4
7
|
var Blog_default = {};
|
|
5
8
|
|
|
6
9
|
// src/components/Markdown.tsx
|
|
7
|
-
import {
|
|
10
|
+
import { runSync } from "@mdx-js/mdx";
|
|
11
|
+
import { useMDXComponents } from "@mdx-js/react";
|
|
12
|
+
import * as runtime from "react/jsx-runtime";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
var compileMDX = (code) => {
|
|
15
|
+
try {
|
|
16
|
+
const { default: Component } = runSync(code, {
|
|
17
|
+
...runtime,
|
|
18
|
+
baseUrl: import.meta.url
|
|
19
|
+
});
|
|
20
|
+
return { Component };
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return { error };
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function Markdown({ content }) {
|
|
26
|
+
const components = useMDXComponents();
|
|
27
|
+
const { Component, error } = compileMDX(content.code);
|
|
28
|
+
if (error) {
|
|
29
|
+
return /* @__PURE__ */ jsx("h1", { children: `Error rendering MDX: ${error}` });
|
|
30
|
+
}
|
|
31
|
+
if (!Component) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsx(Component, { components });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/components/Blog.tsx
|
|
38
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
39
|
+
function Blog({ content }) {
|
|
40
|
+
return /* @__PURE__ */ jsx2("div", { className: Blog_default.blog, children: /* @__PURE__ */ jsx2("div", { className: Blog_default.main, children: /* @__PURE__ */ jsxs("div", { className: Blog_default.content, children: [
|
|
41
|
+
/* @__PURE__ */ jsx2("h1", { children: content?.meta?.title }),
|
|
42
|
+
/* @__PURE__ */ jsx2("p", { className: Blog_default.description, children: content?.meta?.description }),
|
|
43
|
+
/* @__PURE__ */ jsx2(Markdown, { content })
|
|
44
|
+
] }) }) });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/components/Docs.tsx
|
|
48
|
+
import { Grid, Box as Box3, Heading as Heading2 } from "@umami/react-zen";
|
|
49
|
+
|
|
50
|
+
// src/components/hooks/useShiso.ts
|
|
51
|
+
import { useContext } from "react";
|
|
52
|
+
|
|
53
|
+
// src/components/Shiso.tsx
|
|
54
|
+
import { createContext } from "react";
|
|
55
|
+
import { MDXProvider } from "@mdx-js/react";
|
|
8
56
|
|
|
9
57
|
// src/components/CodeBlock.tsx
|
|
10
58
|
import { useState, useRef } from "react";
|
|
@@ -14,7 +62,7 @@ import { Icon, Icons } from "@umami/react-zen";
|
|
|
14
62
|
var CodeBlock_default = { "container": "CodeBlock_container__ZTkxY", "button": "CodeBlock_button__MmZkO", "copy": "CodeBlock_copy__M2I0N", "check": "CodeBlock_check__MjkzY" };
|
|
15
63
|
|
|
16
64
|
// src/components/CodeBlock.tsx
|
|
17
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
65
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
18
66
|
function CodeBlock(props) {
|
|
19
67
|
const textInput = useRef(null);
|
|
20
68
|
const [copied, setCopied] = useState(false);
|
|
@@ -25,43 +73,33 @@ function CodeBlock(props) {
|
|
|
25
73
|
setCopied(false);
|
|
26
74
|
}, 1e3);
|
|
27
75
|
};
|
|
28
|
-
return /* @__PURE__ */
|
|
76
|
+
return /* @__PURE__ */ jsxs2("pre", { ref: textInput, className: CodeBlock_default.container, children: [
|
|
29
77
|
props.children,
|
|
30
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ jsx3("button", { "aria-label": "Copy code", className: CodeBlock_default.button, onClick: handleCopy, children: /* @__PURE__ */ jsx3(Icon, { size: "sm", className: copied ? CodeBlock_default.check : CodeBlock_default.copy, children: copied ? /* @__PURE__ */ jsx3(Icons.Check, {}) : /* @__PURE__ */ jsx3(Icons.Copy, {}) }) })
|
|
31
79
|
] });
|
|
32
80
|
}
|
|
33
81
|
|
|
34
|
-
// src/components/
|
|
35
|
-
import { jsx as
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
components: { ...components, pre: CodeBlock }
|
|
48
|
-
}
|
|
49
|
-
);
|
|
82
|
+
// src/components/Shiso.tsx
|
|
83
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
84
|
+
var defaultTemplates = {
|
|
85
|
+
docs: Docs,
|
|
86
|
+
blog: Blog
|
|
87
|
+
};
|
|
88
|
+
var ShisoContext = createContext(null);
|
|
89
|
+
function Shiso({ content, type, config, components, templates }) {
|
|
90
|
+
const Component = { ...defaultTemplates, ...templates }[type];
|
|
91
|
+
if (!Component) {
|
|
92
|
+
return /* @__PURE__ */ jsx4("h1", { children: `Component not found: ${type}` });
|
|
93
|
+
}
|
|
94
|
+
return /* @__PURE__ */ jsx4(ShisoContext.Provider, { value: { content, type, config }, children: /* @__PURE__ */ jsx4(MDXProvider, { components: { ...components, pre: CodeBlock }, children: /* @__PURE__ */ jsx4(Component, { content, config }) }) });
|
|
50
95
|
}
|
|
51
96
|
|
|
52
|
-
// src/components/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
/* @__PURE__ */ jsx3("h1", { children: content?.meta?.title }),
|
|
57
|
-
/* @__PURE__ */ jsx3("p", { className: Blog_default.description, children: content?.meta?.description }),
|
|
58
|
-
/* @__PURE__ */ jsx3(Markdown, { content })
|
|
59
|
-
] }) }) });
|
|
97
|
+
// src/components/hooks/useShiso.ts
|
|
98
|
+
function useShiso() {
|
|
99
|
+
const { content, config } = useContext(ShisoContext);
|
|
100
|
+
return { content, config };
|
|
60
101
|
}
|
|
61
102
|
|
|
62
|
-
// src/components/Docs.tsx
|
|
63
|
-
import { Grid, Box as Box3, Heading as Heading2 } from "@umami/react-zen";
|
|
64
|
-
|
|
65
103
|
// src/components/PageLinks.tsx
|
|
66
104
|
import { useEffect, useState as useState2 } from "react";
|
|
67
105
|
import { Column, Text } from "@umami/react-zen";
|
|
@@ -71,7 +109,7 @@ import classNames from "classnames";
|
|
|
71
109
|
var PageLinks_default = { "title": "PageLinks_title__NTM5N", "links": "PageLinks_links__ODg1Z", "indent-1": "PageLinks_indent-1__OGVmN", "indent-2": "PageLinks_indent-2__YTFmN", "indent-3": "PageLinks_indent-3__OTI0Y", "indent-4": "PageLinks_indent-4__NzhkM", "indent-5": "PageLinks_indent-5__ZGViZ", "indent-6": "PageLinks_indent-6__YjVkN", "selected": "PageLinks_selected__YzEyZ" };
|
|
72
110
|
|
|
73
111
|
// src/components/PageLinks.tsx
|
|
74
|
-
import { jsx as
|
|
112
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
75
113
|
function PageLinks({ items, offset = 0 }) {
|
|
76
114
|
const [hash, setHash] = useState2(items?.[0]?.id);
|
|
77
115
|
useEffect(() => {
|
|
@@ -91,9 +129,9 @@ function PageLinks({ items, offset = 0 }) {
|
|
|
91
129
|
return null;
|
|
92
130
|
}
|
|
93
131
|
return /* @__PURE__ */ jsxs3(Column, { gap: "3", minWidth: "240px", className: PageLinks_default.links, children: [
|
|
94
|
-
/* @__PURE__ */
|
|
132
|
+
/* @__PURE__ */ jsx5(Text, { size: "2", weight: "bold", children: "On this page" }),
|
|
95
133
|
items.map(({ name, id, size }) => {
|
|
96
|
-
return /* @__PURE__ */
|
|
134
|
+
return /* @__PURE__ */ jsx5(
|
|
97
135
|
"a",
|
|
98
136
|
{
|
|
99
137
|
href: `#${id}`,
|
|
@@ -113,23 +151,23 @@ import { usePathname } from "next/navigation";
|
|
|
113
151
|
import Link from "next/link";
|
|
114
152
|
|
|
115
153
|
// css-modules:E:\dev\umami-shiso\src\components\SideNav.module.css
|
|
116
|
-
var SideNav_default = { "nav": "
|
|
154
|
+
var SideNav_default = { "nav": "SideNav_nav__MDc0N", "item": "SideNav_item__NDJkN", "selected": "SideNav_selected__ZThhN", "items": "SideNav_items__NzRlZ" };
|
|
117
155
|
|
|
118
156
|
// src/components/SideNav.tsx
|
|
119
|
-
import { jsx as
|
|
157
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
120
158
|
function SideNav({ tabs, navigation }) {
|
|
121
159
|
const pathname = usePathname();
|
|
122
|
-
const tab = tabs
|
|
160
|
+
const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
123
161
|
const menu = navigation[tab?.id || "docs"];
|
|
124
|
-
return /* @__PURE__ */
|
|
125
|
-
return /* @__PURE__ */
|
|
126
|
-
return /* @__PURE__ */
|
|
162
|
+
return /* @__PURE__ */ jsx6(Box, { className: SideNav_default.nav, children: /* @__PURE__ */ jsx6(List, { items: navigation, "aria-label": "nav", children: menu.map(({ group, pages }) => {
|
|
163
|
+
return /* @__PURE__ */ jsx6(ListSection, { title: group, className: SideNav_default.items, children: pages.map(({ label: text, url }, index) => {
|
|
164
|
+
return /* @__PURE__ */ jsx6(
|
|
127
165
|
ListItem,
|
|
128
166
|
{
|
|
129
167
|
className: classNames2(SideNav_default.item, {
|
|
130
168
|
[SideNav_default.selected]: url === pathname
|
|
131
169
|
}),
|
|
132
|
-
children: /* @__PURE__ */
|
|
170
|
+
children: /* @__PURE__ */ jsx6(Link, { href: url, prefetch: false, children: text })
|
|
133
171
|
},
|
|
134
172
|
index
|
|
135
173
|
);
|
|
@@ -141,13 +179,13 @@ function SideNav({ tabs, navigation }) {
|
|
|
141
179
|
import Link2 from "next/link";
|
|
142
180
|
import { usePathname as usePathname2 } from "next/navigation";
|
|
143
181
|
import { Tabs, TabList, Tab } from "@umami/react-zen";
|
|
144
|
-
import { jsx as
|
|
182
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
145
183
|
function TopNav({ tabs }) {
|
|
146
184
|
const pathname = usePathname2();
|
|
147
|
-
const tab = tabs
|
|
185
|
+
const tab = tabs?.find(({ id, url }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
148
186
|
const selected = tab?.id || "docs";
|
|
149
|
-
return /* @__PURE__ */
|
|
150
|
-
return /* @__PURE__ */
|
|
187
|
+
return /* @__PURE__ */ jsx7(Tabs, { selectedKey: selected, children: /* @__PURE__ */ jsx7(TabList, { items: tabs, children: ({ id, label, url }) => {
|
|
188
|
+
return /* @__PURE__ */ jsx7(Tab, { id, children: /* @__PURE__ */ jsx7(Link2, { href: url, children: label }) });
|
|
151
189
|
} }) });
|
|
152
190
|
}
|
|
153
191
|
|
|
@@ -158,21 +196,22 @@ import { Heading, Box as Box2, Text as Text2 } from "@umami/react-zen";
|
|
|
158
196
|
var ContentArea_default = { "content": "ContentArea_content__MWQ1Z" };
|
|
159
197
|
|
|
160
198
|
// src/components/ContentArea.tsx
|
|
161
|
-
import { jsx as
|
|
162
|
-
function ContentArea({ content
|
|
199
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
200
|
+
function ContentArea({ content }) {
|
|
163
201
|
return /* @__PURE__ */ jsxs4(Box2, { flexGrow: 1, children: [
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
202
|
+
/* @__PURE__ */ jsx8(Text2, { color: "primary", weight: "bold", children: content.group }),
|
|
203
|
+
/* @__PURE__ */ jsx8(Heading, { size: "8", as: "h1", children: content?.meta?.title }),
|
|
204
|
+
/* @__PURE__ */ jsx8(Text2, { type: "muted", children: content?.meta?.description }),
|
|
205
|
+
/* @__PURE__ */ jsx8(Box2, { className: ContentArea_default.content, children: /* @__PURE__ */ jsx8(Markdown, { content }) })
|
|
168
206
|
] });
|
|
169
207
|
}
|
|
170
208
|
|
|
171
209
|
// src/components/Docs.tsx
|
|
172
|
-
import { jsx as
|
|
173
|
-
function Docs(
|
|
210
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
211
|
+
function Docs() {
|
|
212
|
+
const { content, config } = useShiso();
|
|
174
213
|
if (!content) {
|
|
175
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ jsx9(Heading2, { size: "6", children: "Page not found" });
|
|
176
215
|
}
|
|
177
216
|
const { tabs, navigation } = config?.docs || {};
|
|
178
217
|
content.group = Object.keys(navigation).reduce((name, key) => {
|
|
@@ -186,15 +225,16 @@ function Docs({ content, config, components }) {
|
|
|
186
225
|
return name;
|
|
187
226
|
}, null);
|
|
188
227
|
return /* @__PURE__ */ jsxs5(Box3, { flexGrow: "1", children: [
|
|
189
|
-
tabs && /* @__PURE__ */
|
|
228
|
+
tabs && /* @__PURE__ */ jsx9(TopNav, { tabs }),
|
|
190
229
|
/* @__PURE__ */ jsxs5(Grid, { gap: "6", columns: "240px 1fr 240px", children: [
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ jsx9(SideNav, { tabs, navigation }),
|
|
231
|
+
/* @__PURE__ */ jsx9(ContentArea, { content }),
|
|
232
|
+
/* @__PURE__ */ jsx9(PageLinks, { items: content?.anchors, offset: 150 })
|
|
194
233
|
] })
|
|
195
234
|
] });
|
|
196
235
|
}
|
|
197
236
|
export {
|
|
198
237
|
Blog,
|
|
199
|
-
Docs
|
|
238
|
+
Docs,
|
|
239
|
+
Shiso
|
|
200
240
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umami/shiso",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "A content layer for Next.js",
|
|
5
5
|
"homepage": "https://umami.is/shiso",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@umami/react-zen": "^0.
|
|
46
|
+
"@umami/react-zen": "^0.1.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@mdx-js/loader": "^3.0.0",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"mdx-bundler": "^10.0.3",
|
|
58
58
|
"next": "15.1.2",
|
|
59
59
|
"next-mdx-remote": "^5.0.0",
|
|
60
|
-
"react": "19.0.0",
|
|
61
|
-
"react-dom": "19.0.0",
|
|
60
|
+
"react": "^19.0.0",
|
|
61
|
+
"react-dom": "^19.0.0",
|
|
62
62
|
"recursive-readdir": "^2.2.3",
|
|
63
63
|
"rehype-highlight": "^7.0.1",
|
|
64
64
|
"remark-gfm": "^4.0.0",
|
|
@@ -85,6 +85,8 @@
|
|
|
85
85
|
"lint-staged": "^15.2.7",
|
|
86
86
|
"npm-run-all": "^4.1.5",
|
|
87
87
|
"prettier": "^3.2.5",
|
|
88
|
+
"remark-frontmatter": "^5.0.0",
|
|
89
|
+
"remark-mdx-frontmatter": "^5.0.0",
|
|
88
90
|
"stylelint": "^15.10.1",
|
|
89
91
|
"stylelint-config-prettier": "^9.0.5",
|
|
90
92
|
"stylelint-config-recommended": "^14.0.1",
|
package/server/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare function getFile(id: string, folder: string): Promise<any>;
|
|
1
|
+
export declare const parseMdx: (file: string) => Promise<any>;
|
|
3
2
|
export declare function getContent(params: {
|
|
4
3
|
id: string[];
|
|
5
4
|
}, folder: string): Promise<any>;
|
package/server/index.js
CHANGED
|
@@ -35,90 +35,61 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { cache } from 'react';
|
|
38
|
-
import
|
|
39
|
-
import { firstBy } from 'thenby';
|
|
38
|
+
import { compile } from '@mdx-js/mdx';
|
|
40
39
|
import remarkGfm from 'remark-gfm';
|
|
41
40
|
import rehypeHighlight from 'rehype-highlight';
|
|
42
|
-
import
|
|
41
|
+
import matter from 'gray-matter';
|
|
43
42
|
import fs from 'node:fs/promises';
|
|
44
43
|
import path from 'node:path';
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var dir, files;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
dir = path.resolve(folder);
|
|
55
|
-
return [4 /*yield*/, recursive(dir)];
|
|
44
|
+
export var parseMdx = cache(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var postContent, _a, frontmatter, mdxContent, id, anchors, modifiedContent, code, _b;
|
|
46
|
+
return __generator(this, function (_c) {
|
|
47
|
+
switch (_c.label) {
|
|
48
|
+
case 0: return [4 /*yield*/, fs.readFile(file, 'utf8')];
|
|
56
49
|
case 1:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
meta: frontmatter,
|
|
91
|
-
id: id,
|
|
92
|
-
content: postContent,
|
|
93
|
-
code: compiledSource,
|
|
94
|
-
anchors: anchors,
|
|
95
|
-
}];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}); })).then(function (posts) { return posts.sort(firstBy('date', 'desc')); })];
|
|
50
|
+
postContent = _c.sent();
|
|
51
|
+
_a = matter(postContent), frontmatter = _a.data, mdxContent = _a.content;
|
|
52
|
+
id = file.replace('.mdx', '').replace(/\\/g, '/').replace(/^\//, '');
|
|
53
|
+
anchors = [];
|
|
54
|
+
modifiedContent = mdxContent
|
|
55
|
+
.split('\n')
|
|
56
|
+
.map(function (line) {
|
|
57
|
+
var match = line.match(/^(#+)\s+(.*)/);
|
|
58
|
+
if (match) {
|
|
59
|
+
var num = match[1], name_1 = match[2];
|
|
60
|
+
var id_1 = name_1.toLowerCase().replace(/\s+/g, '-');
|
|
61
|
+
var size = num.length;
|
|
62
|
+
anchors.push({ name: name_1, id: id_1, size: size });
|
|
63
|
+
return "<h".concat(size, " id=\"").concat(id_1, "\">").concat(name_1.replace(/\{|\}/g, ''), "</h").concat(size, ">");
|
|
64
|
+
}
|
|
65
|
+
return line;
|
|
66
|
+
})
|
|
67
|
+
.join('\n');
|
|
68
|
+
_b = String;
|
|
69
|
+
return [4 /*yield*/, compile(modifiedContent, {
|
|
70
|
+
outputFormat: 'function-body',
|
|
71
|
+
remarkPlugins: [remarkGfm],
|
|
72
|
+
rehypePlugins: [rehypeHighlight],
|
|
73
|
+
})];
|
|
74
|
+
case 2:
|
|
75
|
+
code = _b.apply(void 0, [_c.sent()]);
|
|
76
|
+
return [2 /*return*/, {
|
|
77
|
+
id: id,
|
|
78
|
+
meta: frontmatter,
|
|
79
|
+
content: postContent,
|
|
80
|
+
code: code,
|
|
81
|
+
anchors: anchors,
|
|
82
|
+
}];
|
|
99
83
|
}
|
|
100
84
|
});
|
|
101
85
|
}); });
|
|
102
|
-
export function getFile(id, folder) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var files;
|
|
105
|
-
return __generator(this, function (_a) {
|
|
106
|
-
switch (_a.label) {
|
|
107
|
-
case 0: return [4 /*yield*/, getFiles(folder)];
|
|
108
|
-
case 1:
|
|
109
|
-
files = _a.sent();
|
|
110
|
-
return [2 /*return*/, files.find(function (file) { return (file === null || file === void 0 ? void 0 : file.id) === id; })];
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
86
|
export function getContent(params, folder) {
|
|
116
87
|
return __awaiter(this, void 0, void 0, function () {
|
|
117
88
|
var _a, id, name;
|
|
118
89
|
return __generator(this, function (_b) {
|
|
119
90
|
_a = params.id, id = _a === void 0 ? [] : _a;
|
|
120
91
|
name = (id === null || id === void 0 ? void 0 : id.length) ? id.join('/') : 'index';
|
|
121
|
-
return [2 /*return*/,
|
|
92
|
+
return [2 /*return*/, parseMdx(path.resolve(folder, "".concat(name, ".mdx")))];
|
|
122
93
|
});
|
|
123
94
|
});
|
|
124
95
|
}
|