index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const path = require('path')
  2. // Theme API.
  3. module.exports = (options, ctx) => {
  4. const { themeConfig, siteConfig } = ctx
  5. // resolve algolia
  6. const isAlgoliaSearch = (
  7. themeConfig.algolia
  8. || Object
  9. .keys(siteConfig.locales && themeConfig.locales || {})
  10. .some(base => themeConfig.locales[base].algolia)
  11. )
  12. const enableSmoothScroll = themeConfig.smoothScroll === true
  13. return {
  14. alias () {
  15. return {
  16. '@AlgoliaSearchBox': isAlgoliaSearch
  17. ? path.resolve(__dirname, 'components/AlgoliaSearchBox.vue')
  18. : path.resolve(__dirname, 'noopModule.js')
  19. }
  20. },
  21. plugins: [
  22. ['@vuepress/active-header-links', options.activeHeaderLinks],
  23. '@vuepress/search',
  24. '@vuepress/plugin-nprogress',
  25. ['container', {
  26. type: 'tip',
  27. defaultTitle: {
  28. '/': 'TIP',
  29. '/zh/': '提示'
  30. }
  31. }],
  32. ['container', {
  33. type: 'warning',
  34. defaultTitle: {
  35. '/': 'WARNING',
  36. '/zh/': '注意'
  37. }
  38. }],
  39. ['container', {
  40. type: 'danger',
  41. defaultTitle: {
  42. '/': 'WARNING',
  43. '/zh/': '警告'
  44. }
  45. }],
  46. ['smooth-scroll', enableSmoothScroll]
  47. ]
  48. }
  49. }