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