@umami/shiso 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -26
- package/dist/index.mjs +32 -26
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -26,9 +26,9 @@ declare module '@umami/shiso/Docs' {
|
|
|
26
26
|
|
|
27
27
|
declare module '@umami/shiso/Shiso' {
|
|
28
28
|
import { JSX } from 'react';
|
|
29
|
-
import type { ShisoConfig } from '@/lib/types';
|
|
29
|
+
import type { ShisoConfig, ShisoContent } from '@/lib/types';
|
|
30
30
|
export interface ShisoProps {
|
|
31
|
-
content:
|
|
31
|
+
content: ShisoContent;
|
|
32
32
|
type: string;
|
|
33
33
|
config: ShisoConfig;
|
|
34
34
|
components?: {
|
package/dist/index.js
CHANGED
|
@@ -210,8 +210,8 @@ function SideNav({ tabs, navigation }) {
|
|
|
210
210
|
const pathname = (0, import_navigation.usePathname)();
|
|
211
211
|
const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
212
212
|
const menu = navigation[tab?.id || "docs"];
|
|
213
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.Box, { className: SideNav_default.nav, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.List, { items: navigation, "aria-label": "nav", children: menu.map(({
|
|
214
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.ListSection, { title:
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.Box, { className: SideNav_default.nav, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.List, { items: navigation, "aria-label": "nav", children: menu.map(({ section, pages }) => {
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_zen3.ListSection, { title: section, className: SideNav_default.items, children: pages.map(({ label: text, url }, index) => {
|
|
215
215
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
216
216
|
import_react_zen3.ListItem,
|
|
217
217
|
{
|
|
@@ -222,7 +222,7 @@ function SideNav({ tabs, navigation }) {
|
|
|
222
222
|
},
|
|
223
223
|
index
|
|
224
224
|
);
|
|
225
|
-
}) },
|
|
225
|
+
}) }, section);
|
|
226
226
|
}) }) });
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -249,9 +249,9 @@ var ContentArea_default = { "content": "ContentArea_content__OTBiZ" };
|
|
|
249
249
|
// src/components/ContentArea.tsx
|
|
250
250
|
var import_link3 = __toESM(require("next/link"));
|
|
251
251
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
252
|
-
function ContentArea({
|
|
252
|
+
function ContentArea({ section, title, description, code, next, prev }) {
|
|
253
253
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_zen5.Box, { flexGrow: 1, children: [
|
|
254
|
-
|
|
254
|
+
section && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Text, { color: "primary", weight: "bold", children: section }),
|
|
255
255
|
title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Heading, { size: "8", as: "h1", children: title }),
|
|
256
256
|
description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Text, { color: "muted", children: description }),
|
|
257
257
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_zen5.Box, { className: ContentArea_default.content, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Markdown, { code }) }),
|
|
@@ -280,31 +280,37 @@ var NavigationButton = ({
|
|
|
280
280
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
281
281
|
function parseContent(content, config = {}) {
|
|
282
282
|
const { tabs, navigation } = config;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
283
|
+
const keys = Object.keys(navigation);
|
|
284
|
+
let next, prev, section, found;
|
|
285
|
+
keys.forEach((key) => {
|
|
286
|
+
if (!found) {
|
|
287
|
+
const groups = navigation[key];
|
|
288
|
+
found = groups?.find((group, groupIndex) => {
|
|
289
|
+
return group.pages.find((page, pageIndex) => {
|
|
290
|
+
const match = content.path.replace(/(\/index)?\.mdx$/, "").endsWith(page.url);
|
|
291
|
+
if (match) {
|
|
292
|
+
const prevGroup = groups[groupIndex - 1];
|
|
293
|
+
const nextGroup = groups[groupIndex + 1];
|
|
294
|
+
prev = group.pages[pageIndex - 1] || prevGroup?.pages?.at(-1);
|
|
295
|
+
next = group.pages[pageIndex + 1] || nextGroup?.pages?.[0];
|
|
296
|
+
section = group.section;
|
|
292
297
|
}
|
|
293
|
-
return
|
|
298
|
+
return match;
|
|
294
299
|
});
|
|
295
|
-
})
|
|
296
|
-
prevKey = key;
|
|
300
|
+
});
|
|
297
301
|
}
|
|
298
|
-
}
|
|
299
|
-
return { ...content, tabs, navigation,
|
|
302
|
+
});
|
|
303
|
+
return { ...content, tabs, navigation, section, next, prev };
|
|
300
304
|
}
|
|
301
305
|
function Docs() {
|
|
302
306
|
const { content, config } = useShiso();
|
|
303
307
|
if (!content) {
|
|
304
308
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_zen6.Heading, { size: "6", children: "Page not found" });
|
|
305
309
|
}
|
|
306
|
-
const { tabs, navigation,
|
|
307
|
-
|
|
310
|
+
const { tabs, navigation, code, meta, section, next, prev, anchors } = parseContent(
|
|
311
|
+
content,
|
|
312
|
+
config?.docs
|
|
313
|
+
);
|
|
308
314
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_zen6.Box, { flexGrow: "1", children: [
|
|
309
315
|
tabs && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TopNav, { tabs }),
|
|
310
316
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_zen6.Grid, { gap: "6", columns: "240px 1fr 240px", children: [
|
|
@@ -312,15 +318,15 @@ function Docs() {
|
|
|
312
318
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
313
319
|
ContentArea,
|
|
314
320
|
{
|
|
315
|
-
|
|
316
|
-
title:
|
|
317
|
-
description:
|
|
318
|
-
code
|
|
321
|
+
section,
|
|
322
|
+
title: meta?.title,
|
|
323
|
+
description: meta?.description,
|
|
324
|
+
code,
|
|
319
325
|
next,
|
|
320
326
|
prev
|
|
321
327
|
}
|
|
322
328
|
),
|
|
323
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PageLinks, { items:
|
|
329
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PageLinks, { items: anchors, offset: 150 })
|
|
324
330
|
] })
|
|
325
331
|
] });
|
|
326
332
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -174,8 +174,8 @@ function SideNav({ tabs, navigation }) {
|
|
|
174
174
|
const pathname = usePathname();
|
|
175
175
|
const tab = tabs?.find(({ url, id }) => id !== "docs" ? pathname.startsWith(url) : false);
|
|
176
176
|
const menu = navigation[tab?.id || "docs"];
|
|
177
|
-
return /* @__PURE__ */ jsx7(Box, { className: SideNav_default.nav, children: /* @__PURE__ */ jsx7(List, { items: navigation, "aria-label": "nav", children: menu.map(({
|
|
178
|
-
return /* @__PURE__ */ jsx7(ListSection, { title:
|
|
177
|
+
return /* @__PURE__ */ jsx7(Box, { className: SideNav_default.nav, children: /* @__PURE__ */ jsx7(List, { items: navigation, "aria-label": "nav", children: menu.map(({ section, pages }) => {
|
|
178
|
+
return /* @__PURE__ */ jsx7(ListSection, { title: section, className: SideNav_default.items, children: pages.map(({ label: text, url }, index) => {
|
|
179
179
|
return /* @__PURE__ */ jsx7(
|
|
180
180
|
ListItem,
|
|
181
181
|
{
|
|
@@ -186,7 +186,7 @@ function SideNav({ tabs, navigation }) {
|
|
|
186
186
|
},
|
|
187
187
|
index
|
|
188
188
|
);
|
|
189
|
-
}) },
|
|
189
|
+
}) }, section);
|
|
190
190
|
}) }) });
|
|
191
191
|
}
|
|
192
192
|
|
|
@@ -213,9 +213,9 @@ var ContentArea_default = { "content": "ContentArea_content__OTBiZ" };
|
|
|
213
213
|
// src/components/ContentArea.tsx
|
|
214
214
|
import Link3 from "next/link";
|
|
215
215
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
216
|
-
function ContentArea({
|
|
216
|
+
function ContentArea({ section, title, description, code, next, prev }) {
|
|
217
217
|
return /* @__PURE__ */ jsxs5(Box2, { flexGrow: 1, children: [
|
|
218
|
-
|
|
218
|
+
section && /* @__PURE__ */ jsx9(Text2, { color: "primary", weight: "bold", children: section }),
|
|
219
219
|
title && /* @__PURE__ */ jsx9(Heading, { size: "8", as: "h1", children: title }),
|
|
220
220
|
description && /* @__PURE__ */ jsx9(Text2, { color: "muted", children: description }),
|
|
221
221
|
/* @__PURE__ */ jsx9(Box2, { className: ContentArea_default.content, children: /* @__PURE__ */ jsx9(Markdown, { code }) }),
|
|
@@ -244,31 +244,37 @@ var NavigationButton = ({
|
|
|
244
244
|
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
245
245
|
function parseContent(content, config = {}) {
|
|
246
246
|
const { tabs, navigation } = config;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
247
|
+
const keys = Object.keys(navigation);
|
|
248
|
+
let next, prev, section, found;
|
|
249
|
+
keys.forEach((key) => {
|
|
250
|
+
if (!found) {
|
|
251
|
+
const groups = navigation[key];
|
|
252
|
+
found = groups?.find((group, groupIndex) => {
|
|
253
|
+
return group.pages.find((page, pageIndex) => {
|
|
254
|
+
const match = content.path.replace(/(\/index)?\.mdx$/, "").endsWith(page.url);
|
|
255
|
+
if (match) {
|
|
256
|
+
const prevGroup = groups[groupIndex - 1];
|
|
257
|
+
const nextGroup = groups[groupIndex + 1];
|
|
258
|
+
prev = group.pages[pageIndex - 1] || prevGroup?.pages?.at(-1);
|
|
259
|
+
next = group.pages[pageIndex + 1] || nextGroup?.pages?.[0];
|
|
260
|
+
section = group.section;
|
|
256
261
|
}
|
|
257
|
-
return
|
|
262
|
+
return match;
|
|
258
263
|
});
|
|
259
|
-
})
|
|
260
|
-
prevKey = key;
|
|
264
|
+
});
|
|
261
265
|
}
|
|
262
|
-
}
|
|
263
|
-
return { ...content, tabs, navigation,
|
|
266
|
+
});
|
|
267
|
+
return { ...content, tabs, navigation, section, next, prev };
|
|
264
268
|
}
|
|
265
269
|
function Docs() {
|
|
266
270
|
const { content, config } = useShiso();
|
|
267
271
|
if (!content) {
|
|
268
272
|
return /* @__PURE__ */ jsx10(Heading2, { size: "6", children: "Page not found" });
|
|
269
273
|
}
|
|
270
|
-
const { tabs, navigation,
|
|
271
|
-
|
|
274
|
+
const { tabs, navigation, code, meta, section, next, prev, anchors } = parseContent(
|
|
275
|
+
content,
|
|
276
|
+
config?.docs
|
|
277
|
+
);
|
|
272
278
|
return /* @__PURE__ */ jsxs6(Box3, { flexGrow: "1", children: [
|
|
273
279
|
tabs && /* @__PURE__ */ jsx10(TopNav, { tabs }),
|
|
274
280
|
/* @__PURE__ */ jsxs6(Grid, { gap: "6", columns: "240px 1fr 240px", children: [
|
|
@@ -276,15 +282,15 @@ function Docs() {
|
|
|
276
282
|
/* @__PURE__ */ jsx10(
|
|
277
283
|
ContentArea,
|
|
278
284
|
{
|
|
279
|
-
|
|
280
|
-
title:
|
|
281
|
-
description:
|
|
282
|
-
code
|
|
285
|
+
section,
|
|
286
|
+
title: meta?.title,
|
|
287
|
+
description: meta?.description,
|
|
288
|
+
code,
|
|
283
289
|
next,
|
|
284
290
|
prev
|
|
285
291
|
}
|
|
286
292
|
),
|
|
287
|
-
/* @__PURE__ */ jsx10(PageLinks, { items:
|
|
293
|
+
/* @__PURE__ */ jsx10(PageLinks, { items: anchors, offset: 150 })
|
|
288
294
|
] })
|
|
289
295
|
] });
|
|
290
296
|
}
|