@lukoweb/apitogo 0.1.1 → 0.1.3
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/cli.js +168 -57
- package/dist/declarations/lib/ui/Command.d.ts +1 -1
- package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
- package/package.json +2 -1
- package/src/app/main.tsx +150 -150
- package/src/config/loader.ts +245 -245
- package/src/index.ts +33 -33
- package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
- package/src/lib/authentication/components/SignIn.tsx +46 -46
- package/src/lib/authentication/components/SignUp.tsx +48 -48
- package/src/lib/authentication/providers/clerk.tsx +224 -224
- package/src/lib/authentication/ui/AuthCard.tsx +7 -7
- package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
- package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
- package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
- package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
- package/src/lib/components/Autocomplete.tsx +123 -123
- package/src/lib/components/DeveloperHint.tsx +39 -35
- package/src/lib/components/Header.tsx +260 -260
- package/src/lib/components/Layout.tsx +53 -53
- package/src/lib/components/Main.tsx +51 -51
- package/src/lib/components/Mermaid.tsx +74 -70
- package/src/lib/components/MobileTopNavigation.tsx +276 -276
- package/src/lib/components/MultiSelect.tsx +86 -82
- package/src/lib/components/TopNavigation.tsx +103 -103
- package/src/lib/components/index.ts +26 -26
- package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
- package/src/lib/components/navigation/NavigationItem.tsx +181 -177
- package/src/lib/core/RouteGuard.tsx +193 -193
- package/src/lib/errors/ErrorMessage.tsx +50 -46
- package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
- package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
- package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
- package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
- package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
- package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
- package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
- package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
- package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
- package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
- package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
- package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
- package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
- package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
- package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
- package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
- package/src/lib/ui/ActionButton.tsx +21 -21
- package/src/lib/ui/Command.tsx +191 -191
- package/src/lib/util/MdxComponents.tsx +150 -150
- package/src/vite/config.ts +234 -231
- package/src/vite/dev-server.ts +291 -291
- package/src/vite/plugin-api-keys.ts +50 -50
- package/src/vite/plugin-api.ts +320 -318
- package/src/vite/plugin-auth.ts +38 -38
- package/src/vite/plugin-component.ts +45 -39
- package/src/vite/plugin-config.ts +75 -75
- package/src/vite/plugin-custom-pages.ts +36 -36
- package/src/vite/plugin-docs.ts +202 -202
- package/src/vite/plugin-markdown-export.ts +214 -214
- package/src/vite/plugin-mdx.ts +149 -149
- package/src/vite/plugin-navigation.ts +106 -106
- package/src/vite/plugin-search.ts +47 -47
- package/src/vite/plugin.ts +42 -42
- package/src/vite/prerender/prerender.ts +233 -233
|
@@ -1,285 +1,285 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "
|
|
21
|
-
import { AiAssistantMenuItems } from "../../components/AiAssistantMenuItems.js";
|
|
22
|
-
import { CategoryHeading } from "../../components/CategoryHeading.js";
|
|
23
|
-
import { useZudoku } from "../../components/context/ZudokuContext.js";
|
|
24
|
-
import { DeveloperHint } from "../../components/DeveloperHint.js";
|
|
25
|
-
import { Heading } from "../../components/Heading.js";
|
|
26
|
-
import { Toc } from "../../components/navigation/Toc.js";
|
|
27
|
-
import {
|
|
28
|
-
useCurrentItem,
|
|
29
|
-
usePrevNext,
|
|
30
|
-
} from "../../components/navigation/utils.js";
|
|
31
|
-
import { Pagination } from "../../components/Pagination.js";
|
|
32
|
-
import { Typography } from "../../components/Typography.js";
|
|
33
|
-
import { joinUrl } from "../../util/joinUrl.js";
|
|
34
|
-
import type { MdxComponentsType } from "../../util/MdxComponents.js";
|
|
35
|
-
import { slugify } from "../../util/slugify.js";
|
|
36
|
-
import type { MarkdownPluginDefaultOptions, MDXImport } from "./index.js";
|
|
37
|
-
|
|
38
|
-
declare global {
|
|
39
|
-
interface Window {
|
|
40
|
-
__getReactRefreshIgnoredExports?: (args: {
|
|
41
|
-
id: string;
|
|
42
|
-
}) => string[] | undefined;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const MarkdownHeadings = {
|
|
47
|
-
h2: ({ children, id }) => (
|
|
48
|
-
<Heading level={2} id={id} registerNavigationAnchor>
|
|
49
|
-
{children}
|
|
50
|
-
</Heading>
|
|
51
|
-
),
|
|
52
|
-
h3: ({ children, id }) => (
|
|
53
|
-
<Heading level={3} id={id} registerNavigationAnchor>
|
|
54
|
-
{children}
|
|
55
|
-
</Heading>
|
|
56
|
-
),
|
|
57
|
-
} satisfies MdxComponentsType;
|
|
58
|
-
|
|
59
|
-
export const MdxPage = ({
|
|
60
|
-
mdxComponent: MdxComponent,
|
|
61
|
-
basePath,
|
|
62
|
-
frontmatter = {},
|
|
63
|
-
defaultOptions,
|
|
64
|
-
__filepath,
|
|
65
|
-
tableOfContents,
|
|
66
|
-
excerpt,
|
|
67
|
-
}: PropsWithChildren<
|
|
68
|
-
Omit<MDXImport, "default"> & {
|
|
69
|
-
basePath: string;
|
|
70
|
-
mdxComponent: MDXImport["default"];
|
|
71
|
-
defaultOptions?: MarkdownPluginDefaultOptions;
|
|
72
|
-
}
|
|
73
|
-
>) => {
|
|
74
|
-
const categoryTitle = useCurrentItem()?.categoryLabel;
|
|
75
|
-
const location = useLocation();
|
|
76
|
-
const { options } = useZudoku();
|
|
77
|
-
const [isCopied, setIsCopied] = useState(false);
|
|
78
|
-
|
|
79
|
-
const title = frontmatter.title;
|
|
80
|
-
const description = frontmatter.description ?? excerpt;
|
|
81
|
-
const category = frontmatter.category ?? categoryTitle;
|
|
82
|
-
const hideToc = frontmatter.toc === false || defaultOptions?.toc === false;
|
|
83
|
-
const pageTitle =
|
|
84
|
-
title ?? tableOfContents.find((item) => item.depth === 1)?.text;
|
|
85
|
-
const hidePager =
|
|
86
|
-
frontmatter.disable_pager ??
|
|
87
|
-
frontmatter.disablePager ??
|
|
88
|
-
defaultOptions?.disablePager ??
|
|
89
|
-
false;
|
|
90
|
-
|
|
91
|
-
const showLastModified =
|
|
92
|
-
frontmatter.showLastModified ?? defaultOptions?.showLastModified ?? true;
|
|
93
|
-
|
|
94
|
-
const lastModifiedDate = frontmatter.lastModifiedTime
|
|
95
|
-
? new Date(frontmatter.lastModifiedTime)
|
|
96
|
-
: null;
|
|
97
|
-
|
|
98
|
-
const editConfig =
|
|
99
|
-
frontmatter.suggestEdit !== false &&
|
|
100
|
-
(frontmatter.suggestEdit ?? defaultOptions?.suggestEdit);
|
|
101
|
-
|
|
102
|
-
const editUrl = editConfig
|
|
103
|
-
? editConfig.url.replaceAll("{filePath}", __filepath)
|
|
104
|
-
: null;
|
|
105
|
-
const editText = editConfig ? editConfig.text || "Edit this page" : null;
|
|
106
|
-
|
|
107
|
-
const copyMarkdownConfig =
|
|
108
|
-
frontmatter.copyPage !== false && defaultOptions?.copyPage !== false;
|
|
109
|
-
|
|
110
|
-
const markdownUrl = joinUrl(basePath, `${location.pathname}.md`);
|
|
111
|
-
|
|
112
|
-
const handleCopyMarkdown = async () => {
|
|
113
|
-
const response = await fetch(markdownUrl);
|
|
114
|
-
if (!response.ok) throw new Error("Failed to fetch markdown");
|
|
115
|
-
const markdown = await response.text();
|
|
116
|
-
void navigator.clipboard.writeText(markdown);
|
|
117
|
-
setIsCopied(true);
|
|
118
|
-
setTimeout(() => setIsCopied(false), 2000);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const tocEntries =
|
|
122
|
-
tableOfContents.find((item) => item.depth === 1)?.children ??
|
|
123
|
-
// if `title` is provided by frontmatter it does not appear in the table of contents
|
|
124
|
-
tableOfContents.filter((item) => item.depth === 2);
|
|
125
|
-
|
|
126
|
-
const showToc = !hideToc && tocEntries.length > 0;
|
|
127
|
-
|
|
128
|
-
const { prev, next } = usePrevNext();
|
|
129
|
-
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
if (process.env.NODE_ENV === "development") {
|
|
132
|
-
window.__getReactRefreshIgnoredExports = ({ id }) => {
|
|
133
|
-
if (!id.endsWith(__filepath)) return;
|
|
134
|
-
|
|
135
|
-
return ["frontmatter", "tableOfContents"];
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
return () => {
|
|
139
|
-
window.__getReactRefreshIgnoredExports = undefined;
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
}, [__filepath]);
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<div
|
|
146
|
-
className="grid grid-cols-1 xl:grid-cols-(--sidecar-grid-cols) gap-8 justify-between"
|
|
147
|
-
data-pagefind-filter="section:markdown"
|
|
148
|
-
data-pagefind-meta="section:markdown"
|
|
149
|
-
>
|
|
150
|
-
<Helmet>
|
|
151
|
-
<title>{pageTitle}</title>
|
|
152
|
-
{description && <meta name="description" content={description} />}
|
|
153
|
-
</Helmet>
|
|
154
|
-
|
|
155
|
-
<Typography className="max-w-full xl:w-full xl:max-w-3xl flex-1 shrink pt-(--padding-content-top)">
|
|
156
|
-
<header className="flow-root">
|
|
157
|
-
{copyMarkdownConfig && (
|
|
158
|
-
<div
|
|
159
|
-
className="float-end ms-4 mt-1"
|
|
160
|
-
role="group"
|
|
161
|
-
aria-label="Page actions"
|
|
162
|
-
>
|
|
163
|
-
<ButtonGroup>
|
|
164
|
-
<Button
|
|
165
|
-
variant="outline"
|
|
166
|
-
size="sm"
|
|
167
|
-
onClick={handleCopyMarkdown}
|
|
168
|
-
>
|
|
169
|
-
{isCopied ? (
|
|
170
|
-
<CheckIcon size={14} className="text-emerald-600" />
|
|
171
|
-
) : (
|
|
172
|
-
<CopyIcon size={14} />
|
|
173
|
-
)}
|
|
174
|
-
<span>Copy page</span>
|
|
175
|
-
</Button>
|
|
176
|
-
<DropdownMenu>
|
|
177
|
-
<DropdownMenuTrigger asChild>
|
|
178
|
-
<Button variant="outline" size="icon-sm">
|
|
179
|
-
<ChevronDownIcon size={14} />
|
|
180
|
-
</Button>
|
|
181
|
-
</DropdownMenuTrigger>
|
|
182
|
-
<DropdownMenuContent align="end">
|
|
183
|
-
<DropdownMenuItem
|
|
184
|
-
className="gap-2"
|
|
185
|
-
onClick={() =>
|
|
186
|
-
void navigator.clipboard.writeText(window.location.href)
|
|
187
|
-
}
|
|
188
|
-
>
|
|
189
|
-
<Link2Icon className="size-4" />
|
|
190
|
-
Copy link to page
|
|
191
|
-
</DropdownMenuItem>
|
|
192
|
-
<DropdownMenuItem className="gap-2" asChild>
|
|
193
|
-
<a
|
|
194
|
-
href={markdownUrl}
|
|
195
|
-
target="_blank"
|
|
196
|
-
rel="noopener noreferrer"
|
|
197
|
-
>
|
|
198
|
-
<ExternalLinkIcon className="size-4" />
|
|
199
|
-
Open Markdown page
|
|
200
|
-
</a>
|
|
201
|
-
</DropdownMenuItem>
|
|
202
|
-
<AiAssistantMenuItems
|
|
203
|
-
aiAssistants={options.aiAssistants}
|
|
204
|
-
getPageUrl={() => window.location.href}
|
|
205
|
-
type="docs"
|
|
206
|
-
/>
|
|
207
|
-
</DropdownMenuContent>
|
|
208
|
-
</DropdownMenu>
|
|
209
|
-
</ButtonGroup>
|
|
210
|
-
</div>
|
|
211
|
-
)}
|
|
212
|
-
{category && <CategoryHeading>{category}</CategoryHeading>}
|
|
213
|
-
{title && (
|
|
214
|
-
<Heading level={1} id={slugify(title)}>
|
|
215
|
-
{title}
|
|
216
|
-
</Heading>
|
|
217
|
-
)}
|
|
218
|
-
</header>
|
|
219
|
-
|
|
220
|
-
{frontmatter.draft && (
|
|
221
|
-
<DeveloperHint>
|
|
222
|
-
This page is a draft and is not visible in production.
|
|
223
|
-
</DeveloperHint>
|
|
224
|
-
)}
|
|
225
|
-
|
|
226
|
-
<MdxComponent
|
|
227
|
-
components={{ ...useMDXComponents(), ...MarkdownHeadings }}
|
|
228
|
-
/>
|
|
229
|
-
<div className="h-16" />
|
|
230
|
-
{(showLastModified && lastModifiedDate) || editUrl ? (
|
|
231
|
-
<div className="flex justify-between text-xs text-muted-foreground ">
|
|
232
|
-
<div />
|
|
233
|
-
<div className="flex items-center gap-2">
|
|
234
|
-
<div>
|
|
235
|
-
{editUrl && (
|
|
236
|
-
<Button asChild variant="ghost" size="sm">
|
|
237
|
-
<a
|
|
238
|
-
href={editUrl}
|
|
239
|
-
target="_blank"
|
|
240
|
-
rel="noopener noreferrer"
|
|
241
|
-
className="flex items-center gap-1"
|
|
242
|
-
>
|
|
243
|
-
<EditIcon size={12} />
|
|
244
|
-
{editText}
|
|
245
|
-
</a>
|
|
246
|
-
</Button>
|
|
247
|
-
)}
|
|
248
|
-
</div>
|
|
249
|
-
<div>
|
|
250
|
-
{showLastModified && lastModifiedDate && (
|
|
251
|
-
<div
|
|
252
|
-
title={lastModifiedDate.toLocaleString(undefined, {
|
|
253
|
-
dateStyle: "full",
|
|
254
|
-
timeStyle: "medium",
|
|
255
|
-
})}
|
|
256
|
-
>
|
|
257
|
-
Last modified on{" "}
|
|
258
|
-
<time dateTime={lastModifiedDate.toISOString()}>
|
|
259
|
-
{lastModifiedDate.toLocaleDateString("en-US", {
|
|
260
|
-
dateStyle: "long",
|
|
261
|
-
})}
|
|
262
|
-
</time>
|
|
263
|
-
</div>
|
|
264
|
-
)}
|
|
265
|
-
</div>
|
|
266
|
-
</div>
|
|
267
|
-
</div>
|
|
268
|
-
) : null}
|
|
269
|
-
{!hidePager && (
|
|
270
|
-
<>
|
|
271
|
-
<div className="h-px bg-border mt-2 mb-6" />
|
|
272
|
-
<Pagination
|
|
273
|
-
prev={prev ? { to: prev.id, label: prev.label ?? "" } : undefined}
|
|
274
|
-
next={next ? { to: next.id, label: next.label ?? "" } : undefined}
|
|
275
|
-
className="mb-10"
|
|
276
|
-
/>
|
|
277
|
-
</>
|
|
278
|
-
)}
|
|
279
|
-
</Typography>
|
|
280
|
-
<div className="hidden xl:block" data-pagefind-ignore="all">
|
|
281
|
-
{showToc && <Toc entries={tocEntries} />}
|
|
282
|
-
</div>
|
|
283
|
-
</div>
|
|
284
|
-
);
|
|
285
|
-
};
|
|
1
|
+
import { Button } from "@lukoweb/apitogo/ui/Button.js";
|
|
2
|
+
import { ButtonGroup } from "@lukoweb/apitogo/ui/ButtonGroup.js";
|
|
3
|
+
import {
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuContent,
|
|
6
|
+
DropdownMenuItem,
|
|
7
|
+
DropdownMenuTrigger,
|
|
8
|
+
} from "@lukoweb/apitogo/ui/DropdownMenu.js";
|
|
9
|
+
import { useMDXComponents } from "@mdx-js/react";
|
|
10
|
+
import { Helmet } from "@zudoku/react-helmet-async";
|
|
11
|
+
import {
|
|
12
|
+
CheckIcon,
|
|
13
|
+
ChevronDownIcon,
|
|
14
|
+
CopyIcon,
|
|
15
|
+
EditIcon,
|
|
16
|
+
ExternalLinkIcon,
|
|
17
|
+
Link2Icon,
|
|
18
|
+
} from "lucide-react";
|
|
19
|
+
import { type PropsWithChildren, useEffect, useState } from "react";
|
|
20
|
+
import { useLocation } from "react-router";
|
|
21
|
+
import { AiAssistantMenuItems } from "../../components/AiAssistantMenuItems.js";
|
|
22
|
+
import { CategoryHeading } from "../../components/CategoryHeading.js";
|
|
23
|
+
import { useZudoku } from "../../components/context/ZudokuContext.js";
|
|
24
|
+
import { DeveloperHint } from "../../components/DeveloperHint.js";
|
|
25
|
+
import { Heading } from "../../components/Heading.js";
|
|
26
|
+
import { Toc } from "../../components/navigation/Toc.js";
|
|
27
|
+
import {
|
|
28
|
+
useCurrentItem,
|
|
29
|
+
usePrevNext,
|
|
30
|
+
} from "../../components/navigation/utils.js";
|
|
31
|
+
import { Pagination } from "../../components/Pagination.js";
|
|
32
|
+
import { Typography } from "../../components/Typography.js";
|
|
33
|
+
import { joinUrl } from "../../util/joinUrl.js";
|
|
34
|
+
import type { MdxComponentsType } from "../../util/MdxComponents.js";
|
|
35
|
+
import { slugify } from "../../util/slugify.js";
|
|
36
|
+
import type { MarkdownPluginDefaultOptions, MDXImport } from "./index.js";
|
|
37
|
+
|
|
38
|
+
declare global {
|
|
39
|
+
interface Window {
|
|
40
|
+
__getReactRefreshIgnoredExports?: (args: {
|
|
41
|
+
id: string;
|
|
42
|
+
}) => string[] | undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const MarkdownHeadings = {
|
|
47
|
+
h2: ({ children, id }) => (
|
|
48
|
+
<Heading level={2} id={id} registerNavigationAnchor>
|
|
49
|
+
{children}
|
|
50
|
+
</Heading>
|
|
51
|
+
),
|
|
52
|
+
h3: ({ children, id }) => (
|
|
53
|
+
<Heading level={3} id={id} registerNavigationAnchor>
|
|
54
|
+
{children}
|
|
55
|
+
</Heading>
|
|
56
|
+
),
|
|
57
|
+
} satisfies MdxComponentsType;
|
|
58
|
+
|
|
59
|
+
export const MdxPage = ({
|
|
60
|
+
mdxComponent: MdxComponent,
|
|
61
|
+
basePath,
|
|
62
|
+
frontmatter = {},
|
|
63
|
+
defaultOptions,
|
|
64
|
+
__filepath,
|
|
65
|
+
tableOfContents,
|
|
66
|
+
excerpt,
|
|
67
|
+
}: PropsWithChildren<
|
|
68
|
+
Omit<MDXImport, "default"> & {
|
|
69
|
+
basePath: string;
|
|
70
|
+
mdxComponent: MDXImport["default"];
|
|
71
|
+
defaultOptions?: MarkdownPluginDefaultOptions;
|
|
72
|
+
}
|
|
73
|
+
>) => {
|
|
74
|
+
const categoryTitle = useCurrentItem()?.categoryLabel;
|
|
75
|
+
const location = useLocation();
|
|
76
|
+
const { options } = useZudoku();
|
|
77
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
78
|
+
|
|
79
|
+
const title = frontmatter.title;
|
|
80
|
+
const description = frontmatter.description ?? excerpt;
|
|
81
|
+
const category = frontmatter.category ?? categoryTitle;
|
|
82
|
+
const hideToc = frontmatter.toc === false || defaultOptions?.toc === false;
|
|
83
|
+
const pageTitle =
|
|
84
|
+
title ?? tableOfContents.find((item) => item.depth === 1)?.text;
|
|
85
|
+
const hidePager =
|
|
86
|
+
frontmatter.disable_pager ??
|
|
87
|
+
frontmatter.disablePager ??
|
|
88
|
+
defaultOptions?.disablePager ??
|
|
89
|
+
false;
|
|
90
|
+
|
|
91
|
+
const showLastModified =
|
|
92
|
+
frontmatter.showLastModified ?? defaultOptions?.showLastModified ?? true;
|
|
93
|
+
|
|
94
|
+
const lastModifiedDate = frontmatter.lastModifiedTime
|
|
95
|
+
? new Date(frontmatter.lastModifiedTime)
|
|
96
|
+
: null;
|
|
97
|
+
|
|
98
|
+
const editConfig =
|
|
99
|
+
frontmatter.suggestEdit !== false &&
|
|
100
|
+
(frontmatter.suggestEdit ?? defaultOptions?.suggestEdit);
|
|
101
|
+
|
|
102
|
+
const editUrl = editConfig
|
|
103
|
+
? editConfig.url.replaceAll("{filePath}", __filepath)
|
|
104
|
+
: null;
|
|
105
|
+
const editText = editConfig ? editConfig.text || "Edit this page" : null;
|
|
106
|
+
|
|
107
|
+
const copyMarkdownConfig =
|
|
108
|
+
frontmatter.copyPage !== false && defaultOptions?.copyPage !== false;
|
|
109
|
+
|
|
110
|
+
const markdownUrl = joinUrl(basePath, `${location.pathname}.md`);
|
|
111
|
+
|
|
112
|
+
const handleCopyMarkdown = async () => {
|
|
113
|
+
const response = await fetch(markdownUrl);
|
|
114
|
+
if (!response.ok) throw new Error("Failed to fetch markdown");
|
|
115
|
+
const markdown = await response.text();
|
|
116
|
+
void navigator.clipboard.writeText(markdown);
|
|
117
|
+
setIsCopied(true);
|
|
118
|
+
setTimeout(() => setIsCopied(false), 2000);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const tocEntries =
|
|
122
|
+
tableOfContents.find((item) => item.depth === 1)?.children ??
|
|
123
|
+
// if `title` is provided by frontmatter it does not appear in the table of contents
|
|
124
|
+
tableOfContents.filter((item) => item.depth === 2);
|
|
125
|
+
|
|
126
|
+
const showToc = !hideToc && tocEntries.length > 0;
|
|
127
|
+
|
|
128
|
+
const { prev, next } = usePrevNext();
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (process.env.NODE_ENV === "development") {
|
|
132
|
+
window.__getReactRefreshIgnoredExports = ({ id }) => {
|
|
133
|
+
if (!id.endsWith(__filepath)) return;
|
|
134
|
+
|
|
135
|
+
return ["frontmatter", "tableOfContents"];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return () => {
|
|
139
|
+
window.__getReactRefreshIgnoredExports = undefined;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}, [__filepath]);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<div
|
|
146
|
+
className="grid grid-cols-1 xl:grid-cols-(--sidecar-grid-cols) gap-8 justify-between"
|
|
147
|
+
data-pagefind-filter="section:markdown"
|
|
148
|
+
data-pagefind-meta="section:markdown"
|
|
149
|
+
>
|
|
150
|
+
<Helmet>
|
|
151
|
+
<title>{pageTitle}</title>
|
|
152
|
+
{description && <meta name="description" content={description} />}
|
|
153
|
+
</Helmet>
|
|
154
|
+
|
|
155
|
+
<Typography className="max-w-full xl:w-full xl:max-w-3xl flex-1 shrink pt-(--padding-content-top)">
|
|
156
|
+
<header className="flow-root">
|
|
157
|
+
{copyMarkdownConfig && (
|
|
158
|
+
<div
|
|
159
|
+
className="float-end ms-4 mt-1"
|
|
160
|
+
role="group"
|
|
161
|
+
aria-label="Page actions"
|
|
162
|
+
>
|
|
163
|
+
<ButtonGroup>
|
|
164
|
+
<Button
|
|
165
|
+
variant="outline"
|
|
166
|
+
size="sm"
|
|
167
|
+
onClick={handleCopyMarkdown}
|
|
168
|
+
>
|
|
169
|
+
{isCopied ? (
|
|
170
|
+
<CheckIcon size={14} className="text-emerald-600" />
|
|
171
|
+
) : (
|
|
172
|
+
<CopyIcon size={14} />
|
|
173
|
+
)}
|
|
174
|
+
<span>Copy page</span>
|
|
175
|
+
</Button>
|
|
176
|
+
<DropdownMenu>
|
|
177
|
+
<DropdownMenuTrigger asChild>
|
|
178
|
+
<Button variant="outline" size="icon-sm">
|
|
179
|
+
<ChevronDownIcon size={14} />
|
|
180
|
+
</Button>
|
|
181
|
+
</DropdownMenuTrigger>
|
|
182
|
+
<DropdownMenuContent align="end">
|
|
183
|
+
<DropdownMenuItem
|
|
184
|
+
className="gap-2"
|
|
185
|
+
onClick={() =>
|
|
186
|
+
void navigator.clipboard.writeText(window.location.href)
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
<Link2Icon className="size-4" />
|
|
190
|
+
Copy link to page
|
|
191
|
+
</DropdownMenuItem>
|
|
192
|
+
<DropdownMenuItem className="gap-2" asChild>
|
|
193
|
+
<a
|
|
194
|
+
href={markdownUrl}
|
|
195
|
+
target="_blank"
|
|
196
|
+
rel="noopener noreferrer"
|
|
197
|
+
>
|
|
198
|
+
<ExternalLinkIcon className="size-4" />
|
|
199
|
+
Open Markdown page
|
|
200
|
+
</a>
|
|
201
|
+
</DropdownMenuItem>
|
|
202
|
+
<AiAssistantMenuItems
|
|
203
|
+
aiAssistants={options.aiAssistants}
|
|
204
|
+
getPageUrl={() => window.location.href}
|
|
205
|
+
type="docs"
|
|
206
|
+
/>
|
|
207
|
+
</DropdownMenuContent>
|
|
208
|
+
</DropdownMenu>
|
|
209
|
+
</ButtonGroup>
|
|
210
|
+
</div>
|
|
211
|
+
)}
|
|
212
|
+
{category && <CategoryHeading>{category}</CategoryHeading>}
|
|
213
|
+
{title && (
|
|
214
|
+
<Heading level={1} id={slugify(title)}>
|
|
215
|
+
{title}
|
|
216
|
+
</Heading>
|
|
217
|
+
)}
|
|
218
|
+
</header>
|
|
219
|
+
|
|
220
|
+
{frontmatter.draft && (
|
|
221
|
+
<DeveloperHint>
|
|
222
|
+
This page is a draft and is not visible in production.
|
|
223
|
+
</DeveloperHint>
|
|
224
|
+
)}
|
|
225
|
+
|
|
226
|
+
<MdxComponent
|
|
227
|
+
components={{ ...useMDXComponents(), ...MarkdownHeadings }}
|
|
228
|
+
/>
|
|
229
|
+
<div className="h-16" />
|
|
230
|
+
{(showLastModified && lastModifiedDate) || editUrl ? (
|
|
231
|
+
<div className="flex justify-between text-xs text-muted-foreground ">
|
|
232
|
+
<div />
|
|
233
|
+
<div className="flex items-center gap-2">
|
|
234
|
+
<div>
|
|
235
|
+
{editUrl && (
|
|
236
|
+
<Button asChild variant="ghost" size="sm">
|
|
237
|
+
<a
|
|
238
|
+
href={editUrl}
|
|
239
|
+
target="_blank"
|
|
240
|
+
rel="noopener noreferrer"
|
|
241
|
+
className="flex items-center gap-1"
|
|
242
|
+
>
|
|
243
|
+
<EditIcon size={12} />
|
|
244
|
+
{editText}
|
|
245
|
+
</a>
|
|
246
|
+
</Button>
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
<div>
|
|
250
|
+
{showLastModified && lastModifiedDate && (
|
|
251
|
+
<div
|
|
252
|
+
title={lastModifiedDate.toLocaleString(undefined, {
|
|
253
|
+
dateStyle: "full",
|
|
254
|
+
timeStyle: "medium",
|
|
255
|
+
})}
|
|
256
|
+
>
|
|
257
|
+
Last modified on{" "}
|
|
258
|
+
<time dateTime={lastModifiedDate.toISOString()}>
|
|
259
|
+
{lastModifiedDate.toLocaleDateString("en-US", {
|
|
260
|
+
dateStyle: "long",
|
|
261
|
+
})}
|
|
262
|
+
</time>
|
|
263
|
+
</div>
|
|
264
|
+
)}
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
) : null}
|
|
269
|
+
{!hidePager && (
|
|
270
|
+
<>
|
|
271
|
+
<div className="h-px bg-border mt-2 mb-6" />
|
|
272
|
+
<Pagination
|
|
273
|
+
prev={prev ? { to: prev.id, label: prev.label ?? "" } : undefined}
|
|
274
|
+
next={next ? { to: next.id, label: next.label ?? "" } : undefined}
|
|
275
|
+
className="mb-10"
|
|
276
|
+
/>
|
|
277
|
+
</>
|
|
278
|
+
)}
|
|
279
|
+
</Typography>
|
|
280
|
+
<div className="hidden xl:block" data-pagefind-ignore="all">
|
|
281
|
+
{showToc && <Toc entries={tocEntries} />}
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
};
|