@umami/shiso 0.55.0 → 0.61.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/CHANGELOG.md +12 -0
- package/README.md +9 -49
- package/bin/shiso.mjs +132 -0
- package/docs.schema.json +835 -0
- package/mdx.config.ts +143 -0
- package/package.json +73 -83
- package/scripts/check-package.mjs +18 -0
- package/scripts/generate-icon-registry.mjs +196 -0
- package/scripts/generate-last-modified.mjs +128 -0
- package/scripts/generate-search-index.mjs +252 -0
- package/scripts/load-docs-config.mjs +244 -0
- package/scripts/prerender.mjs +187 -0
- package/scripts/validate-config.mjs +104 -0
- package/scripts/vite-docs-config.mjs +60 -0
- package/src/App.tsx +39 -0
- package/src/components/Banner.tsx +69 -0
- package/src/components/CodeBlock.tsx +46 -0
- package/src/components/ConfiguredIcon.tsx +15 -0
- package/src/components/ContextualMenu.tsx +93 -0
- package/src/components/DocContent.tsx +100 -0
- package/src/components/Docs.tsx +126 -0
- package/src/components/Footer.tsx +84 -0
- package/src/components/Header.tsx +72 -0
- package/src/components/Layout.tsx +16 -0
- package/src/components/PageLinks.tsx +71 -0
- package/src/components/Search.tsx +208 -0
- package/src/components/SideNav.tsx +347 -0
- package/src/components/SocialIcon.tsx +88 -0
- package/src/components/ThemeToggle.tsx +34 -0
- package/src/components/TopNav.tsx +127 -0
- package/src/components/docs/Accordion.tsx +68 -0
- package/src/components/docs/Badge.tsx +171 -0
- package/src/components/docs/Callout.tsx +73 -0
- package/src/components/docs/Card.tsx +158 -0
- package/src/components/docs/CodeGroup.tsx +73 -0
- package/src/components/docs/Columns.tsx +20 -0
- package/src/components/docs/Expandable.tsx +28 -0
- package/src/components/docs/Frame.tsx +56 -0
- package/src/components/docs/Icon.tsx +30 -0
- package/src/components/docs/ParamField.tsx +45 -0
- package/src/components/docs/PropertiesTable.tsx +84 -0
- package/src/components/docs/ResponseField.tsx +36 -0
- package/src/components/docs/Steps.tsx +47 -0
- package/src/components/docs/Tabs.tsx +116 -0
- package/src/components/docs/Tooltip.tsx +21 -0
- package/src/components/docs/index.ts +15 -0
- package/src/components/docs/styles.ts +82 -0
- package/src/components/docs/utils.ts +118 -0
- package/src/components/icons/index.ts +17 -0
- package/src/components/ui/accordion.tsx +69 -0
- package/src/components/ui/alert.tsx +69 -0
- package/src/components/ui/badge.tsx +49 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/card.tsx +88 -0
- package/src/components/ui/collapsible.tsx +15 -0
- package/src/components/ui/command.tsx +173 -0
- package/src/components/ui/dialog.tsx +137 -0
- package/src/components/ui/dropdown-menu.tsx +257 -0
- package/src/components/ui/scroll-area.tsx +71 -0
- package/src/components/ui/sheet.tsx +124 -0
- package/src/components/ui/tabs.tsx +73 -0
- package/src/components/ui/tooltip.tsx +52 -0
- package/src/declarations.d.ts +9 -0
- package/src/entry-client.tsx +17 -0
- package/src/entry-server.tsx +77 -0
- package/src/generated/last-modified.ts +2 -0
- package/src/lib/content.ts +44 -0
- package/src/lib/docs-config.ts +682 -0
- package/src/lib/head.ts +220 -0
- package/src/lib/icon-registry.generated.ts +4 -0
- package/src/lib/icons.ts +29 -0
- package/src/lib/inline-markdown.tsx +86 -0
- package/src/lib/mdast.ts +56 -0
- package/src/lib/paths.ts +86 -0
- package/src/lib/remark-toc.ts +71 -0
- package/src/lib/search/config.ts +43 -0
- package/src/lib/search/provider.ts +80 -0
- package/src/lib/search/providers/local.ts +15 -0
- package/src/lib/search-index.generated.ts +4 -0
- package/src/lib/search.ts +100 -0
- package/src/lib/site-config.ts +104 -0
- package/src/lib/site-model.ts +221 -0
- package/src/lib/slug.ts +38 -0
- package/src/lib/types.ts +478 -0
- package/src/lib/utils.ts +6 -0
- package/src/pages/DocPage.tsx +33 -0
- package/src/styles/global.css +268 -0
- package/src/styles/tokens.css +114 -0
- package/types/client.d.ts +3 -0
- package/types/search.d.ts +17 -0
- package/vite.config.ts +342 -0
- package/LICENSE +0 -21
- package/dist/index.css +0 -189
- package/dist/index.d.ts +0 -57
- package/dist/index.js +0 -464
- package/dist/index.mjs +0 -437
- package/server/index.d.ts +0 -30
- package/server/index.js +0 -189
- package/styles.css +0 -4766
package/src/lib/types.ts
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
/* ---------------------------------------------------------------------------
|
|
2
|
+
* Raw docs.json shapes
|
|
3
|
+
* ------------------------------------------------------------------------- */
|
|
4
|
+
|
|
5
|
+
export interface PageObjectItem {
|
|
6
|
+
page: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
tag?: string;
|
|
11
|
+
hidden?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** An external link in the navigation tree. `anchor` is an alias for the label. */
|
|
15
|
+
export interface LinkItem {
|
|
16
|
+
href: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
anchor?: string;
|
|
19
|
+
icon?: string;
|
|
20
|
+
hidden?: boolean;
|
|
21
|
+
target?: LinkTarget;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type PageItem = string | GroupItem | PageObjectItem | LinkItem;
|
|
25
|
+
|
|
26
|
+
export interface GroupItem {
|
|
27
|
+
group: string;
|
|
28
|
+
root?: string;
|
|
29
|
+
pages: PageItem[];
|
|
30
|
+
icon?: string;
|
|
31
|
+
expanded?: boolean;
|
|
32
|
+
collapsible?: boolean;
|
|
33
|
+
hidden?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface DropdownItem {
|
|
37
|
+
dropdown: string;
|
|
38
|
+
groups?: GroupItem[];
|
|
39
|
+
pages?: PageItem[];
|
|
40
|
+
icon?: string;
|
|
41
|
+
hidden?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TabItem {
|
|
45
|
+
tab: string;
|
|
46
|
+
groups?: GroupItem[];
|
|
47
|
+
pages?: PageItem[];
|
|
48
|
+
dropdowns?: DropdownItem[];
|
|
49
|
+
icon?: string;
|
|
50
|
+
hidden?: boolean;
|
|
51
|
+
/** Internal normalized presentation; not a docs.json field. */
|
|
52
|
+
presentation?: 'tab' | 'dropdown';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface AnchorItem {
|
|
56
|
+
anchor: string;
|
|
57
|
+
href?: string;
|
|
58
|
+
icon?: string;
|
|
59
|
+
hidden?: boolean;
|
|
60
|
+
target?: LinkTarget;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface VersionItem {
|
|
64
|
+
version: string;
|
|
65
|
+
default?: boolean;
|
|
66
|
+
hidden?: boolean;
|
|
67
|
+
tabs?: TabItem[];
|
|
68
|
+
dropdowns?: DropdownItem[];
|
|
69
|
+
groups?: GroupItem[];
|
|
70
|
+
pages?: PageItem[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface LanguageItem {
|
|
74
|
+
language: string;
|
|
75
|
+
default?: boolean;
|
|
76
|
+
hidden?: boolean;
|
|
77
|
+
versions?: VersionItem[];
|
|
78
|
+
tabs?: TabItem[];
|
|
79
|
+
dropdowns?: DropdownItem[];
|
|
80
|
+
groups?: GroupItem[];
|
|
81
|
+
pages?: PageItem[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface NavigationConfig {
|
|
85
|
+
tabs?: TabItem[];
|
|
86
|
+
dropdowns?: DropdownItem[];
|
|
87
|
+
anchors?: AnchorItem[];
|
|
88
|
+
versions?: VersionItem[];
|
|
89
|
+
languages?: LanguageItem[];
|
|
90
|
+
groups?: GroupItem[];
|
|
91
|
+
pages?: PageItem[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ThemeColors {
|
|
95
|
+
primary?: string;
|
|
96
|
+
light?: string;
|
|
97
|
+
dark?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type LogoOption =
|
|
101
|
+
| string
|
|
102
|
+
| { light?: string; dark?: string; href?: string; target?: LinkTarget };
|
|
103
|
+
|
|
104
|
+
/** Shiso-only configuration. Namespaced so docs.json stays portable. */
|
|
105
|
+
export interface ShisoOptions {
|
|
106
|
+
/** Where docs pages are mounted within the site. Default "/docs"; "" for root. */
|
|
107
|
+
docsPrefix?: string;
|
|
108
|
+
/** Content directory relative to the project root. Default "content/docs". */
|
|
109
|
+
contentDir?: string;
|
|
110
|
+
/** Absolute site origin, required for canonical and og:url tags. */
|
|
111
|
+
siteUrl?: string;
|
|
112
|
+
/** Locale used for deterministic date formatting. */
|
|
113
|
+
locale?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type LinkTarget = '_self' | '_blank';
|
|
117
|
+
|
|
118
|
+
/** A user-configured link. Presentation is determined entirely by its fields. */
|
|
119
|
+
export interface ConfigLink {
|
|
120
|
+
/** Visible link text. Omit for an icon-only link. */
|
|
121
|
+
label?: string;
|
|
122
|
+
href: string;
|
|
123
|
+
icon?: string;
|
|
124
|
+
/** Accessible text for an icon-only link. */
|
|
125
|
+
ariaLabel?: string;
|
|
126
|
+
/** Override whether the link opens in the current or a new browsing context. */
|
|
127
|
+
target?: LinkTarget;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export type NavbarLink = ConfigLink;
|
|
131
|
+
|
|
132
|
+
export type NavbarPrimary = ConfigLink;
|
|
133
|
+
|
|
134
|
+
export interface NavbarConfig {
|
|
135
|
+
links?: NavbarLink[];
|
|
136
|
+
primary?: NavbarPrimary;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface FooterLinkItem {
|
|
140
|
+
label: string;
|
|
141
|
+
href: string;
|
|
142
|
+
target?: LinkTarget;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface FooterLinkColumn {
|
|
146
|
+
header?: string;
|
|
147
|
+
items: FooterLinkItem[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface FooterConfig {
|
|
151
|
+
socials?: ConfigLink[];
|
|
152
|
+
links?: FooterLinkColumn[];
|
|
153
|
+
/** Show the theme-provided Shiso attribution. Defaults to true. */
|
|
154
|
+
attribution?: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface BannerConfig {
|
|
158
|
+
/** Supports basic markdown: links, bold, italic, and inline code. */
|
|
159
|
+
content: string;
|
|
160
|
+
dismissible?: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** A redirect for a moved or renamed page. Sources are matched exactly. */
|
|
164
|
+
export interface RedirectRule {
|
|
165
|
+
source: string;
|
|
166
|
+
destination: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface SeoConfig {
|
|
170
|
+
/** Extra meta tags added to every page, e.g. { "og:image": "/social.png" }. */
|
|
171
|
+
metatags?: Record<string, string>;
|
|
172
|
+
/** "navigable" (default) keeps hidden pages out of the index; "all" indexes everything. */
|
|
173
|
+
indexing?: 'navigable' | 'all';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface Error404Config {
|
|
177
|
+
/** Navigate to the docs home instead of showing the 404 page. Defaults to true. */
|
|
178
|
+
redirect?: boolean;
|
|
179
|
+
title?: string;
|
|
180
|
+
/** Supports basic markdown: links, bold, italic, and inline code. */
|
|
181
|
+
description?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface ErrorsConfig {
|
|
185
|
+
'404'?: Error404Config;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface MetadataConfig {
|
|
189
|
+
/** Show the last-modified date on all pages. Overridable per page via `timestamp` frontmatter. */
|
|
190
|
+
timestamp?: boolean;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface AppearanceConfig {
|
|
194
|
+
/** Initial theme mode. "system" follows the OS preference. */
|
|
195
|
+
default?: 'system' | 'light' | 'dark';
|
|
196
|
+
/** Hide the light/dark toggle and ignore stored preferences. */
|
|
197
|
+
strict?: boolean;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface StylingConfig {
|
|
201
|
+
/** Page eyebrow style: the section name (default) or the full breadcrumb path. */
|
|
202
|
+
eyebrows?: 'section' | 'breadcrumbs';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface FontSpec {
|
|
206
|
+
/** Font family name. Google Fonts families load automatically without a source. */
|
|
207
|
+
family: string;
|
|
208
|
+
weight?: number;
|
|
209
|
+
/** URL or path to a hosted font file, for non-Google fonts. */
|
|
210
|
+
source?: string;
|
|
211
|
+
format?: 'woff' | 'woff2';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface FontsConfig extends FontSpec {
|
|
215
|
+
heading?: FontSpec;
|
|
216
|
+
body?: FontSpec;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface SearchConfig {
|
|
220
|
+
/** Placeholder text for the search input. */
|
|
221
|
+
prompt?: string;
|
|
222
|
+
/** Registered provider id. Defaults to the built-in local provider. */
|
|
223
|
+
provider?: string;
|
|
224
|
+
/** Provider-specific configuration. */
|
|
225
|
+
options?: Record<string, unknown>;
|
|
226
|
+
/** Cmd/Ctrl shortcut key. Set false to disable the shortcut. Defaults to "k". */
|
|
227
|
+
shortcut?: string | false;
|
|
228
|
+
/** Text shown for the shortcut. The theme supplies a platform-neutral default. */
|
|
229
|
+
shortcutLabel?: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface InteractionConfig {
|
|
233
|
+
/**
|
|
234
|
+
* Collapsible-group click behavior: true navigates to the group's first
|
|
235
|
+
* page on expand, false only expands/collapses. Unset uses the default
|
|
236
|
+
* (navigate when the group has a root page, toggle otherwise).
|
|
237
|
+
*/
|
|
238
|
+
drilldown?: boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* A custom contextual menu entry. `href` may contain `$path` (replaced with
|
|
243
|
+
* the current page path) and `$page` (replaced with the page's markdown URL).
|
|
244
|
+
*/
|
|
245
|
+
export interface ContextualOptionObject {
|
|
246
|
+
title: string;
|
|
247
|
+
description?: string;
|
|
248
|
+
icon?: string;
|
|
249
|
+
href: string;
|
|
250
|
+
target?: LinkTarget;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export type ContextualOption =
|
|
254
|
+
| 'copy'
|
|
255
|
+
| 'view'
|
|
256
|
+
| 'chatgpt'
|
|
257
|
+
| 'claude'
|
|
258
|
+
| 'perplexity'
|
|
259
|
+
| ContextualOptionObject;
|
|
260
|
+
|
|
261
|
+
export interface ContextualConfig {
|
|
262
|
+
options: ContextualOption[];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface BackgroundConfig {
|
|
266
|
+
/** Background image, single or per-mode. */
|
|
267
|
+
image?: string | { light?: string; dark?: string };
|
|
268
|
+
/** Background color per mode. */
|
|
269
|
+
color?: { light?: string; dark?: string };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface DocsConfig {
|
|
273
|
+
$schema?: string;
|
|
274
|
+
$shiso?: ShisoOptions;
|
|
275
|
+
theme?: string;
|
|
276
|
+
name?: string;
|
|
277
|
+
colors?: ThemeColors;
|
|
278
|
+
logo?: LogoOption;
|
|
279
|
+
favicon?: string;
|
|
280
|
+
description?: string;
|
|
281
|
+
navigation: NavigationConfig;
|
|
282
|
+
navbar?: NavbarConfig;
|
|
283
|
+
footer?: FooterConfig;
|
|
284
|
+
banner?: BannerConfig;
|
|
285
|
+
redirects?: RedirectRule[];
|
|
286
|
+
seo?: SeoConfig;
|
|
287
|
+
errors?: ErrorsConfig;
|
|
288
|
+
metadata?: MetadataConfig;
|
|
289
|
+
appearance?: AppearanceConfig;
|
|
290
|
+
styling?: StylingConfig;
|
|
291
|
+
fonts?: FontsConfig;
|
|
292
|
+
background?: BackgroundConfig;
|
|
293
|
+
/** Search settings. Set to false to hide search and skip index generation. */
|
|
294
|
+
search?: false | SearchConfig;
|
|
295
|
+
interaction?: InteractionConfig;
|
|
296
|
+
contextual?: ContextualConfig;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* ---------------------------------------------------------------------------
|
|
300
|
+
* Normalized shapes
|
|
301
|
+
* ------------------------------------------------------------------------- */
|
|
302
|
+
|
|
303
|
+
export interface DocsTab {
|
|
304
|
+
id: string;
|
|
305
|
+
label: string;
|
|
306
|
+
url: string;
|
|
307
|
+
icon?: string;
|
|
308
|
+
presentation: 'tab' | 'dropdown';
|
|
309
|
+
hidden?: boolean;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface NormalizedDocsPage {
|
|
313
|
+
slug: string;
|
|
314
|
+
fileSlug: string;
|
|
315
|
+
label: string;
|
|
316
|
+
url: string;
|
|
317
|
+
section: string;
|
|
318
|
+
tabId: string;
|
|
319
|
+
tabLabel: string;
|
|
320
|
+
order: number;
|
|
321
|
+
/**
|
|
322
|
+
* Hidden pages are still routed and prerendered, so they remain reachable by
|
|
323
|
+
* URL, but are excluded from the sidebar, prev/next, the
|
|
324
|
+
* sitemap, and search.
|
|
325
|
+
*/
|
|
326
|
+
hidden?: boolean;
|
|
327
|
+
icon?: string;
|
|
328
|
+
tag?: string;
|
|
329
|
+
/** Module key of the MDX file, e.g. "/content/docs/installation.mdx". */
|
|
330
|
+
filePath: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** A routed docs page in the navigation tree. */
|
|
334
|
+
export interface NavPageNode {
|
|
335
|
+
kind: 'page';
|
|
336
|
+
page: NormalizedDocsPage;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** An external link. Never routed, never in prev/next, never indexed. */
|
|
340
|
+
export interface NavLinkNode {
|
|
341
|
+
kind: 'link';
|
|
342
|
+
label: string;
|
|
343
|
+
href: string;
|
|
344
|
+
icon?: string;
|
|
345
|
+
hidden?: boolean;
|
|
346
|
+
target: LinkTarget;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** A titled, arbitrarily nestable group of nodes. */
|
|
350
|
+
export interface NavGroupNode {
|
|
351
|
+
kind: 'group';
|
|
352
|
+
label: string;
|
|
353
|
+
/** Optional landing page for the group itself. */
|
|
354
|
+
root?: NavPageNode;
|
|
355
|
+
children: NavNode[];
|
|
356
|
+
icon?: string;
|
|
357
|
+
expanded?: boolean;
|
|
358
|
+
collapsible?: boolean;
|
|
359
|
+
hidden?: boolean;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export type NavNode = NavPageNode | NavLinkNode | NavGroupNode;
|
|
363
|
+
|
|
364
|
+
export interface NormalizedDocsConfig {
|
|
365
|
+
name?: string;
|
|
366
|
+
tabs: DocsTab[];
|
|
367
|
+
/** Whether the source config explicitly defines top-level tabs/dropdowns. */
|
|
368
|
+
showTabs: boolean;
|
|
369
|
+
/** Navigation tree per tab id. */
|
|
370
|
+
navigation: Record<string, NavNode[]>;
|
|
371
|
+
/** Top-level anchors, rendered above the sidebar. */
|
|
372
|
+
anchors: NavLinkNode[];
|
|
373
|
+
/** All routed pages in document order, including hidden ones. */
|
|
374
|
+
pages: NormalizedDocsPage[];
|
|
375
|
+
pageBySlug: Record<string, NormalizedDocsPage>;
|
|
376
|
+
pageByLookupSlug: Record<string, NormalizedDocsPage>;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface NormalizeOptions {
|
|
380
|
+
/** Route prefix for docs pages. Phases 6/7 pass "/v2/docs", "/es/docs", etc. */
|
|
381
|
+
docsPrefix?: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface NormalizedLink extends ConfigLink {
|
|
385
|
+
target: LinkTarget;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface NormalizedNavbar {
|
|
389
|
+
links: NormalizedLink[];
|
|
390
|
+
primary?: NormalizedLink;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export interface NormalizedFooter {
|
|
394
|
+
socials: NormalizedLink[];
|
|
395
|
+
links: FooterLinkColumn[];
|
|
396
|
+
attribution: boolean;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface ThemeLabels {
|
|
400
|
+
menu: string;
|
|
401
|
+
documentationNavigation: string;
|
|
402
|
+
sections: string;
|
|
403
|
+
tableOfContents: string;
|
|
404
|
+
tableOfContentsNavigation: string;
|
|
405
|
+
searchTitle: string;
|
|
406
|
+
searching: string;
|
|
407
|
+
searchUnavailable: string;
|
|
408
|
+
noResults: string;
|
|
409
|
+
lastUpdated: string;
|
|
410
|
+
notFound: string;
|
|
411
|
+
dismissBanner: string;
|
|
412
|
+
toggleTheme: string;
|
|
413
|
+
moreOptions: string;
|
|
414
|
+
copied: string;
|
|
415
|
+
expand: string;
|
|
416
|
+
collapse: string;
|
|
417
|
+
copyPage: string;
|
|
418
|
+
copyPageDescription: string;
|
|
419
|
+
viewMarkdown: string;
|
|
420
|
+
viewMarkdownDescription: string;
|
|
421
|
+
openInChatGPT: string;
|
|
422
|
+
openInClaude: string;
|
|
423
|
+
openInPerplexity: string;
|
|
424
|
+
askQuestionsAboutPage: string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export interface SiteModel {
|
|
428
|
+
name?: string;
|
|
429
|
+
logo: { light?: string; dark?: string; href?: string; target?: LinkTarget } | null;
|
|
430
|
+
navbar: NormalizedNavbar | null;
|
|
431
|
+
footer: NormalizedFooter | null;
|
|
432
|
+
banner: BannerConfig | null;
|
|
433
|
+
appearance: Required<AppearanceConfig>;
|
|
434
|
+
styling: Required<Pick<StylingConfig, 'eyebrows'>>;
|
|
435
|
+
search: import('@/lib/search/config').ResolvedSearchConfig;
|
|
436
|
+
contextualOptions: ContextualOption[];
|
|
437
|
+
error404: Required<Pick<Error404Config, 'redirect'>> & Error404Config;
|
|
438
|
+
showTimestamp: boolean;
|
|
439
|
+
drilldown?: boolean;
|
|
440
|
+
locale: string;
|
|
441
|
+
labels: ThemeLabels;
|
|
442
|
+
docs: NormalizedDocsConfig;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface ResolvedContextualOption {
|
|
446
|
+
key: string;
|
|
447
|
+
title: string;
|
|
448
|
+
description?: string;
|
|
449
|
+
icon?: string;
|
|
450
|
+
action: 'copy' | 'link';
|
|
451
|
+
href: string;
|
|
452
|
+
target: LinkTarget;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/* ---------------------------------------------------------------------------
|
|
456
|
+
* Content
|
|
457
|
+
* ------------------------------------------------------------------------- */
|
|
458
|
+
|
|
459
|
+
export interface TocEntry {
|
|
460
|
+
name: string;
|
|
461
|
+
id: string;
|
|
462
|
+
size: number;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export interface DocFrontmatter {
|
|
466
|
+
title?: string;
|
|
467
|
+
description?: string;
|
|
468
|
+
noindex?: boolean;
|
|
469
|
+
/** Overrides the site-wide `metadata.timestamp` setting for this page. */
|
|
470
|
+
timestamp?: boolean;
|
|
471
|
+
[key: string]: unknown;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export interface DocModule {
|
|
475
|
+
default: (props: { components?: Record<string, unknown> }) => React.ReactElement;
|
|
476
|
+
frontmatter?: DocFrontmatter;
|
|
477
|
+
toc?: TocEntry[];
|
|
478
|
+
}
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { Navigate, useLocation } from 'react-router';
|
|
3
|
+
import { Docs } from '@/components/Docs';
|
|
4
|
+
import { getDocModule } from '@/lib/content';
|
|
5
|
+
import { useHead } from '@/lib/head';
|
|
6
|
+
import { isExternalHref } from '@/lib/paths';
|
|
7
|
+
import { getPageByPathname, matchRedirect } from '@/lib/site-config';
|
|
8
|
+
import type { SiteModel } from '@/lib/types';
|
|
9
|
+
|
|
10
|
+
export function DocPage({ site }: { site: SiteModel }) {
|
|
11
|
+
// pathname is base-relative: the router's basename already stripped BASE_URL.
|
|
12
|
+
const { pathname } = useLocation();
|
|
13
|
+
const page = getPageByPathname(pathname);
|
|
14
|
+
const doc = page ? getDocModule(page.filePath) : undefined;
|
|
15
|
+
// Real pages win over redirect rules; rules only apply to paths that
|
|
16
|
+
// would otherwise 404.
|
|
17
|
+
const redirect = page && doc ? null : matchRedirect(pathname);
|
|
18
|
+
const externalRedirect = redirect && isExternalHref(redirect) ? redirect : null;
|
|
19
|
+
|
|
20
|
+
useHead(pathname);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (externalRedirect) {
|
|
24
|
+
window.location.replace(externalRedirect);
|
|
25
|
+
}
|
|
26
|
+
}, [externalRedirect]);
|
|
27
|
+
|
|
28
|
+
if (redirect) {
|
|
29
|
+
return externalRedirect ? null : <Navigate to={redirect} replace />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return <Docs page={page} doc={doc || null} site={site} />;
|
|
33
|
+
}
|