|
1 | | -function plugin() { |
2 | | - return (ctx) => { |
3 | | - window.app = ctx |
4 | | - } |
5 | | -} |
6 | | - |
7 | 1 | const languages = { |
8 | 2 | title: 'Language', |
9 | 3 | type: 'dropdown', |
10 | 4 | exact: true, |
11 | 5 | items: [ |
12 | | - { title: 'English', path: '/en/' } |
| 6 | + { title: 'English', path: '/en/', matchPath: /\/en\/.*/i } |
13 | 7 | ] |
14 | 8 | } |
15 | 9 |
|
16 | 10 | const home = { title: 'Home', path: '/' } |
17 | 11 |
|
18 | | -const version_en = { |
19 | | - title: 'Version', |
20 | | - type: 'dropdown', |
21 | | - exact: true, |
22 | | - items: [ |
23 | | - { title: 'Version 2.2', path: '/en/2.2/' }, |
24 | | - { title: 'Version 2.3', path: '/en/2.3/' }, |
25 | | - ] |
| 12 | +const versions = [ |
| 13 | + { title: 'Version 2.2', path: '/2.2/', matchPath: /^\/([a-z-]+)\/2.2\/.*/i }, |
| 14 | + { title: 'Version 2.3', path: '/2.3/', matchPath: /^\/([a-z-]+)\/2.3\/.*/i }, |
| 15 | +] |
| 16 | + |
| 17 | +function lang_version(lang) { |
| 18 | + const version = { |
| 19 | + title: 'Version', |
| 20 | + type: 'dropdown', |
| 21 | + exact: true, |
| 22 | + } |
| 23 | + version.items = versions.map(function (v) { |
| 24 | + const ver = Object.assign({}, v) |
| 25 | + ver.path = '/' + lang + ver.path |
| 26 | + |
| 27 | + return ver |
| 28 | + }) |
| 29 | + |
| 30 | + return version |
26 | 31 | } |
27 | 32 |
|
28 | 33 | self.$config = { |
29 | 34 | repo: 'vuejs/rollup-plugin-vue', |
30 | 35 | 'edit-link': 'https://github.com/vuejs/rollup-plugin-vue/edit/master/docs', |
31 | 36 |
|
32 | 37 | nav: { |
33 | | - default: [home, languages, version_en], |
34 | | - |
35 | | - 'en2.2': [home, { title: 'Examples', path: '/en/2.2/examples' }, languages, version_en] |
| 38 | + default: [home, languages, lang_version('en')], |
| 39 | + 'en2.3': [{ title: 'Home', path: '/en/2.3/' }, { title: 'Examples', path: '/en/2.3/examples' }, languages, lang_version('en')], |
| 40 | + 'en2.2': [{ title: 'Home', path: '/en/2.2/' }, { title: 'Examples', path: '/en/2.2/examples' }, languages, lang_version('en')], |
36 | 41 | }, |
37 | 42 |
|
38 | | - plugins: [plugin()] |
| 43 | + plugins: [ |
| 44 | + docsearch({ |
| 45 | + apiKey: 'You API Key', |
| 46 | + indexName: 'rollup-plugin-vue-docs', |
| 47 | + tags: ['en'] |
| 48 | + }) |
| 49 | + ] |
39 | 50 | } |
0 commit comments