index.d.ts 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. import { AliasOptions } from 'vite';
  2. import anchor from 'markdown-it-anchor';
  3. import { BuildOptions } from 'vite';
  4. import MarkdownIt from 'markdown-it';
  5. import { Options } from '@vitejs/plugin-vue';
  6. import { ServerOptions } from 'vite';
  7. import { UserConfig as UserConfig_2 } from 'vite';
  8. import { ViteDevServer } from 'vite';
  9. export declare function build(root: string, buildOptions?: BuildOptions & {
  10. mpa?: string;
  11. }): Promise<void>;
  12. export declare const createMarkdownRenderer: (srcDir: string, options: MarkdownOptions | undefined, base: string) => MarkdownRenderer;
  13. export declare function createServer(root?: string, serverOptions?: ServerOptions): Promise<ViteDevServer>;
  14. export declare namespace DefaultTheme {
  15. export interface Config {
  16. logo?: string
  17. nav?: NavItem[] | false
  18. sidebar?: SideBarConfig | MultiSideBarConfig
  19. /**
  20. * GitHub repository following the format <user>/<project>.
  21. *
  22. * @example `"vuejs/vue-next"`
  23. */
  24. repo?: string
  25. /**
  26. * Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
  27. * depending on the provided repo.
  28. *
  29. * @example `"Contribute!"`
  30. */
  31. repoLabel?: string
  32. /**
  33. * If your docs are in a different repository from your main project.
  34. *
  35. * @example `"vuejs/docs-next"`
  36. */
  37. docsRepo?: string
  38. /**
  39. * If your docs are not at the root of the repo.
  40. *
  41. * @example `"docs"`
  42. */
  43. docsDir?: string
  44. /**
  45. * If your docs are in a different branch. Defaults to `master`.
  46. *
  47. * @example `"next"`
  48. */
  49. docsBranch?: string
  50. /**
  51. * Enable links to edit pages at the bottom of the page.
  52. */
  53. editLinks?: boolean
  54. /**
  55. * Custom text for edit link. Defaults to "Edit this page".
  56. */
  57. editLinkText?: string
  58. /**
  59. * Show last updated time at the bottom of the page. Defaults to `false`.
  60. * If given a string, it will be displayed as a prefix (default value:
  61. * "Last Updated").
  62. */
  63. lastUpdated?: string | boolean
  64. prevLinks?: boolean
  65. nextLinks?: boolean
  66. locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
  67. algolia?: AlgoliaSearchOptions
  68. carbonAds?: {
  69. carbon: string
  70. custom?: string
  71. placement: string
  72. }
  73. }
  74. // navbar --------------------------------------------------------------------
  75. export type NavItem = NavItemWithLink | NavItemWithChildren
  76. export interface NavItemBase {
  77. text: string
  78. target?: string
  79. rel?: string
  80. ariaLabel?: string
  81. activeMatch?: string
  82. }
  83. export interface NavItemWithLink extends NavItemBase {
  84. link: string
  85. }
  86. export interface NavItemWithChildren extends NavItemBase {
  87. items: NavItemWithLink[]
  88. }
  89. // sidebar -------------------------------------------------------------------
  90. export type SideBarConfig = SideBarItem[] | 'auto' | false
  91. export interface MultiSideBarConfig {
  92. [path: string]: SideBarConfig
  93. }
  94. export type SideBarItem = SideBarLink | SideBarGroup
  95. export interface SideBarLink {
  96. text: string
  97. link: string
  98. }
  99. export interface SideBarGroup {
  100. text: string
  101. link?: string
  102. /**
  103. * @default false
  104. */
  105. collapsable?: boolean
  106. children: SideBarItem[]
  107. }
  108. // algolia ------------------------------------------------------------------
  109. // partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
  110. export interface AlgoliaSearchOptions {
  111. appId: string
  112. apiKey: string
  113. indexName: string
  114. placeholder?: string
  115. searchParameters?: any
  116. disableUserPersonalization?: boolean
  117. initialQuery?: string
  118. }
  119. // locales -------------------------------------------------------------------
  120. export interface LocaleConfig {
  121. /**
  122. * Text for the language dropdown.
  123. */
  124. selectText?: string
  125. /**
  126. * Label for this locale in the language dropdown.
  127. */
  128. label?: string
  129. }
  130. }
  131. /**
  132. * Type config helper
  133. */
  134. export declare function defineConfig(config: UserConfig<DefaultTheme.Config>): UserConfig<DefaultTheme.Config>;
  135. /**
  136. * Type config helper for custom theme config
  137. */
  138. export declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): UserConfig<ThemeConfig>;
  139. export declare type HeadConfig =
  140. | [string, Record<string, string>]
  141. | [string, Record<string, string>, string]
  142. export declare interface Header {
  143. level: number
  144. title: string
  145. slug: string
  146. }
  147. export declare interface LocaleConfig {
  148. lang: string
  149. title?: string
  150. description?: string
  151. head?: HeadConfig[]
  152. label?: string
  153. selectText?: string
  154. }
  155. export declare interface MarkdownOptions extends MarkdownIt.Options {
  156. lineNumbers?: boolean;
  157. config?: (md: MarkdownIt) => void;
  158. anchor?: {
  159. permalink?: anchor.AnchorOptions['permalink'];
  160. };
  161. attrs?: {
  162. leftDelimiter?: string;
  163. rightDelimiter?: string;
  164. allowedAttributes?: string[];
  165. };
  166. toc?: any;
  167. externalLinks?: Record<string, string>;
  168. }
  169. export declare interface MarkdownParsedData {
  170. hoistedTags?: string[];
  171. links?: string[];
  172. headers?: Header[];
  173. }
  174. export declare interface MarkdownRenderer extends MarkdownIt {
  175. __path: string;
  176. __relativePath: string;
  177. __data: MarkdownParsedData;
  178. }
  179. export declare type RawConfigExports<ThemeConfig = any> = UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>> | (() => UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>>);
  180. export declare function resolveConfig(root?: string, command?: 'serve' | 'build', mode?: string): Promise<SiteConfig>;
  181. export declare function resolveSiteData(root: string, userConfig?: UserConfig, command?: 'serve' | 'build', mode?: string): Promise<SiteData>;
  182. export declare function resolveSiteDataByRoute(siteData: SiteData, route: string): SiteData;
  183. export declare function serve(options?: ServeOptions): Promise<void>;
  184. export declare interface ServeOptions {
  185. root?: string;
  186. port?: number;
  187. }
  188. export declare interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'lastUpdated'> {
  189. root: string;
  190. srcDir: string;
  191. site: SiteData<ThemeConfig>;
  192. configPath: string | undefined;
  193. themeDir: string;
  194. outDir: string;
  195. tempDir: string;
  196. alias: AliasOptions;
  197. pages: string[];
  198. }
  199. export declare interface SiteData<ThemeConfig = any> {
  200. base: string
  201. /**
  202. * Language of the site as it should be set on the `html` element.
  203. * @example `en-US`, `zh-CN`
  204. */
  205. lang: string
  206. title: string
  207. description: string
  208. head: HeadConfig[]
  209. themeConfig: ThemeConfig
  210. scrollOffset: number | string
  211. locales: Record<string, LocaleConfig>
  212. /**
  213. * Available locales for the site when it has defined `locales` in its
  214. * `themeConfig`. This object is otherwise empty. Keys are paths like `/` or
  215. * `/zh/`.
  216. */
  217. langs: Record<
  218. string,
  219. {
  220. /**
  221. * Lang attribute as set on the `<html>` element.
  222. * @example `en-US`, `zh-CN`
  223. */
  224. lang: string
  225. /**
  226. * Label to display in the language menu.
  227. * @example `English`, `简体中文`
  228. */
  229. label: string
  230. }
  231. >
  232. }
  233. export declare interface UserConfig<ThemeConfig = any> {
  234. extends?: RawConfigExports<ThemeConfig>;
  235. lang?: string;
  236. base?: string;
  237. title?: string;
  238. description?: string;
  239. head?: HeadConfig[];
  240. themeConfig?: ThemeConfig;
  241. locales?: Record<string, LocaleConfig>;
  242. markdown?: MarkdownOptions;
  243. lastUpdated?: boolean;
  244. /**
  245. * Options to pass on to `@vitejs/plugin-vue`
  246. */
  247. vue?: Options;
  248. /**
  249. * Vite config
  250. */
  251. vite?: UserConfig_2;
  252. srcDir?: string;
  253. srcExclude?: string[];
  254. outDir?: string;
  255. shouldPreload?: (link: string, page: string) => boolean;
  256. /**
  257. * Configure the scroll offset when the theme has a sticky header.
  258. * Can be a number or a selector element to get the offset from.
  259. */
  260. scrollOffset?: number | string;
  261. /**
  262. * Enable MPA / zero-JS mode
  263. * @experimental
  264. */
  265. mpa?: boolean;
  266. }
  267. export { }