zudoku 0.18.2 → 0.18.4
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/cli/common/logger.js +9 -0
- package/dist/cli/common/logger.js.map +1 -1
- package/dist/config/validators/validate.d.ts +23 -3
- package/dist/config/validators/validate.js +7 -1
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/lib/components/Header.js +2 -2
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/oas/parser/upgrade/index.d.ts +2 -2
- package/dist/lib/oas/parser/upgrade/index.js +3 -20
- package/dist/lib/oas/parser/upgrade/index.js.map +1 -1
- package/dist/lib/plugins/markdown/MdxPage.d.ts +9 -1
- package/dist/lib/plugins/markdown/MdxPage.js +14 -1
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/markdown/index.js +1 -1
- package/dist/lib/plugins/markdown/index.js.map +1 -1
- package/dist/lib/plugins/openapi/client/GraphQLClient.js +12 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.js.map +1 -1
- package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +1 -1
- package/dist/lib/plugins/openapi/client/useCreateQuery.js +4 -2
- package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +1 -1
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.d.ts +6 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.js +14 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.d.ts +1 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.js +125 -0
- package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.d.ts +11 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.js +33 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.test.d.ts +1 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.test.js +104 -0
- package/dist/lib/plugins/openapi/post-processors/removePaths.test.js.map +1 -0
- package/dist/lib/plugins/openapi/post-processors/traverse.d.ts +1 -0
- package/dist/lib/plugins/openapi/post-processors/traverse.js +2 -0
- package/dist/lib/plugins/openapi/post-processors/traverse.js.map +1 -0
- package/dist/lib/util/traverse.d.ts +2 -0
- package/dist/lib/util/traverse.js +18 -0
- package/dist/lib/util/traverse.js.map +1 -0
- package/dist/vite/config.js +12 -0
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/config.test.js +3 -4
- package/dist/vite/config.test.js.map +1 -1
- package/dist/vite/output.js +20 -0
- package/dist/vite/output.js.map +1 -1
- package/dist/vite/plugin-api.js +23 -19
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-component.js +14 -19
- package/dist/vite/plugin-component.js.map +1 -1
- package/dist/vite/plugin-docs.test.js +15 -23
- package/dist/vite/plugin-docs.test.js.map +1 -1
- package/dist/zuplo/with-zuplo.d.ts +3 -0
- package/dist/zuplo/with-zuplo.js +28 -0
- package/dist/zuplo/with-zuplo.js.map +1 -0
- package/lib/MdxPage-B2FpJ9KC.js +183 -0
- package/lib/MdxPage-B2FpJ9KC.js.map +1 -0
- package/lib/{OperationList-BwBl1xrD.js → OperationList-BkNQEsNs.js} +459 -457
- package/lib/OperationList-BkNQEsNs.js.map +1 -0
- package/lib/assets/{worker-CPsGZsve.js → worker-BHClFO3A.js} +434 -438
- package/lib/assets/worker-BHClFO3A.js.map +1 -0
- package/lib/{createServer-DK-g7kbB.js → createServer-CpJlUPtn.js} +4457 -5247
- package/lib/createServer-CpJlUPtn.js.map +1 -0
- package/lib/{index-DNxQ_rCt.js → index-C7SaIME0.js} +49 -45
- package/lib/index-C7SaIME0.js.map +1 -0
- package/lib/object_hash-CvlLgU-M.js +785 -0
- package/lib/object_hash-CvlLgU-M.js.map +1 -0
- package/lib/post-processors/removeExtensions.js +11 -0
- package/lib/post-processors/removeExtensions.js.map +1 -0
- package/lib/post-processors/removePaths.js +28 -0
- package/lib/post-processors/removePaths.js.map +1 -0
- package/lib/post-processors/traverse.js +12 -0
- package/lib/post-processors/traverse.js.map +1 -0
- package/lib/zudoku.components.js +1 -2
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +1 -1
- package/lib/zudoku.plugin-markdown.js +15 -14
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +15 -5
- package/src/lib/components/Header.tsx +1 -2
- package/src/lib/oas/parser/upgrade/index.ts +4 -27
- package/src/lib/plugins/markdown/MdxPage.tsx +25 -1
- package/src/lib/plugins/markdown/index.tsx +1 -0
- package/src/lib/plugins/openapi/client/GraphQLClient.tsx +17 -0
- package/src/lib/plugins/openapi/client/useCreateQuery.ts +5 -2
- package/src/lib/plugins/openapi/interfaces.ts +1 -1
- package/src/lib/plugins/openapi/post-processors/removeExtensions.test.ts +144 -0
- package/src/lib/plugins/openapi/post-processors/removeExtensions.ts +24 -0
- package/src/lib/plugins/openapi/post-processors/removePaths.test.ts +126 -0
- package/src/lib/plugins/openapi/post-processors/removePaths.ts +55 -0
- package/src/lib/plugins/openapi/post-processors/traverse.ts +1 -0
- package/src/lib/util/traverse.ts +25 -0
- package/lib/MdxPage-Bwn-VSsH.js +0 -174
- package/lib/MdxPage-Bwn-VSsH.js.map +0 -1
- package/lib/OperationList-BwBl1xrD.js.map +0 -1
- package/lib/assets/worker-CPsGZsve.js.map +0 -1
- package/lib/createServer-DK-g7kbB.js.map +0 -1
- package/lib/index-DNxQ_rCt.js.map +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { removePaths } from "./removePaths.js";
|
|
3
|
+
|
|
4
|
+
const baseDoc = {
|
|
5
|
+
openapi: "3.0.3",
|
|
6
|
+
paths: {
|
|
7
|
+
"/example": {
|
|
8
|
+
get: { summary: "Get example" },
|
|
9
|
+
post: { summary: "Post example" },
|
|
10
|
+
},
|
|
11
|
+
"/remove-me": {
|
|
12
|
+
delete: { summary: "Delete example" },
|
|
13
|
+
},
|
|
14
|
+
"/another": {
|
|
15
|
+
get: { summary: "Another example" },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe("removePaths", () => {
|
|
21
|
+
it("removes paths specified in the paths option", () => {
|
|
22
|
+
const processed = removePaths({
|
|
23
|
+
paths: {
|
|
24
|
+
"/remove-me": true,
|
|
25
|
+
},
|
|
26
|
+
})(baseDoc);
|
|
27
|
+
|
|
28
|
+
expect(processed.paths["/remove-me"]).toBeUndefined();
|
|
29
|
+
expect(processed.paths["/example"]).toBeDefined();
|
|
30
|
+
expect(processed.paths["/another"]).toBeDefined();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("removes specific methods in the paths option", () => {
|
|
34
|
+
const processed = removePaths({
|
|
35
|
+
paths: {
|
|
36
|
+
"/example": ["get"],
|
|
37
|
+
},
|
|
38
|
+
})(baseDoc);
|
|
39
|
+
|
|
40
|
+
expect(processed.paths["/example"].get).toBeUndefined();
|
|
41
|
+
expect(processed.paths["/example"].post).toBeDefined();
|
|
42
|
+
expect(processed.paths["/remove-me"]).toBeDefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("removes paths and methods using paths and shouldRemove together", () => {
|
|
46
|
+
const processed = removePaths({
|
|
47
|
+
paths: {
|
|
48
|
+
"/example": ["post"],
|
|
49
|
+
},
|
|
50
|
+
shouldRemove: ({ path }) => path.startsWith("/remove"),
|
|
51
|
+
})(baseDoc);
|
|
52
|
+
|
|
53
|
+
expect(processed.paths["/remove-me"]).toBeUndefined();
|
|
54
|
+
expect(processed.paths["/example"].get).toBeDefined();
|
|
55
|
+
expect(processed.paths["/example"].post).toBeUndefined();
|
|
56
|
+
expect(processed.paths["/another"]).toBeDefined();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("removes paths based on shouldRemove callback", () => {
|
|
60
|
+
const processed = removePaths({
|
|
61
|
+
shouldRemove: ({ path }) => path.startsWith("/remove"),
|
|
62
|
+
})(baseDoc);
|
|
63
|
+
|
|
64
|
+
expect(processed.paths["/remove-me"]).toBeUndefined();
|
|
65
|
+
expect(processed.paths["/example"]).toBeDefined();
|
|
66
|
+
expect(processed.paths["/another"]).toBeDefined();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("removes methods based on shouldRemove callback", () => {
|
|
70
|
+
const processed = removePaths({
|
|
71
|
+
shouldRemove: ({ method }) => method === "post",
|
|
72
|
+
})(baseDoc);
|
|
73
|
+
|
|
74
|
+
expect(processed.paths["/example"].post).toBeUndefined();
|
|
75
|
+
expect(processed.paths["/example"].get).toBeDefined();
|
|
76
|
+
expect(processed.paths["/remove-me"]).toBeDefined();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("removes both paths and methods based on shouldRemove callback", () => {
|
|
80
|
+
const processed = removePaths({
|
|
81
|
+
shouldRemove: ({ path, method }) =>
|
|
82
|
+
path.startsWith("/remove") || method === "post",
|
|
83
|
+
})(baseDoc);
|
|
84
|
+
|
|
85
|
+
expect(processed.paths["/remove-me"]).toBeUndefined();
|
|
86
|
+
expect(processed.paths["/example"].post).toBeUndefined();
|
|
87
|
+
expect(processed.paths["/example"].get).toBeDefined();
|
|
88
|
+
expect(processed.paths["/another"]).toBeDefined();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("does nothing if shouldRemove always returns false", () => {
|
|
92
|
+
const processed = removePaths({
|
|
93
|
+
shouldRemove: () => false,
|
|
94
|
+
})(baseDoc);
|
|
95
|
+
|
|
96
|
+
expect(processed).toEqual(baseDoc);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("removes everything if shouldRemove always returns true", () => {
|
|
100
|
+
const processed = removePaths({
|
|
101
|
+
shouldRemove: () => true,
|
|
102
|
+
})(baseDoc);
|
|
103
|
+
|
|
104
|
+
expect(processed.paths).toEqual({});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("removes entire paths via shouldRemove callback", () => {
|
|
108
|
+
const processed = removePaths({
|
|
109
|
+
shouldRemove: ({ path, method }) =>
|
|
110
|
+
method === true && path === "/remove-me",
|
|
111
|
+
})(baseDoc);
|
|
112
|
+
|
|
113
|
+
expect(processed.paths["/remove-me"]).toBeUndefined();
|
|
114
|
+
expect(processed.paths["/example"]).toBeDefined();
|
|
115
|
+
expect(processed.paths["/another"]).toBeDefined();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("removes specific methods while keeping paths", () => {
|
|
119
|
+
const processed = removePaths({
|
|
120
|
+
shouldRemove: ({ method }) => method === "delete",
|
|
121
|
+
})(baseDoc);
|
|
122
|
+
|
|
123
|
+
expect(processed.paths["/remove-me"]).toBeDefined();
|
|
124
|
+
expect(processed.paths["/remove-me"].delete).toBeUndefined();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type RecordAny, traverse } from "./traverse.js";
|
|
2
|
+
|
|
3
|
+
interface RemovePathsOptions {
|
|
4
|
+
// Path definitions, e.g., { '/path': true, '/path-2': ['get'] }
|
|
5
|
+
paths?: Record<string, true | string[]>;
|
|
6
|
+
shouldRemove?: (options: {
|
|
7
|
+
path: string;
|
|
8
|
+
method: true | string;
|
|
9
|
+
operation: RecordAny;
|
|
10
|
+
}) => boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const removePaths =
|
|
14
|
+
({ paths = {}, shouldRemove }: RemovePathsOptions) =>
|
|
15
|
+
(doc: RecordAny): RecordAny =>
|
|
16
|
+
traverse(doc, (spec) => {
|
|
17
|
+
if (!spec.paths) return spec;
|
|
18
|
+
|
|
19
|
+
const updatedPaths: RecordAny = {};
|
|
20
|
+
|
|
21
|
+
for (const [path, methods] of Object.entries(spec.paths)) {
|
|
22
|
+
const operations = spec.paths[path];
|
|
23
|
+
|
|
24
|
+
// If the path is explicitly marked for removal in `paths`
|
|
25
|
+
if (paths[path] === true) continue;
|
|
26
|
+
|
|
27
|
+
// If the path should be removed via `shouldRemove`
|
|
28
|
+
if (shouldRemove?.({ path, method: true, operation: operations }))
|
|
29
|
+
continue;
|
|
30
|
+
|
|
31
|
+
if (typeof methods === "object" && methods !== null) {
|
|
32
|
+
const filteredPath = Object.fromEntries(
|
|
33
|
+
Object.entries(methods).filter(([method]) => {
|
|
34
|
+
const operations = spec.paths[path][method];
|
|
35
|
+
const isMethodToRemove =
|
|
36
|
+
Array.isArray(paths[path]) && paths[path].includes(method);
|
|
37
|
+
|
|
38
|
+
const isMethodFiltered = shouldRemove?.({
|
|
39
|
+
path,
|
|
40
|
+
method,
|
|
41
|
+
operation: operations,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return !isMethodToRemove && !isMethodFiltered;
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
updatedPaths[path] = filteredPath;
|
|
49
|
+
} else {
|
|
50
|
+
updatedPaths[path] = methods;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { ...spec, paths: updatedPaths };
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { traverse, type RecordAny } from "../../../util/traverse.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
export type RecordAny = Record<string, any>;
|
|
3
|
+
|
|
4
|
+
export const traverse = (
|
|
5
|
+
specification: RecordAny,
|
|
6
|
+
transform: (specification: RecordAny) => RecordAny,
|
|
7
|
+
) => {
|
|
8
|
+
const result: RecordAny = {};
|
|
9
|
+
|
|
10
|
+
for (const [key, value] of Object.entries(specification)) {
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
result[key] = value.map((item) =>
|
|
13
|
+
typeof item === "object" && item !== null
|
|
14
|
+
? traverse(item, transform)
|
|
15
|
+
: item,
|
|
16
|
+
);
|
|
17
|
+
} else if (typeof value === "object" && value !== null) {
|
|
18
|
+
result[key] = traverse(value, transform);
|
|
19
|
+
} else {
|
|
20
|
+
result[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return transform(result);
|
|
25
|
+
};
|
package/lib/MdxPage-Bwn-VSsH.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { j as e } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
-
import { s as T } from "./index-LNp6rxyU.js";
|
|
3
|
-
import { A as k, H as P, u as C } from "./AnchorLink-CDlhr8gL.js";
|
|
4
|
-
import { L as v } from "./index-Yn8c3UWE.js";
|
|
5
|
-
import { C as H } from "./CategoryHeading-Bb9dqxD3.js";
|
|
6
|
-
import { u as R, P as S, H as h } from "./Markdown-ievDDhFT.js";
|
|
7
|
-
import { a as E, b as I } from "./utils-DcpDOncX.js";
|
|
8
|
-
import { c as x } from "./cn-BmFQLtkS.js";
|
|
9
|
-
import { ListTreeIcon as L } from "lucide-react";
|
|
10
|
-
import { useRef as y, useState as _, useEffect as $ } from "react";
|
|
11
|
-
const N = "data-active", b = ({
|
|
12
|
-
item: r,
|
|
13
|
-
children: t,
|
|
14
|
-
className: s,
|
|
15
|
-
isActive: o
|
|
16
|
-
}) => /* @__PURE__ */ e.jsxs(
|
|
17
|
-
"li",
|
|
18
|
-
{
|
|
19
|
-
className: x(
|
|
20
|
-
"truncate",
|
|
21
|
-
o ? "text-primary" : "text-foreground/65 dark:text-foreground/75",
|
|
22
|
-
s
|
|
23
|
-
),
|
|
24
|
-
title: r.value,
|
|
25
|
-
children: [
|
|
26
|
-
/* @__PURE__ */ e.jsx(
|
|
27
|
-
k,
|
|
28
|
-
{
|
|
29
|
-
to: `#${r.id}`,
|
|
30
|
-
[N]: r.id,
|
|
31
|
-
className: x(
|
|
32
|
-
o ? "text-primary" : "text-foreground/65 dark:text-foreground/75 hover:text-foreground"
|
|
33
|
-
),
|
|
34
|
-
children: r.value
|
|
35
|
-
}
|
|
36
|
-
),
|
|
37
|
-
t
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
), M = ({ entries: r }) => {
|
|
41
|
-
const { activeAnchor: t } = R(), s = y(null), o = y(!1), [m, i] = _({
|
|
42
|
-
top: 0,
|
|
43
|
-
opacity: 0
|
|
44
|
-
});
|
|
45
|
-
return $(() => {
|
|
46
|
-
if (!s.current) return;
|
|
47
|
-
const a = s.current.querySelector(
|
|
48
|
-
`[${N}='${t}']`
|
|
49
|
-
);
|
|
50
|
-
if (!a) {
|
|
51
|
-
i({ top: 0, opacity: 0 });
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const n = s.current.getBoundingClientRect().top, p = a.getBoundingClientRect().top;
|
|
55
|
-
i({
|
|
56
|
-
opacity: 1,
|
|
57
|
-
top: `${p - n}px`
|
|
58
|
-
}), !o.current && requestIdleCallback(() => {
|
|
59
|
-
o.current = !0;
|
|
60
|
-
});
|
|
61
|
-
}, [t]), /* @__PURE__ */ e.jsxs("aside", { className: "sticky scrollbar top-[--header-height] h-[calc(100vh-var(--header-height))] pt-[--padding-content-top] pb-[--padding-content-bottom] overflow-y-auto ps-1 text-sm", children: [
|
|
62
|
-
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 font-medium mb-2", children: [
|
|
63
|
-
/* @__PURE__ */ e.jsx(L, { size: 16 }),
|
|
64
|
-
"On this page"
|
|
65
|
-
] }),
|
|
66
|
-
/* @__PURE__ */ e.jsxs("div", { className: "relative ms-2 ps-4", children: [
|
|
67
|
-
/* @__PURE__ */ e.jsx("div", { className: "absolute inset-0 right-auto bg-border w-[2px]" }),
|
|
68
|
-
/* @__PURE__ */ e.jsx(
|
|
69
|
-
"div",
|
|
70
|
-
{
|
|
71
|
-
className: x(
|
|
72
|
-
"absolute -left-px -translate-y-1 h-6 w-[4px] rounded bg-primary",
|
|
73
|
-
o.current && "ease-out [transition:top_150ms,opacity_325ms]"
|
|
74
|
-
),
|
|
75
|
-
style: m
|
|
76
|
-
}
|
|
77
|
-
),
|
|
78
|
-
/* @__PURE__ */ e.jsx(
|
|
79
|
-
"ul",
|
|
80
|
-
{
|
|
81
|
-
ref: s,
|
|
82
|
-
className: "relative font-medium list-none space-y-2",
|
|
83
|
-
children: r.map((a) => /* @__PURE__ */ e.jsx(
|
|
84
|
-
b,
|
|
85
|
-
{
|
|
86
|
-
isActive: a.id === t,
|
|
87
|
-
item: a,
|
|
88
|
-
className: "pl-0",
|
|
89
|
-
children: a.children && /* @__PURE__ */ e.jsx("ul", { className: "list-none pl-4 pt-2 space-y-2", children: a.children.map((n) => /* @__PURE__ */ e.jsx(
|
|
90
|
-
b,
|
|
91
|
-
{
|
|
92
|
-
item: n,
|
|
93
|
-
isActive: n.id === t
|
|
94
|
-
},
|
|
95
|
-
n.id
|
|
96
|
-
)) })
|
|
97
|
-
},
|
|
98
|
-
a.id
|
|
99
|
-
))
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
] })
|
|
103
|
-
] });
|
|
104
|
-
}, q = {
|
|
105
|
-
h2: ({ children: r, id: t }) => /* @__PURE__ */ e.jsx(h, { level: 2, id: t, registerSidebarAnchor: !0, children: r }),
|
|
106
|
-
h3: ({ children: r, id: t }) => /* @__PURE__ */ e.jsx(h, { level: 3, id: t, registerSidebarAnchor: !0, children: r })
|
|
107
|
-
}, Q = ({
|
|
108
|
-
mdxComponent: r,
|
|
109
|
-
frontmatter: t = {},
|
|
110
|
-
defaultOptions: s,
|
|
111
|
-
tableOfContents: o
|
|
112
|
-
}) => {
|
|
113
|
-
var g, f, j;
|
|
114
|
-
const m = (g = E()) == null ? void 0 : g.categoryLabel, i = t.title, a = t.category ?? m, n = t.toc === !1 || (s == null ? void 0 : s.toc) === !1, p = ((f = o.find((c) => c.depth === 1)) == null ? void 0 : f.value) ?? i, w = t.disablePager ?? (s == null ? void 0 : s.disablePager) ?? !1, u = ((j = o.find((c) => c.depth === 1)) == null ? void 0 : j.children) ?? // if `title` is provided by frontmatter it does not appear in the table of contents
|
|
115
|
-
o.filter((c) => c.depth === 2), A = !n && u.length > 0, { prev: l, next: d } = I();
|
|
116
|
-
return /* @__PURE__ */ e.jsxs("div", { className: "xl:grid grid-cols-[--sidecar-grid-cols] gap-8 justify-between", children: [
|
|
117
|
-
/* @__PURE__ */ e.jsx(P, { children: /* @__PURE__ */ e.jsx("title", { children: p }) }),
|
|
118
|
-
/* @__PURE__ */ e.jsxs(
|
|
119
|
-
"div",
|
|
120
|
-
{
|
|
121
|
-
className: x(
|
|
122
|
-
S,
|
|
123
|
-
"max-w-full xl:w-full xl:max-w-prose flex-1 flex-shrink pt-[--padding-content-top] pb-[--padding-content-bottom]"
|
|
124
|
-
),
|
|
125
|
-
children: [
|
|
126
|
-
(a || i) && /* @__PURE__ */ e.jsxs("header", { children: [
|
|
127
|
-
a && /* @__PURE__ */ e.jsx(H, { children: a }),
|
|
128
|
-
i && /* @__PURE__ */ e.jsx(h, { level: 1, id: T(i), children: i })
|
|
129
|
-
] }),
|
|
130
|
-
/* @__PURE__ */ e.jsx(
|
|
131
|
-
r,
|
|
132
|
-
{
|
|
133
|
-
components: { ...C(), ...q }
|
|
134
|
-
}
|
|
135
|
-
),
|
|
136
|
-
!w && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
137
|
-
/* @__PURE__ */ e.jsx("hr", {}),
|
|
138
|
-
/* @__PURE__ */ e.jsxs("div", { className: "not-prose flex flex-wrap items-center justify-between gap-2 lg:gap-8", children: [
|
|
139
|
-
l ? /* @__PURE__ */ e.jsxs(
|
|
140
|
-
v,
|
|
141
|
-
{
|
|
142
|
-
to: l.id,
|
|
143
|
-
className: "flex flex-col items-stretch gap-2 flex-1 min-w-max border rounded px-6 py-4 text-start hover:border-primary/85 transition shadow-sm hover:shadow-md",
|
|
144
|
-
title: l.label,
|
|
145
|
-
children: [
|
|
146
|
-
/* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: "← Previous page" }),
|
|
147
|
-
/* @__PURE__ */ e.jsx("div", { className: "text-lg text-primary truncate", children: l.label })
|
|
148
|
-
]
|
|
149
|
-
}
|
|
150
|
-
) : /* @__PURE__ */ e.jsx("div", { className: "flex-1" }),
|
|
151
|
-
d ? /* @__PURE__ */ e.jsxs(
|
|
152
|
-
v,
|
|
153
|
-
{
|
|
154
|
-
to: d.id,
|
|
155
|
-
className: "flex flex-col items-stretch gap-2 flex-1 min-w-max border rounded px-6 py-4 text-end hover:border-primary/85 transition shadow-sm hover:shadow-md",
|
|
156
|
-
title: d.label,
|
|
157
|
-
children: [
|
|
158
|
-
/* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: "Next page →" }),
|
|
159
|
-
/* @__PURE__ */ e.jsx("div", { className: "text-lg text-primary truncate", children: d.label })
|
|
160
|
-
]
|
|
161
|
-
}
|
|
162
|
-
) : /* @__PURE__ */ e.jsx("div", { className: "flex-1" })
|
|
163
|
-
] })
|
|
164
|
-
] })
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
),
|
|
168
|
-
/* @__PURE__ */ e.jsx("div", { className: "hidden xl:block", children: A && /* @__PURE__ */ e.jsx(M, { entries: u }) })
|
|
169
|
-
] });
|
|
170
|
-
};
|
|
171
|
-
export {
|
|
172
|
-
Q as MdxPage
|
|
173
|
-
};
|
|
174
|
-
//# sourceMappingURL=MdxPage-Bwn-VSsH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MdxPage-Bwn-VSsH.js","sources":["../src/lib/plugins/markdown/Toc.tsx","../src/lib/plugins/markdown/MdxPage.tsx"],"sourcesContent":["import type { TocEntry } from \"@stefanprobst/rehype-extract-toc\";\nimport { ListTreeIcon } from \"lucide-react\";\nimport {\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type PropsWithChildren,\n} from \"react\";\nimport { AnchorLink } from \"../../components/AnchorLink.js\";\nimport { useViewportAnchor } from \"../../components/context/ViewportAnchorContext.js\";\nimport { cn } from \"../../util/cn.js\";\n\nconst DATA_ANCHOR_ATTR = \"data-active\";\n\nconst TocItem = ({\n item,\n children,\n className,\n isActive,\n}: PropsWithChildren<{\n item: TocEntry;\n isActive: boolean;\n className?: string;\n}>) => {\n return (\n <li\n className={cn(\n \"truncate\",\n isActive\n ? \"text-primary\"\n : \"text-foreground/65 dark:text-foreground/75\",\n className,\n )}\n title={item.value}\n >\n <AnchorLink\n to={`#${item.id}`}\n {...{ [DATA_ANCHOR_ATTR]: item.id }}\n className={cn(\n isActive\n ? \"text-primary\"\n : \"text-foreground/65 dark:text-foreground/75 hover:text-foreground\",\n )}\n >\n {item.value}\n </AnchorLink>\n {children}\n </li>\n );\n};\n\nexport const Toc = ({ entries }: { entries: TocEntry[] }) => {\n const { activeAnchor } = useViewportAnchor();\n const listWrapperRef = useRef<HTMLUListElement>(null);\n const paintedOnce = useRef(false);\n const [indicatorStyle, setIndicatorStyles] = useState<CSSProperties>({\n top: 0,\n opacity: 0,\n });\n\n // synchronize active anchor indicator with the scroll position\n useEffect(() => {\n if (!listWrapperRef.current) return;\n\n const activeElement = listWrapperRef.current.querySelector(\n `[${DATA_ANCHOR_ATTR}='${activeAnchor}']`,\n );\n\n if (!activeElement) {\n setIndicatorStyles({ top: 0, opacity: 0 });\n return;\n }\n\n const topParent = listWrapperRef.current.getBoundingClientRect().top;\n const topElement = activeElement.getBoundingClientRect().top;\n\n setIndicatorStyles({\n opacity: 1,\n top: `${topElement - topParent}px`,\n });\n\n if (paintedOnce.current) return;\n\n // after all is painted, the indicator should animate\n requestIdleCallback(() => {\n paintedOnce.current = true;\n });\n }, [activeAnchor]);\n\n return (\n <aside className=\"sticky scrollbar top-[--header-height] h-[calc(100vh-var(--header-height))] pt-[--padding-content-top] pb-[--padding-content-bottom] overflow-y-auto ps-1 text-sm\">\n <div className=\"flex items-center gap-2 font-medium mb-2\">\n <ListTreeIcon size={16} />\n On this page\n </div>\n <div className=\"relative ms-2 ps-4\">\n <div className=\"absolute inset-0 right-auto bg-border w-[2px]\" />\n <div\n className={cn(\n \"absolute -left-px -translate-y-1 h-6 w-[4px] rounded bg-primary\",\n paintedOnce.current &&\n \"ease-out [transition:top_150ms,opacity_325ms]\",\n )}\n style={indicatorStyle}\n />\n <ul\n ref={listWrapperRef}\n className=\"relative font-medium list-none space-y-2\"\n >\n {entries.map((item) => (\n <TocItem\n isActive={item.id === activeAnchor}\n key={item.id}\n item={item}\n className=\"pl-0\"\n >\n {item.children && (\n <ul className=\"list-none pl-4 pt-2 space-y-2\">\n {item.children.map((child) => (\n <TocItem\n item={child}\n isActive={child.id === activeAnchor}\n key={child.id}\n />\n ))}\n </ul>\n )}\n </TocItem>\n ))}\n </ul>\n </div>\n </aside>\n );\n};\n","import { useMDXComponents } from \"@mdx-js/react\";\nimport slugify from \"@sindresorhus/slugify\";\nimport { Helmet } from \"@zudoku/react-helmet-async\";\nimport { type PropsWithChildren } from \"react\";\nimport { Link } from \"react-router-dom\";\nimport { CategoryHeading } from \"../../components/CategoryHeading.js\";\nimport { Heading } from \"../../components/Heading.js\";\nimport { ProseClasses } from \"../../components/Markdown.js\";\nimport {\n useCurrentItem,\n usePrevNext,\n} from \"../../components/navigation/utils.js\";\nimport type { MdxComponentsType } from \"../../util/MdxComponents.js\";\nimport { cn } from \"../../util/cn.js\";\nimport { Toc } from \"./Toc.js\";\nimport { MarkdownPluginDefaultOptions, MDXImport } from \"./index.js\";\n\nconst MarkdownHeadings = {\n h2: ({ children, id }) => (\n <Heading level={2} id={id} registerSidebarAnchor>\n {children}\n </Heading>\n ),\n h3: ({ children, id }) => (\n <Heading level={3} id={id} registerSidebarAnchor>\n {children}\n </Heading>\n ),\n} satisfies MdxComponentsType;\n\nexport const MdxPage = ({\n mdxComponent: MdxComponent,\n frontmatter = {},\n defaultOptions,\n tableOfContents,\n}: PropsWithChildren<\n Omit<MDXImport, \"default\"> & {\n mdxComponent: MDXImport[\"default\"];\n defaultOptions?: MarkdownPluginDefaultOptions;\n }\n>) => {\n const categoryTitle = useCurrentItem()?.categoryLabel;\n const title = frontmatter.title;\n const category = frontmatter.category ?? categoryTitle;\n const hideToc = frontmatter.toc === false || defaultOptions?.toc === false;\n const pageTitle =\n tableOfContents.find((item) => item.depth === 1)?.value ?? title;\n const hidePager =\n frontmatter.disablePager ?? defaultOptions?.disablePager ?? false;\n\n const tocEntries =\n tableOfContents.find((item) => item.depth === 1)?.children ??\n // if `title` is provided by frontmatter it does not appear in the table of contents\n tableOfContents.filter((item) => item.depth === 2);\n\n const showToc = !hideToc && tocEntries.length > 0;\n\n const { prev, next } = usePrevNext();\n\n return (\n <div className=\"xl:grid grid-cols-[--sidecar-grid-cols] gap-8 justify-between\">\n <Helmet>\n <title>{pageTitle}</title>\n </Helmet>\n <div\n className={cn(\n ProseClasses,\n \"max-w-full xl:w-full xl:max-w-prose flex-1 flex-shrink pt-[--padding-content-top] pb-[--padding-content-bottom]\",\n )}\n >\n {(category || title) && (\n <header>\n {category && <CategoryHeading>{category}</CategoryHeading>}\n {title && (\n <Heading level={1} id={slugify(title)}>\n {title}\n </Heading>\n )}\n </header>\n )}\n <MdxComponent\n components={{ ...useMDXComponents(), ...MarkdownHeadings }}\n />\n {!hidePager && (\n <>\n <hr />\n <div className=\"not-prose flex flex-wrap items-center justify-between gap-2 lg:gap-8\">\n {prev ? (\n <Link\n to={prev.id}\n className=\"flex flex-col items-stretch gap-2 flex-1 min-w-max border rounded px-6 py-4 text-start hover:border-primary/85 transition shadow-sm hover:shadow-md\"\n title={prev.label}\n >\n <div className=\"text-sm text-muted-foreground\">\n ← Previous page\n </div>\n <div className=\"text-lg text-primary truncate\">\n {prev.label}\n </div>\n </Link>\n ) : (\n <div className=\"flex-1\" />\n )}\n {next ? (\n <Link\n to={next.id}\n className=\"flex flex-col items-stretch gap-2 flex-1 min-w-max border rounded px-6 py-4 text-end hover:border-primary/85 transition shadow-sm hover:shadow-md\"\n title={next.label}\n >\n <div className=\"text-sm text-muted-foreground\">\n Next page →\n </div>\n <div className=\"text-lg text-primary truncate\">\n {next.label}\n </div>\n </Link>\n ) : (\n <div className=\"flex-1\" />\n )}\n </div>\n </>\n )}\n </div>\n <div className=\"hidden xl:block\">\n {showToc && <Toc entries={tocEntries} />}\n </div>\n </div>\n );\n};\n"],"names":["DATA_ANCHOR_ATTR","TocItem","item","children","className","isActive","jsxs","cn","jsx","AnchorLink","Toc","entries","activeAnchor","useViewportAnchor","listWrapperRef","useRef","paintedOnce","indicatorStyle","setIndicatorStyles","useState","useEffect","activeElement","topParent","topElement","ListTreeIcon","child","MarkdownHeadings","id","Heading","MdxPage","MdxComponent","frontmatter","defaultOptions","tableOfContents","categoryTitle","_a","useCurrentItem","title","category","hideToc","pageTitle","_b","hidePager","tocEntries","_c","showToc","prev","next","usePrevNext","Helmet","ProseClasses","CategoryHeading","slugify","useMDXComponents","Fragment","Link"],"mappings":";;;;;;;;;;AAaA,MAAMA,IAAmB,eAEnBC,IAAU,CAAC;AAAA,EACf,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AACF,MAMIC,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACT;AAAA,MACAF,IACI,iBACA;AAAA,MACJD;AAAA,IACF;AAAA,IACA,OAAOF,EAAK;AAAA,IAEZ,UAAA;AAAA,MAAAM,gBAAAA,EAAA;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,IAAI,IAAIP,EAAK,EAAE;AAAA,UACT,CAACF,CAAgB,GAAGE,EAAK;AAAA,UAC/B,WAAWK;AAAA,YACTF,IACI,iBACA;AAAA,UACN;AAAA,UAEC,UAAKH,EAAA;AAAA,QAAA;AAAA,MACR;AAAA,MACCC;AAAA,IAAA;AAAA,EAAA;AAAA,GAKMO,IAAM,CAAC,EAAE,SAAAC,QAAuC;AACrD,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