@dreamlake/dockit 0.1.1
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/components/Callout.d.ts +11 -0
- package/dist/components/Callout.js +101 -0
- package/dist/components/ClientOnly.d.ts +4 -0
- package/dist/components/ClientOnly.js +11 -0
- package/dist/components/CodeBlock.d.ts +13 -0
- package/dist/components/CodeBlock.js +155 -0
- package/dist/components/DocFooter.d.ts +1 -0
- package/dist/components/DocFooter.js +63 -0
- package/dist/components/Preview.d.ts +16 -0
- package/dist/components/Preview.js +220 -0
- package/dist/components/SearchPalette.d.ts +8 -0
- package/dist/components/SearchPalette.js +678 -0
- package/dist/components/SearchResize.d.ts +11 -0
- package/dist/components/SearchResize.js +150 -0
- package/dist/components/Sidebar.d.ts +1 -0
- package/dist/components/Sidebar.js +134 -0
- package/dist/components/StatusTable.d.ts +19 -0
- package/dist/components/StatusTable.js +251 -0
- package/dist/components/TOC.d.ts +1 -0
- package/dist/components/TOC.js +674 -0
- package/dist/components/TabStrip.d.ts +8 -0
- package/dist/components/TabStrip.js +105 -0
- package/dist/components/ThemeProvider.d.ts +11 -0
- package/dist/components/ThemeProvider.js +40 -0
- package/dist/components/ThemeToggle.d.ts +2 -0
- package/dist/components/ThemeToggle.js +109 -0
- package/dist/components/Topbar.d.ts +9 -0
- package/dist/components/Topbar.js +818 -0
- package/dist/components/mdx-components.d.ts +30 -0
- package/dist/components/mdx-components.js +346 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +81 -0
- package/dist/lib/navigation.d.ts +80 -0
- package/dist/lib/navigation.js +57 -0
- package/dist/lib/pagefind-search.d.ts +21 -0
- package/dist/lib/pagefind-search.js +201 -0
- package/dist/lib/search-index.d.ts +43 -0
- package/dist/lib/search-index.js +112 -0
- package/dist/lib/tabs.d.ts +23 -0
- package/dist/lib/tabs.js +30 -0
- package/dist/lib/use-hidden-toggle.d.ts +15 -0
- package/dist/lib/use-hidden-toggle.js +23 -0
- package/dist/lib/use-line-numbers.d.ts +9 -0
- package/dist/lib/use-line-numbers.js +7 -0
- package/dist/lib/use-local-storage.d.ts +15 -0
- package/dist/lib/use-local-storage.js +58 -0
- package/dist/lib/use-media-query.d.ts +5 -0
- package/dist/lib/use-media-query.js +16 -0
- package/dist/renderer/Layout.d.ts +5 -0
- package/dist/renderer/Layout.js +170 -0
- package/dist/renderer/onRenderClient.d.ts +1 -0
- package/dist/renderer/onRenderClient.js +23 -0
- package/dist/renderer/onRenderHtml.d.ts +5 -0
- package/dist/renderer/onRenderHtml.js +44 -0
- package/dist/site-config.d.ts +61 -0
- package/dist/site-config.js +21 -0
- package/dist/styles.css +310 -0
- package/dist/vike.d.ts +12 -0
- package/dist/vike.js +8 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +80 -0
- package/package.json +82 -0
- package/templates/netlify.example.toml +33 -0
- package/templates/set-version.mjs +70 -0
- package/templates/version-branch.sh +16 -0
- package/templates/versions.example.json +15 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { Callout } from './Callout';
|
|
3
|
+
import { Preview } from './Preview';
|
|
4
|
+
import { StatusTable, TestStatus } from './StatusTable';
|
|
5
|
+
/**
|
|
6
|
+
* MDX <pre> wrapper. Pulls language from the inner <code> className
|
|
7
|
+
* (e.g., `language-tsx`) and renders our CodeBlock chrome around it.
|
|
8
|
+
*/
|
|
9
|
+
declare function PreWrapper(props: ComponentPropsWithoutRef<'pre'>): import("react").JSX.Element;
|
|
10
|
+
export declare const mdxComponents: {
|
|
11
|
+
h1: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">>;
|
|
12
|
+
h2: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">>;
|
|
13
|
+
h3: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">>;
|
|
14
|
+
p: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">>;
|
|
15
|
+
ul: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref">>;
|
|
16
|
+
ol: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, "ref">>;
|
|
17
|
+
li: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref">>;
|
|
18
|
+
a: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref">>;
|
|
19
|
+
blockquote: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>, "ref">>;
|
|
20
|
+
table: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref">>;
|
|
21
|
+
th: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, "ref">>;
|
|
22
|
+
td: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, "ref">>;
|
|
23
|
+
code: import('react').FC<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLElement>, HTMLElement>, "ref">>;
|
|
24
|
+
pre: typeof PreWrapper;
|
|
25
|
+
Callout: typeof Callout;
|
|
26
|
+
Preview: typeof Preview;
|
|
27
|
+
StatusTable: typeof StatusTable;
|
|
28
|
+
TestStatus: typeof TestStatus;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, createContext, useState } from "react";
|
|
3
|
+
import { CodeBlock } from "./CodeBlock.js";
|
|
4
|
+
import { Callout } from "./Callout.js";
|
|
5
|
+
import { Preview } from "./Preview.js";
|
|
6
|
+
import { TestStatus, StatusTable } from "./StatusTable.js";
|
|
7
|
+
const InsidePreContext = createContext(false);
|
|
8
|
+
const ChainIcon = () => /* @__PURE__ */ jsxs(
|
|
9
|
+
"svg",
|
|
10
|
+
{
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
fill: "none",
|
|
13
|
+
stroke: "currentColor",
|
|
14
|
+
strokeWidth: "2",
|
|
15
|
+
strokeLinecap: "round",
|
|
16
|
+
strokeLinejoin: "round",
|
|
17
|
+
"aria-hidden": true,
|
|
18
|
+
style: { width: 14, height: 14, display: "block" },
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.71 1.71" }),
|
|
21
|
+
/* @__PURE__ */ jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
const CheckIcon = () => /* @__PURE__ */ jsx(
|
|
26
|
+
"svg",
|
|
27
|
+
{
|
|
28
|
+
viewBox: "0 0 24 24",
|
|
29
|
+
fill: "none",
|
|
30
|
+
stroke: "currentColor",
|
|
31
|
+
strokeWidth: "2.5",
|
|
32
|
+
strokeLinecap: "round",
|
|
33
|
+
strokeLinejoin: "round",
|
|
34
|
+
"aria-hidden": true,
|
|
35
|
+
style: { width: 14, height: 14, display: "block" },
|
|
36
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" })
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
function HeadingAnchor({ id, label }) {
|
|
40
|
+
const [copied, setCopied] = useState(false);
|
|
41
|
+
if (!id) return null;
|
|
42
|
+
const onClick = () => {
|
|
43
|
+
if (typeof window === "undefined") return;
|
|
44
|
+
const url = `${window.location.origin}${window.location.pathname}#${id}`;
|
|
45
|
+
navigator.clipboard?.writeText(url).catch(() => {
|
|
46
|
+
});
|
|
47
|
+
setCopied(true);
|
|
48
|
+
window.setTimeout(() => setCopied(false), 1200);
|
|
49
|
+
};
|
|
50
|
+
const base = "inline-flex items-center justify-center no-underline rounded transition-[opacity,background-color,color] duration-150";
|
|
51
|
+
const idle = "text-doc-template-muted opacity-0 group-hover:opacity-70 hover:!opacity-100 hover:text-doc-template-ink hover:bg-doc-template-chip focus-visible:opacity-100";
|
|
52
|
+
const active = "text-doc-template-accent !opacity-100";
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
"a",
|
|
55
|
+
{
|
|
56
|
+
href: `#${id}`,
|
|
57
|
+
onClick,
|
|
58
|
+
"aria-label": copied ? "Link copied to clipboard" : label ? `Copy link to ${label}` : "Copy link to this section",
|
|
59
|
+
title: copied ? "Copied!" : "Copy link to this section",
|
|
60
|
+
className: `${base} ${copied ? active : idle}`,
|
|
61
|
+
style: { width: 18, height: 18 },
|
|
62
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(ChainIcon, {})
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function flatten(node) {
|
|
67
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
68
|
+
if (Array.isArray(node)) return node.map(flatten).join("");
|
|
69
|
+
if (node && typeof node === "object" && "props" in node) {
|
|
70
|
+
const props = node.props;
|
|
71
|
+
return props ? flatten(props.children) : "";
|
|
72
|
+
}
|
|
73
|
+
return "";
|
|
74
|
+
}
|
|
75
|
+
function PreWrapper(props) {
|
|
76
|
+
const { children, file, language, ...rest } = props;
|
|
77
|
+
return /* @__PURE__ */ jsx(
|
|
78
|
+
CodeBlock,
|
|
79
|
+
{
|
|
80
|
+
lang: typeof language === "string" ? language : void 0,
|
|
81
|
+
filename: typeof file === "string" ? file : void 0,
|
|
82
|
+
children: /* @__PURE__ */ jsx(InsidePreContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
83
|
+
"pre",
|
|
84
|
+
{
|
|
85
|
+
...rest,
|
|
86
|
+
style: {
|
|
87
|
+
margin: 0,
|
|
88
|
+
padding: "14px 16px",
|
|
89
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
90
|
+
fontSize: 12.5,
|
|
91
|
+
lineHeight: 1.3,
|
|
92
|
+
overflowX: "auto",
|
|
93
|
+
background: "transparent",
|
|
94
|
+
...rest.style
|
|
95
|
+
},
|
|
96
|
+
children
|
|
97
|
+
}
|
|
98
|
+
) })
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const H2 = ({ id, children, style, ...rest }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
+
id && /* @__PURE__ */ jsx(
|
|
104
|
+
"span",
|
|
105
|
+
{
|
|
106
|
+
id,
|
|
107
|
+
"aria-hidden": true,
|
|
108
|
+
"data-toc-anchor": true,
|
|
109
|
+
"data-toc-level": "2",
|
|
110
|
+
style: {
|
|
111
|
+
display: "block",
|
|
112
|
+
height: 0,
|
|
113
|
+
marginTop: 16,
|
|
114
|
+
scrollMarginTop: 56
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsxs(
|
|
119
|
+
"h2",
|
|
120
|
+
{
|
|
121
|
+
...rest,
|
|
122
|
+
className: "flex items-center text-doc-template-ink group -mx-[18px] px-[18px] lg:-mx-[56px] lg:px-[56px]",
|
|
123
|
+
style: {
|
|
124
|
+
position: "sticky",
|
|
125
|
+
top: 40,
|
|
126
|
+
zIndex: 3,
|
|
127
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
128
|
+
fontSize: 22,
|
|
129
|
+
fontWeight: 600,
|
|
130
|
+
letterSpacing: "-0.018em",
|
|
131
|
+
marginBottom: 12,
|
|
132
|
+
paddingTop: 12,
|
|
133
|
+
paddingBottom: 8,
|
|
134
|
+
gap: 8,
|
|
135
|
+
lineHeight: 1.2,
|
|
136
|
+
backgroundColor: "color-mix(in srgb, var(--color-doc-template-bg) 92%, transparent)",
|
|
137
|
+
backdropFilter: "saturate(140%) blur(8px)",
|
|
138
|
+
WebkitBackdropFilter: "saturate(140%) blur(8px)",
|
|
139
|
+
...style
|
|
140
|
+
},
|
|
141
|
+
children: [
|
|
142
|
+
children,
|
|
143
|
+
/* @__PURE__ */ jsx(HeadingAnchor, { id, label: flatten(children) })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] });
|
|
148
|
+
const H3 = ({ id, children, style, ...rest }) => /* @__PURE__ */ jsxs(
|
|
149
|
+
"h3",
|
|
150
|
+
{
|
|
151
|
+
id,
|
|
152
|
+
...rest,
|
|
153
|
+
className: "flex items-center text-doc-template-ink group",
|
|
154
|
+
style: {
|
|
155
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
156
|
+
fontSize: 15,
|
|
157
|
+
fontWeight: 600,
|
|
158
|
+
letterSpacing: "-0.005em",
|
|
159
|
+
margin: "18px 0 6px",
|
|
160
|
+
gap: 8,
|
|
161
|
+
scrollMarginTop: 96,
|
|
162
|
+
...style
|
|
163
|
+
},
|
|
164
|
+
children: [
|
|
165
|
+
children,
|
|
166
|
+
/* @__PURE__ */ jsx(HeadingAnchor, { id, label: flatten(children) })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
const H1 = ({ id, children, style, ...rest }) => /* @__PURE__ */ jsxs(
|
|
171
|
+
"h1",
|
|
172
|
+
{
|
|
173
|
+
id,
|
|
174
|
+
...rest,
|
|
175
|
+
className: "flex items-center text-doc-template-ink group",
|
|
176
|
+
style: {
|
|
177
|
+
fontFamily: "var(--font-doc-template-ui)",
|
|
178
|
+
fontSize: 32,
|
|
179
|
+
fontWeight: 700,
|
|
180
|
+
letterSpacing: "-0.025em",
|
|
181
|
+
margin: "18px 0 10px",
|
|
182
|
+
lineHeight: 1.1,
|
|
183
|
+
gap: 8,
|
|
184
|
+
...style
|
|
185
|
+
},
|
|
186
|
+
children: [
|
|
187
|
+
children,
|
|
188
|
+
/* @__PURE__ */ jsx(HeadingAnchor, { id, label: flatten(children) })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
const BODY_FONT_SIZE = 14.5;
|
|
193
|
+
const BODY_LINE_HEIGHT = 1.65;
|
|
194
|
+
const P = ({ children, style, ...rest }) => /* @__PURE__ */ jsx(
|
|
195
|
+
"p",
|
|
196
|
+
{
|
|
197
|
+
...rest,
|
|
198
|
+
style: {
|
|
199
|
+
margin: "0 0 14px",
|
|
200
|
+
fontSize: BODY_FONT_SIZE,
|
|
201
|
+
lineHeight: BODY_LINE_HEIGHT,
|
|
202
|
+
textWrap: "pretty",
|
|
203
|
+
...style
|
|
204
|
+
},
|
|
205
|
+
children
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
const UL = ({ children, style, ...rest }) => /* @__PURE__ */ jsx(
|
|
209
|
+
"ul",
|
|
210
|
+
{
|
|
211
|
+
...rest,
|
|
212
|
+
style: {
|
|
213
|
+
margin: "0 0 14px",
|
|
214
|
+
paddingLeft: 22,
|
|
215
|
+
fontSize: BODY_FONT_SIZE,
|
|
216
|
+
lineHeight: BODY_LINE_HEIGHT,
|
|
217
|
+
// Tailwind's preflight zeroes list-style on ul/ol; restore the
|
|
218
|
+
// default disc/decimal markers (muted color is set via ::marker
|
|
219
|
+
// in app.css, since pseudo-elements can't be styled inline).
|
|
220
|
+
listStyleType: "disc",
|
|
221
|
+
listStylePosition: "outside",
|
|
222
|
+
...style
|
|
223
|
+
},
|
|
224
|
+
children
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
const OL = ({ children, style, ...rest }) => /* @__PURE__ */ jsx(
|
|
228
|
+
"ol",
|
|
229
|
+
{
|
|
230
|
+
...rest,
|
|
231
|
+
style: {
|
|
232
|
+
margin: "0 0 14px",
|
|
233
|
+
paddingLeft: 22,
|
|
234
|
+
fontSize: BODY_FONT_SIZE,
|
|
235
|
+
lineHeight: BODY_LINE_HEIGHT,
|
|
236
|
+
listStyleType: "decimal",
|
|
237
|
+
listStylePosition: "outside",
|
|
238
|
+
...style
|
|
239
|
+
},
|
|
240
|
+
children
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
const LI = ({ children, style, ...rest }) => /* @__PURE__ */ jsx("li", { ...rest, style: { marginBottom: 4, ...style }, children });
|
|
244
|
+
const Blockquote = ({ children, style, ...rest }) => /* @__PURE__ */ jsx(
|
|
245
|
+
"blockquote",
|
|
246
|
+
{
|
|
247
|
+
...rest,
|
|
248
|
+
className: "text-doc-template-muted",
|
|
249
|
+
style: {
|
|
250
|
+
borderLeft: "3px solid color-mix(in srgb, var(--color-doc-template-ink) 22%, transparent)",
|
|
251
|
+
padding: "2px 0 2px 16px",
|
|
252
|
+
margin: "14px 0",
|
|
253
|
+
...style
|
|
254
|
+
},
|
|
255
|
+
children
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
const A = ({ children, style, ...rest }) => /* @__PURE__ */ jsx(
|
|
259
|
+
"a",
|
|
260
|
+
{
|
|
261
|
+
...rest,
|
|
262
|
+
className: "text-doc-template-accent hover:[border-bottom-color:var(--color-doc-template-accent)]",
|
|
263
|
+
style: {
|
|
264
|
+
borderBottom: "1px solid color-mix(in srgb, var(--color-doc-template-accent) 35%, transparent)",
|
|
265
|
+
textDecoration: "none",
|
|
266
|
+
...style
|
|
267
|
+
},
|
|
268
|
+
children
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
const Table = ({ children, style, ...rest }) => /* @__PURE__ */ jsx("table", { ...rest, style: { width: "100%", borderCollapse: "collapse", fontSize: 13, margin: "0 0 14px", ...style }, children });
|
|
272
|
+
const Th = ({ children, style, ...rest }) => /* @__PURE__ */ jsx(
|
|
273
|
+
"th",
|
|
274
|
+
{
|
|
275
|
+
...rest,
|
|
276
|
+
className: "text-doc-template-muted uppercase border-b border-doc-template-faint",
|
|
277
|
+
style: {
|
|
278
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
279
|
+
fontSize: 10,
|
|
280
|
+
letterSpacing: "0.12em",
|
|
281
|
+
textAlign: "left",
|
|
282
|
+
fontWeight: 600,
|
|
283
|
+
background: "color-mix(in srgb, var(--color-doc-template-ink) 2%, transparent)",
|
|
284
|
+
padding: "9px 10px",
|
|
285
|
+
...style
|
|
286
|
+
},
|
|
287
|
+
children
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
const Td = ({ children, style, ...rest }) => /* @__PURE__ */ jsx(
|
|
291
|
+
"td",
|
|
292
|
+
{
|
|
293
|
+
...rest,
|
|
294
|
+
className: "border-b border-doc-template-faint",
|
|
295
|
+
style: { padding: "9px 10px", verticalAlign: "top", ...style },
|
|
296
|
+
children
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
const Code = ({ className, children, style, ...rest }) => {
|
|
300
|
+
const insidePre = useContext(InsidePreContext);
|
|
301
|
+
const isBlock = insidePre || !!className && /(?:shiki|language-|hljs)/.test(className);
|
|
302
|
+
if (isBlock) {
|
|
303
|
+
return /* @__PURE__ */ jsx("code", { className, ...rest, style, children });
|
|
304
|
+
}
|
|
305
|
+
return /* @__PURE__ */ jsx(
|
|
306
|
+
"code",
|
|
307
|
+
{
|
|
308
|
+
...rest,
|
|
309
|
+
className,
|
|
310
|
+
style: {
|
|
311
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
312
|
+
fontSize: "0.88em",
|
|
313
|
+
letterSpacing: "-0.005em",
|
|
314
|
+
background: "var(--color-doc-template-chip)",
|
|
315
|
+
border: "1px solid var(--color-doc-template-faint)",
|
|
316
|
+
padding: "1px 5px",
|
|
317
|
+
borderRadius: 4,
|
|
318
|
+
...style
|
|
319
|
+
},
|
|
320
|
+
children
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
};
|
|
324
|
+
const mdxComponents = {
|
|
325
|
+
h1: H1,
|
|
326
|
+
h2: H2,
|
|
327
|
+
h3: H3,
|
|
328
|
+
p: P,
|
|
329
|
+
ul: UL,
|
|
330
|
+
ol: OL,
|
|
331
|
+
li: LI,
|
|
332
|
+
a: A,
|
|
333
|
+
blockquote: Blockquote,
|
|
334
|
+
table: Table,
|
|
335
|
+
th: Th,
|
|
336
|
+
td: Td,
|
|
337
|
+
code: Code,
|
|
338
|
+
pre: PreWrapper,
|
|
339
|
+
Callout,
|
|
340
|
+
Preview,
|
|
341
|
+
StatusTable,
|
|
342
|
+
TestStatus
|
|
343
|
+
};
|
|
344
|
+
export {
|
|
345
|
+
mdxComponents
|
|
346
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { SiteConfig as _SiteConfig } from './site-config';
|
|
2
|
+
import { PageFrontmatter as _PageFrontmatter } from './lib/navigation';
|
|
3
|
+
import { TabDef as _TabDef } from './lib/tabs';
|
|
4
|
+
/**
|
|
5
|
+
* @dreamlake/dockit — the DreamLake documentation shell as a library.
|
|
6
|
+
*
|
|
7
|
+
* A consuming site initializes the shell once, from a side-effect module
|
|
8
|
+
* (conventionally `site.config.ts`) imported before the renderer entries:
|
|
9
|
+
*
|
|
10
|
+
* import { initDocs } from '@dreamlake/dockit'
|
|
11
|
+
*
|
|
12
|
+
* initDocs({
|
|
13
|
+
* site: { brand: 'DreamLake', subtitle: 'Dockit', … },
|
|
14
|
+
* pages: import.meta.glob('./pages/** /+Page.mdx', { eager: true }),
|
|
15
|
+
* rawPages: import.meta.glob('./pages/** /+Page.mdx', { eager: true, query: '?raw', import: 'default' }),
|
|
16
|
+
* sectionOrder: ['Getting started', 'Reference'],
|
|
17
|
+
* tabs: [{ id: 'overview', label: 'Get Started', numeral: 'I', landing: '/', urlPrefix: '/get-started' }],
|
|
18
|
+
* })
|
|
19
|
+
*/
|
|
20
|
+
export { siteConfig, defineSiteConfig, type SiteConfig, type VersionChip, } from './site-config';
|
|
21
|
+
export { pages, groupedPages, groupedVisiblePages, initNavigation, getAdjacentPages, type PageMeta, type PageFrontmatter, type PageModule, type NavGroup, } from './lib/navigation';
|
|
22
|
+
export { searchIndex, rawMarkdown, initSearchIndex, search, type SearchEntry, type SearchHit, } from './lib/search-index';
|
|
23
|
+
export { searchPages, defaultResults, type SearchResult, type SubResult, } from './lib/pagefind-search';
|
|
24
|
+
export { TABS, initTabs, tabForUrl, urlInTab, type TabDef } from './lib/tabs';
|
|
25
|
+
export { useHiddenToggle } from './lib/use-hidden-toggle';
|
|
26
|
+
export { useLineNumbers } from './lib/use-line-numbers';
|
|
27
|
+
export { useLocalStorage, DOC_PREFIX, docKey } from './lib/use-local-storage';
|
|
28
|
+
export { useMediaQuery } from './lib/use-media-query';
|
|
29
|
+
export { Callout } from './components/Callout';
|
|
30
|
+
export { ClientOnly } from './components/ClientOnly';
|
|
31
|
+
export { CodeBlock } from './components/CodeBlock';
|
|
32
|
+
export { DocFooter } from './components/DocFooter';
|
|
33
|
+
export { mdxComponents } from './components/mdx-components';
|
|
34
|
+
export { Preview, type PreviewProps } from './components/Preview';
|
|
35
|
+
export { SearchPalette } from './components/SearchPalette';
|
|
36
|
+
export { useSearchResize, SearchResizeHandles } from './components/SearchResize';
|
|
37
|
+
export { Sidebar } from './components/Sidebar';
|
|
38
|
+
export { StatusTable, TestStatus } from './components/StatusTable';
|
|
39
|
+
export { TabStrip } from './components/TabStrip';
|
|
40
|
+
export { ThemeProvider, useTheme, type Theme } from './components/ThemeProvider';
|
|
41
|
+
export { ThemeToggle } from './components/ThemeToggle';
|
|
42
|
+
export { TOC } from './components/TOC';
|
|
43
|
+
export { Topbar } from './components/Topbar';
|
|
44
|
+
export { Layout, useMerge } from './renderer/Layout';
|
|
45
|
+
export interface InitDocsOptions {
|
|
46
|
+
/** Site branding, URLs, version chips, git hash. */
|
|
47
|
+
site: Partial<_SiteConfig>;
|
|
48
|
+
/** Eager glob of every `+Page.mdx` module (frontmatter drives nav). */
|
|
49
|
+
pages: Record<string, {
|
|
50
|
+
frontmatter?: _PageFrontmatter;
|
|
51
|
+
}>;
|
|
52
|
+
/** Eager `?raw` glob of the same pages — feeds the dev search index and
|
|
53
|
+
* the palette's markdown preview. Optional but recommended. */
|
|
54
|
+
rawPages?: Record<string, string>;
|
|
55
|
+
/** Authored sidebar section order; unknown sections fall to the end. */
|
|
56
|
+
sectionOrder?: string[];
|
|
57
|
+
/** Topbar tab lenses. Omit (or pass []) for a tabless site. */
|
|
58
|
+
tabs?: _TabDef[];
|
|
59
|
+
}
|
|
60
|
+
/** One call wires the whole shell: site config, navigation, search, tabs. */
|
|
61
|
+
export declare function initDocs(opts: InitDocsOptions): void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { defineSiteConfig } from "./site-config.js";
|
|
2
|
+
import { siteConfig } from "./site-config.js";
|
|
3
|
+
import { initNavigation } from "./lib/navigation.js";
|
|
4
|
+
import { getAdjacentPages, groupedPages, groupedVisiblePages, pages } from "./lib/navigation.js";
|
|
5
|
+
import { initSearchIndex } from "./lib/search-index.js";
|
|
6
|
+
import { rawMarkdown, search, searchIndex } from "./lib/search-index.js";
|
|
7
|
+
import { defaultResults, searchPages } from "./lib/pagefind-search.js";
|
|
8
|
+
import { initTabs } from "./lib/tabs.js";
|
|
9
|
+
import { TABS, tabForUrl, urlInTab } from "./lib/tabs.js";
|
|
10
|
+
import { useHiddenToggle } from "./lib/use-hidden-toggle.js";
|
|
11
|
+
import { useLineNumbers } from "./lib/use-line-numbers.js";
|
|
12
|
+
import { DOC_PREFIX, docKey, useLocalStorage } from "./lib/use-local-storage.js";
|
|
13
|
+
import { useMediaQuery } from "./lib/use-media-query.js";
|
|
14
|
+
import { Callout } from "./components/Callout.js";
|
|
15
|
+
import { ClientOnly } from "./components/ClientOnly.js";
|
|
16
|
+
import { CodeBlock } from "./components/CodeBlock.js";
|
|
17
|
+
import { DocFooter } from "./components/DocFooter.js";
|
|
18
|
+
import { mdxComponents } from "./components/mdx-components.js";
|
|
19
|
+
import { Preview } from "./components/Preview.js";
|
|
20
|
+
import { SearchPalette } from "./components/SearchPalette.js";
|
|
21
|
+
import { SearchResizeHandles, useSearchResize } from "./components/SearchResize.js";
|
|
22
|
+
import { Sidebar } from "./components/Sidebar.js";
|
|
23
|
+
import { StatusTable, TestStatus } from "./components/StatusTable.js";
|
|
24
|
+
import { TabStrip } from "./components/TabStrip.js";
|
|
25
|
+
import { ThemeProvider, useTheme } from "./components/ThemeProvider.js";
|
|
26
|
+
import { ThemeToggle } from "./components/ThemeToggle.js";
|
|
27
|
+
import { TOC } from "./components/TOC.js";
|
|
28
|
+
import { Topbar } from "./components/Topbar.js";
|
|
29
|
+
import { Layout, useMerge } from "./renderer/Layout.js";
|
|
30
|
+
function initDocs(opts) {
|
|
31
|
+
defineSiteConfig(opts.site);
|
|
32
|
+
initNavigation(opts.pages, opts.sectionOrder ?? []);
|
|
33
|
+
initSearchIndex(opts.rawPages ?? {});
|
|
34
|
+
initTabs(opts.tabs ?? []);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
Callout,
|
|
38
|
+
ClientOnly,
|
|
39
|
+
CodeBlock,
|
|
40
|
+
DOC_PREFIX,
|
|
41
|
+
DocFooter,
|
|
42
|
+
Layout,
|
|
43
|
+
Preview,
|
|
44
|
+
SearchPalette,
|
|
45
|
+
SearchResizeHandles,
|
|
46
|
+
Sidebar,
|
|
47
|
+
StatusTable,
|
|
48
|
+
TABS,
|
|
49
|
+
TOC,
|
|
50
|
+
TabStrip,
|
|
51
|
+
TestStatus,
|
|
52
|
+
ThemeProvider,
|
|
53
|
+
ThemeToggle,
|
|
54
|
+
Topbar,
|
|
55
|
+
defaultResults,
|
|
56
|
+
defineSiteConfig,
|
|
57
|
+
docKey,
|
|
58
|
+
getAdjacentPages,
|
|
59
|
+
groupedPages,
|
|
60
|
+
groupedVisiblePages,
|
|
61
|
+
initDocs,
|
|
62
|
+
initNavigation,
|
|
63
|
+
initSearchIndex,
|
|
64
|
+
initTabs,
|
|
65
|
+
mdxComponents,
|
|
66
|
+
pages,
|
|
67
|
+
rawMarkdown,
|
|
68
|
+
search,
|
|
69
|
+
searchIndex,
|
|
70
|
+
searchPages,
|
|
71
|
+
siteConfig,
|
|
72
|
+
tabForUrl,
|
|
73
|
+
urlInTab,
|
|
74
|
+
useHiddenToggle,
|
|
75
|
+
useLineNumbers,
|
|
76
|
+
useLocalStorage,
|
|
77
|
+
useMediaQuery,
|
|
78
|
+
useMerge,
|
|
79
|
+
useSearchResize,
|
|
80
|
+
useTheme
|
|
81
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export interface PageMeta {
|
|
2
|
+
path: string;
|
|
3
|
+
title: string;
|
|
4
|
+
section: string;
|
|
5
|
+
order: number;
|
|
6
|
+
description?: string;
|
|
7
|
+
/** True if the page is awaiting review. Surfaced as a chip in the
|
|
8
|
+
* sidebar so reviewers can spot what still needs eyes on it. */
|
|
9
|
+
draft?: boolean;
|
|
10
|
+
/** True if the page should be hidden from the sidebar by default.
|
|
11
|
+
* Toggle visibility via the "show hidden" global state (Cmd+Shift+D).
|
|
12
|
+
* The page is still reachable via direct URL. */
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
/** True to emit `<meta name="robots" content="noindex, nofollow">`
|
|
15
|
+
* and exclude the page from the pagefind search index. Use for
|
|
16
|
+
* internal/dev pages that should not be discoverable by spiders. */
|
|
17
|
+
noindex?: boolean;
|
|
18
|
+
/** Right-rail TOC depth. 3 (default) surfaces H2 + H3; 2 limits the
|
|
19
|
+
* rail to H2 only. Set in frontmatter on long pages where H3 noise
|
|
20
|
+
* crowds the rail. */
|
|
21
|
+
tocLevel?: 2 | 3;
|
|
22
|
+
fullscreen?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface PageFrontmatter {
|
|
25
|
+
title?: string;
|
|
26
|
+
section?: string;
|
|
27
|
+
order?: number;
|
|
28
|
+
description?: string;
|
|
29
|
+
draft?: boolean;
|
|
30
|
+
hidden?: boolean;
|
|
31
|
+
noindex?: boolean;
|
|
32
|
+
tocLevel?: 2 | 3;
|
|
33
|
+
fullscreen?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface PageModule {
|
|
36
|
+
frontmatter?: PageFrontmatter;
|
|
37
|
+
}
|
|
38
|
+
export interface NavGroup {
|
|
39
|
+
label: string;
|
|
40
|
+
items: PageMeta[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Module-level singletons, populated by `initNavigation()` from the
|
|
44
|
+
* consuming site. The arrays are mutated in place (`.length = 0` + push,
|
|
45
|
+
* never reassigned) so components holding an imported reference always
|
|
46
|
+
* see the current data.
|
|
47
|
+
*/
|
|
48
|
+
/** All pages, sorted by `order` frontmatter. */
|
|
49
|
+
export declare const pages: PageMeta[];
|
|
50
|
+
/** All pages grouped — includes hidden ones. Components filter for
|
|
51
|
+
* visibility themselves so the toggle can flip live without reflowing
|
|
52
|
+
* the data layer. */
|
|
53
|
+
export declare const groupedPages: NavGroup[];
|
|
54
|
+
/** Same shape, but filtered to only-visible pages. Equivalent to
|
|
55
|
+
* `groupedPages` when no page declares `hidden: true`. */
|
|
56
|
+
export declare const groupedVisiblePages: NavGroup[];
|
|
57
|
+
/**
|
|
58
|
+
* Populate the navigation singletons from the site's eager page glob:
|
|
59
|
+
*
|
|
60
|
+
* initNavigation(
|
|
61
|
+
* import.meta.glob('./pages/** /+Page.mdx', { eager: true }),
|
|
62
|
+
* ['Getting started', 'Reference'],
|
|
63
|
+
* )
|
|
64
|
+
*/
|
|
65
|
+
export declare function initNavigation(modules: Record<string, {
|
|
66
|
+
frontmatter?: PageFrontmatter;
|
|
67
|
+
}>, sectionOrder?: string[]): void;
|
|
68
|
+
/** Prev/next adjacency. By default skips `hidden: true` pages so a
|
|
69
|
+
* reader walking the docs sequentially never lands on an internal
|
|
70
|
+
* page they couldn't see in the sidebar. Pass `{ includeHidden: true }`
|
|
71
|
+
* (e.g. from `useHiddenToggle()`) to make hidden pages part of the
|
|
72
|
+
* sequence. If the *current* page is itself hidden it is always
|
|
73
|
+
* included so the user can step out of it. */
|
|
74
|
+
export declare function getAdjacentPages(path: string, opts?: {
|
|
75
|
+
includeHidden?: boolean;
|
|
76
|
+
}): {
|
|
77
|
+
current: PageMeta | null;
|
|
78
|
+
prev: PageMeta | null;
|
|
79
|
+
next: PageMeta | null;
|
|
80
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const pages = [];
|
|
2
|
+
const groupedPages = [];
|
|
3
|
+
const groupedVisiblePages = [];
|
|
4
|
+
let sectionOrderList = [];
|
|
5
|
+
function groupPages(items) {
|
|
6
|
+
const map = /* @__PURE__ */ new Map();
|
|
7
|
+
for (const p of items) {
|
|
8
|
+
if (!map.has(p.section)) map.set(p.section, []);
|
|
9
|
+
map.get(p.section).push(p);
|
|
10
|
+
}
|
|
11
|
+
const known = sectionOrderList.filter((s) => map.has(s));
|
|
12
|
+
const unknown = [...map.keys()].filter((s) => !sectionOrderList.includes(s)).sort();
|
|
13
|
+
return [...known, ...unknown].map((label) => ({ label, items: map.get(label) }));
|
|
14
|
+
}
|
|
15
|
+
function initNavigation(modules, sectionOrder = []) {
|
|
16
|
+
sectionOrderList = sectionOrder;
|
|
17
|
+
const next = Object.entries(modules).map(([filePath, mod]) => {
|
|
18
|
+
const fm = mod.frontmatter ?? {};
|
|
19
|
+
const dir = filePath.replace(/^.*?\bpages\//, "").replace(/\/\+Page\.mdx$/, "");
|
|
20
|
+
const path = dir === "index" ? "/" : `/${dir}`;
|
|
21
|
+
return {
|
|
22
|
+
path,
|
|
23
|
+
title: fm.title ?? dir,
|
|
24
|
+
section: fm.section ?? "",
|
|
25
|
+
order: fm.order ?? 99,
|
|
26
|
+
description: fm.description,
|
|
27
|
+
draft: fm.draft === true,
|
|
28
|
+
hidden: fm.hidden === true,
|
|
29
|
+
noindex: fm.noindex === true,
|
|
30
|
+
tocLevel: fm.tocLevel,
|
|
31
|
+
fullscreen: fm.fullscreen === true
|
|
32
|
+
};
|
|
33
|
+
}).sort((a, b) => a.order - b.order);
|
|
34
|
+
pages.length = 0;
|
|
35
|
+
pages.push(...next);
|
|
36
|
+
groupedPages.length = 0;
|
|
37
|
+
groupedPages.push(...groupPages(pages));
|
|
38
|
+
groupedVisiblePages.length = 0;
|
|
39
|
+
groupedVisiblePages.push(...groupPages(pages.filter((p) => !p.hidden)));
|
|
40
|
+
}
|
|
41
|
+
function getAdjacentPages(path, opts = {}) {
|
|
42
|
+
const here = pages.find((p) => p.path === path);
|
|
43
|
+
const list = opts.includeHidden || here?.hidden ? pages : pages.filter((p) => !p.hidden);
|
|
44
|
+
const idx = list.findIndex((p) => p.path === path);
|
|
45
|
+
return {
|
|
46
|
+
current: idx >= 0 ? list[idx] : null,
|
|
47
|
+
prev: idx > 0 ? list[idx - 1] : null,
|
|
48
|
+
next: idx >= 0 && idx < list.length - 1 ? list[idx + 1] : null
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
getAdjacentPages,
|
|
53
|
+
groupedPages,
|
|
54
|
+
groupedVisiblePages,
|
|
55
|
+
initNavigation,
|
|
56
|
+
pages
|
|
57
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SubResult {
|
|
2
|
+
title: string;
|
|
3
|
+
url: string;
|
|
4
|
+
excerptHtml: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchResult {
|
|
7
|
+
path: string;
|
|
8
|
+
title: string;
|
|
9
|
+
section: string;
|
|
10
|
+
description: string;
|
|
11
|
+
snippet: string;
|
|
12
|
+
/** Pagefind excerpt with <mark> highlights — empty when using the fallback. */
|
|
13
|
+
excerptHtml: string;
|
|
14
|
+
subResults: SubResult[];
|
|
15
|
+
score: number;
|
|
16
|
+
}
|
|
17
|
+
/** Default (empty-query) results — computed lazily because the
|
|
18
|
+
* `searchIndex` singleton is only populated once the consuming site's
|
|
19
|
+
* `initDocs()` has run, which happens *after* this module evaluates. */
|
|
20
|
+
export declare function defaultResults(): SearchResult[];
|
|
21
|
+
export declare function searchPages(query: string, limit?: number, showHidden?: boolean): Promise<SearchResult[]>;
|