default-theme.d.ts 11 KB

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