config.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import { defineConfig, type DefaultTheme } from 'vitepress'
  2. const nav: DefaultTheme.Config['nav'] = [
  3. {
  4. text: 'Home',
  5. link: '/'
  6. },
  7. {
  8. text: 'API Reference',
  9. items: [
  10. {
  11. text: 'Example',
  12. link: '/home.html'
  13. },
  14. {
  15. component: 'ApiPreference',
  16. props: {
  17. options: ['JavaScript', 'TypeScript', 'Flow'],
  18. defaultOption: 'TypeScript'
  19. }
  20. },
  21. {
  22. component: 'ApiPreference',
  23. props: {
  24. options: ['Options', 'Composition'],
  25. defaultOption: 'Composition'
  26. }
  27. }
  28. ]
  29. },
  30. {
  31. component: 'NavVersion',
  32. props: {
  33. versions: [
  34. {
  35. text: 'v1.x',
  36. link: '/'
  37. },
  38. {
  39. text: 'v0.x',
  40. link: '/v0.x/'
  41. }
  42. ]
  43. }
  44. },
  45. {
  46. text: 'Nested',
  47. items: [
  48. {
  49. text: 'Level 1 - 1',
  50. items: [
  51. {
  52. text: 'Level 2 - 1',
  53. link: '/nested/level1-1/level2-1'
  54. }
  55. ]
  56. },
  57. {
  58. text: 'Level 1 - 2',
  59. items: [
  60. {
  61. text: 'Level 2 - 2',
  62. link: '/nested/level1-2/level2-2'
  63. }
  64. ]
  65. }
  66. ]
  67. }
  68. ]
  69. const sidebar: DefaultTheme.Config['sidebar'] = {
  70. '/': [
  71. {
  72. text: 'Frontmatter',
  73. collapsed: false,
  74. items: [
  75. {
  76. text: 'Multiple Levels Outline',
  77. link: '/frontmatter/multiple-levels-outline'
  78. }
  79. ]
  80. },
  81. {
  82. text: '& &#60;Text Literals &> <code>code</code>',
  83. items: [
  84. {
  85. text: '& &#60;Test Page &> <code>code</code>',
  86. link: '/text-literals/'
  87. }
  88. ]
  89. },
  90. {
  91. text: 'Data Loading',
  92. items: [
  93. {
  94. text: 'Test Page',
  95. link: '/data-loading/data'
  96. }
  97. ]
  98. },
  99. {
  100. text: 'Multi Sidebar Test',
  101. items: [
  102. {
  103. text: 'Test Page',
  104. link: '/multi-sidebar/'
  105. }
  106. ]
  107. },
  108. {
  109. text: 'Dynamic Routes',
  110. items: [
  111. {
  112. text: 'Foo',
  113. link: '/dynamic-routes/foo'
  114. },
  115. {
  116. text: 'Bar',
  117. link: '/dynamic-routes/bar'
  118. }
  119. ]
  120. },
  121. {
  122. text: 'Markdown Extensions',
  123. items: [
  124. {
  125. text: 'Test Page',
  126. link: '/markdown-extensions/'
  127. },
  128. {
  129. text: 'Foo',
  130. link: '/markdown-extensions/foo'
  131. }
  132. ]
  133. }
  134. ],
  135. '/multi-sidebar/': [
  136. {
  137. text: 'Multi Sidebar',
  138. items: [
  139. {
  140. text: 'Test Page',
  141. link: '/multi-sidebar/'
  142. },
  143. {
  144. text: 'Back',
  145. link: '/'
  146. }
  147. ]
  148. }
  149. ]
  150. }
  151. export default defineConfig({
  152. title: 'Example',
  153. description: 'An example app using VitePress.',
  154. markdown: {
  155. image: {
  156. lazyLoading: true
  157. }
  158. },
  159. themeConfig: {
  160. nav,
  161. sidebar,
  162. search: {
  163. provider: 'local',
  164. options: {
  165. async _render(src, env, md) {
  166. const html = await md.renderAsync(src, env)
  167. if (env.frontmatter?.search === false) return ''
  168. if (env.relativePath.startsWith('local-search/excluded')) return ''
  169. return html
  170. }
  171. }
  172. }
  173. },
  174. vite: {
  175. server: {
  176. watch: {
  177. usePolling: true,
  178. interval: 100
  179. }
  180. }
  181. }
  182. })