-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathdefault-theme.d.ts
511 lines (423 loc) · 11.6 KB
/
default-theme.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
import type { Options as _MiniSearchOptions } from 'minisearch'
import type { ComputedRef, Ref, ShallowRef } from 'vue'
import type { DocSearchProps } from './docsearch.js'
import type { LocalSearchTranslations } from './local-search.js'
import type { PageData } from './shared.js'
export namespace DefaultTheme {
export interface Config {
/**
* The logo file of the site.
*
* @example '/logo.svg'
*/
logo?: ThemeableImage
/**
* Overrides the link of the site logo.
*/
logoLink?: string | { link?: string; rel?: string; target?: string }
/**
* Custom site title in navbar. If the value is undefined,
* `config.title` will be used.
*/
siteTitle?: string | false
/**
* Custom header levels of outline in the aside component.
*
* @default 2
*/
outline?: Outline | Outline['level'] | false
/**
* @deprecated Use `outline.label` instead.
*
* @default 'On this page'
*/
outlineTitle?: string
/**
* The nav items.
*/
nav?: NavItem[]
/**
* The sidebar items.
*/
sidebar?: Sidebar
/**
* Set to `false` to prevent rendering of aside container.
* Set to `true` to render the aside to the right.
* Set to `left` to render the aside to the left.
*
* @default true
*/
aside?: boolean | 'left'
/**
* Info for the edit link. If it's undefined, the edit link feature will
* be disabled.
*/
editLink?: EditLink
/**
* @deprecated Use `lastUpdated.text` instead.
*
* Set custom last updated text.
*
* @default 'Last updated'
*/
lastUpdatedText?: string
lastUpdated?: LastUpdatedOptions
/**
* Set custom prev/next labels.
*/
docFooter?: DocFooter
/**
* The social links to be displayed at the end of the nav bar. Perfect for
* placing links to social services such as GitHub, Twitter, Facebook, etc.
*/
socialLinks?: SocialLink[]
/**
* The footer configuration.
*/
footer?: Footer
/**
* @default 'Appearance'
*/
darkModeSwitchLabel?: string
/**
* @default 'Switch to light theme'
*/
lightModeSwitchTitle?: string
/**
* @default 'Switch to dark theme'
*/
darkModeSwitchTitle?: string
/**
* @default 'Menu'
*/
sidebarMenuLabel?: string
/**
* @default 'Return to top'
*/
returnToTopLabel?: string
/**
* @default false
*
* Remove extraneous elements when printing, such as
* the sidebar, navbar, and footer. It can clean print pages, and focus on
* the main content.
*/
removeExtraElementsInPrint?: boolean
/**
* Set custom `aria-label` for language menu button.
*
* @default 'Change language'
*/
langMenuLabel?: string
/**
* @default 'Skip to content'
*/
skipToContentLabel?: string
search?:
| { provider: 'local'; options?: LocalSearchOptions }
| { provider: 'algolia'; options: AlgoliaSearchOptions }
/**
* @deprecated Use `search` instead.
*/
algolia?: AlgoliaSearchOptions
/**
* The carbon ads options. Leave it undefined to disable the ads feature.
*/
carbonAds?: CarbonAdsOptions
/**
* Changing locale when current url is `/foo` will redirect to `/locale/foo`.
*
* @default true
*/
i18nRouting?: boolean
/**
* Show external link icon in Markdown links.
*
* @default false
*/
externalLinkIcon?: boolean
/**
* Customize text of 404 page.
*/
notFound?: NotFoundOptions
}
// nav -----------------------------------------------------------------------
export type NavItem = NavItemComponent | NavItemWithLink | NavItemWithChildren
export interface NavItemComponent {
component: string
props?: Record<string, any>
}
export interface NavItemWithLink {
text: string
link: string
items?: never
/**
* `activeMatch` is expected to be a regex string. We can't use actual
* RegExp object here because it isn't serializable
*/
activeMatch?: string
rel?: string
target?: string
noIcon?: boolean
}
export interface NavItemChildren {
text?: string
items: NavItemWithLink[]
}
export interface NavItemWithChildren {
text?: string
items: (NavItemComponent | NavItemChildren | NavItemWithLink)[]
/**
* `activeMatch` is expected to be a regex string. We can't use actual
* RegExp object here because it isn't serializable
*/
activeMatch?: string
}
// image ---------------------------------------------------------------------
export type ThemeableImage =
| string
| { src: string; alt?: string; [prop: string]: any }
| { light: string; dark: string; alt?: string; [prop: string]: any }
export type FeatureIcon =
| string
| {
src: string
alt?: string
width?: string
height?: string
wrap?: boolean
}
| {
light: string
dark: string
alt?: string
width?: string
height?: string
wrap?: boolean
}
// sidebar -------------------------------------------------------------------
export type Sidebar = SidebarItem[] | SidebarMulti
export interface SidebarMulti {
[path: string]: SidebarItem[] | { items: SidebarItem[]; base: string }
}
export type SidebarItem = {
/**
* The text label of the item.
*/
text?: string
/**
* The link of the item.
*/
link?: string
/**
* The children of the item.
*/
items?: SidebarItem[]
/**
* If not specified, group is not collapsible.
*
* If `true`, group is collapsible and collapsed by default
*
* If `false`, group is collapsible but expanded by default
*/
collapsed?: boolean
/**
* Base path for the children items.
*/
base?: string
/**
* Customize text that appears on the footer of previous/next page.
*/
docFooterText?: string
rel?: string
target?: string
}
/**
* ReturnType of `useSidebar`
*/
export interface DocSidebar {
isOpen: Ref<boolean>
sidebar: ComputedRef<SidebarItem[]>
sidebarGroups: ComputedRef<SidebarItem[]>
hasSidebar: ComputedRef<boolean>
hasAside: ComputedRef<boolean>
leftAside: ComputedRef<boolean>
isSidebarEnabled: ComputedRef<boolean>
open: () => void
close: () => void
toggle: () => void
}
// edit link -----------------------------------------------------------------
export interface EditLink {
/**
* Pattern for edit link.
*
* @example 'https://github.com/vuejs/vitepress/edit/main/docs/:path'
* @example ({ filePath }) => { ... }
*/
pattern: string | ((payload: PageData) => string)
/**
* Custom text for edit link.
*
* @default 'Edit this page'
*/
text?: string
}
// prev-next -----------------------------------------------------------------
export interface DocFooter {
/**
* Custom label for previous page button. Can be set to `false` to disable.
*
* @default 'Previous page'
*/
prev?: string | boolean
/**
* Custom label for next page button. Can be set to `false` to disable.
*
* @default 'Next page'
*/
next?: string | boolean
}
// social link ---------------------------------------------------------------
export interface SocialLink {
icon: SocialLinkIcon
link: string
ariaLabel?: string
}
export type SocialLinkIcon = string | { svg: string }
// footer --------------------------------------------------------------------
export interface Footer {
message?: string
copyright?: string
}
// team ----------------------------------------------------------------------
export interface TeamMember {
avatar: string
name: string
title?: string
org?: string
orgLink?: string
desc?: string
links?: SocialLink[]
sponsor?: string
actionText?: string
}
// local nav -----------------------------------------------------------------
/**
* ReturnType of `useLocalNav`.
*/
export interface DocLocalNav {
/**
* The outline headers of the current page.
*/
headers: ShallowRef<any>
/**
* Whether the current page has a local nav. Local nav is shown when the
* "outline" is present in the page. However, note that the actual
* local nav visibility depends on the screen width as well.
*/
hasLocalNav: ComputedRef<boolean>
}
// outline -------------------------------------------------------------------
export interface Outline {
level?: number | [number, number] | 'deep'
label?: string
}
// local search --------------------------------------------------------------
export interface LocalSearchOptions {
/**
* @default false
* @deprecated Use `detailedView: false` instead.
*/
disableDetailedView?: boolean
/**
* If `true`, the detailed view will be enabled by default.
* If `false`, the detailed view will be disabled.
* If `'auto'`, the detailed view will be disabled by default, but can be enabled by the user.
*
* @default 'auto'
*/
detailedView?: boolean | 'auto'
/**
* @default false
*/
disableQueryPersistence?: boolean
translations?: LocalSearchTranslations
locales?: Record<string, Partial<Omit<LocalSearchOptions, 'locales'>>>
miniSearch?: MiniSearchOptions
}
interface MiniSearchOptions {
/**
* @see https://lucaong.github.io/minisearch/types/MiniSearch.Options.html
*/
options?: Pick<
_MiniSearchOptions,
'extractField' | 'tokenize' | 'processTerm'
>
/**
* @see https://lucaong.github.io/minisearch/types/MiniSearch.SearchOptions.html
*/
searchOptions?: _MiniSearchOptions['searchOptions']
}
// algolia -------------------------------------------------------------------
/**
* Algolia search options. Partially copied from
* `@docsearch/react/dist/esm/DocSearch.d.ts`
*/
export interface AlgoliaSearchOptions extends DocSearchProps {
locales?: Record<string, Partial<DocSearchProps>>
}
// carbon ads ----------------------------------------------------------------
export interface CarbonAdsOptions {
code: string
placement: string
}
// last updated --------------------------------------------------------------
export interface LastUpdatedOptions {
/**
* Set custom last updated text.
*
* @default 'Last updated'
*/
text?: string
/**
* Set options for last updated time formatting.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#using_options
*
* @default
* { dateStyle: 'short', timeStyle: 'short' }
*/
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
}
// not found -----------------------------------------------------------------
export interface NotFoundOptions {
/**
* Set custom not found message.
*
* @default 'PAGE NOT FOUND'
*/
title?: string
/**
* Set custom not found description.
*
* @default "But if you don't change your direction, and if you keep looking, you may end up where you are heading."
*/
quote?: string
/**
* Set aria label for home link.
*
* @default 'go to home'
*/
linkLabel?: string
/**
* Set custom home link text.
*
* @default 'Take me home'
*/
linkText?: string
/**
* @default '404'
*/
code?: string
}
}