config.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { createRequire } from 'module'
  2. import { defineAdditionalConfig, type DefaultTheme } from 'vitepress'
  3. const require = createRequire(import.meta.url)
  4. const pkg = require('vitepress/package.json')
  5. export default defineAdditionalConfig({
  6. lang: 'en-US',
  7. description: 'Vite & Vue powered static site generator.',
  8. themeConfig: {
  9. nav: nav(),
  10. sidebar: {
  11. '/guide/': { base: '/guide/', items: sidebarGuide() },
  12. '/reference/': { base: '/reference/', items: sidebarReference() }
  13. },
  14. editLink: {
  15. pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path',
  16. text: 'Edit this page on GitHub'
  17. },
  18. footer: {
  19. message: 'Released under the MIT License.',
  20. copyright: 'Copyright © 2019-present Evan You'
  21. }
  22. }
  23. })
  24. function nav(): DefaultTheme.NavItem[] {
  25. return [
  26. {
  27. text: 'Guide',
  28. link: '/guide/what-is-vitepress',
  29. activeMatch: '/guide/'
  30. },
  31. {
  32. text: 'Reference',
  33. link: '/reference/site-config',
  34. activeMatch: '/reference/'
  35. },
  36. {
  37. text: pkg.version,
  38. items: [
  39. {
  40. text: 'Changelog',
  41. link: 'https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md'
  42. },
  43. {
  44. text: 'Contributing',
  45. link: 'https://github.com/vuejs/vitepress/blob/main/.github/contributing.md'
  46. }
  47. ]
  48. }
  49. ]
  50. }
  51. function sidebarGuide(): DefaultTheme.SidebarItem[] {
  52. return [
  53. {
  54. text: 'Introduction',
  55. collapsed: false,
  56. items: [
  57. { text: 'What is VitePress?', link: 'what-is-vitepress' },
  58. { text: 'Getting Started', link: 'getting-started' },
  59. { text: 'Routing', link: 'routing' },
  60. { text: 'Deploy', link: 'deploy' }
  61. ]
  62. },
  63. {
  64. text: 'Writing',
  65. collapsed: false,
  66. items: [
  67. { text: 'Markdown Extensions', link: 'markdown' },
  68. { text: 'Asset Handling', link: 'asset-handling' },
  69. { text: 'Frontmatter', link: 'frontmatter' },
  70. { text: 'Using Vue in Markdown', link: 'using-vue' },
  71. { text: 'Internationalization', link: 'i18n' }
  72. ]
  73. },
  74. {
  75. text: 'Customization',
  76. collapsed: false,
  77. items: [
  78. { text: 'Using a Custom Theme', link: 'custom-theme' },
  79. {
  80. text: 'Extending the Default Theme',
  81. link: 'extending-default-theme'
  82. },
  83. { text: 'Build-Time Data Loading', link: 'data-loading' },
  84. { text: 'SSR Compatibility', link: 'ssr-compat' },
  85. { text: 'Connecting to a CMS', link: 'cms' }
  86. ]
  87. },
  88. {
  89. text: 'Experimental',
  90. collapsed: false,
  91. items: [
  92. { text: 'MPA Mode', link: 'mpa-mode' },
  93. { text: 'Sitemap Generation', link: 'sitemap-generation' }
  94. ]
  95. },
  96. { text: 'Config & API Reference', base: '/reference/', link: 'site-config' }
  97. ]
  98. }
  99. function sidebarReference(): DefaultTheme.SidebarItem[] {
  100. return [
  101. {
  102. text: 'Reference',
  103. items: [
  104. { text: 'Site Config', link: 'site-config' },
  105. { text: 'Frontmatter Config', link: 'frontmatter-config' },
  106. { text: 'Runtime API', link: 'runtime-api' },
  107. { text: 'CLI', link: 'cli' },
  108. {
  109. text: 'Default Theme',
  110. base: '/reference/default-theme-',
  111. items: [
  112. { text: 'Overview', link: 'config' },
  113. { text: 'Nav', link: 'nav' },
  114. { text: 'Sidebar', link: 'sidebar' },
  115. { text: 'Home Page', link: 'home-page' },
  116. { text: 'Footer', link: 'footer' },
  117. { text: 'Layout', link: 'layout' },
  118. { text: 'Badge', link: 'badge' },
  119. { text: 'Team Page', link: 'team-page' },
  120. { text: 'Prev / Next Links', link: 'prev-next-links' },
  121. { text: 'Edit Link', link: 'edit-link' },
  122. { text: 'Last Updated Timestamp', link: 'last-updated' },
  123. { text: 'Search', link: 'search' },
  124. { text: 'Carbon Ads', link: 'carbon-ads' }
  125. ]
  126. }
  127. ]
  128. }
  129. ]
  130. }