@vuepress/theme-default 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,9 +53,10 @@ export default {
53
53
  {
54
54
  inputSelector: '#algolia-search-input',
55
55
  // #697 Make docsearch work well at i18n mode.
56
- algoliaOptions: Object.assign({
57
- 'facetFilters': [`lang:${lang}`].concat(algoliaOptions.facetFilters || [])
58
- }, algoliaOptions),
56
+ algoliaOptions: {
57
+ ...algoliaOptions,
58
+ facetFilters: [`lang:${lang}`].concat(algoliaOptions.facetFilters || [])
59
+ },
59
60
  handleSelected: (input, event, suggestion) => {
60
61
  const { pathname, hash } = new URL(suggestion.url)
61
62
  const routepath = pathname.replace(this.$site.base, '/')
@@ -90,13 +90,16 @@ function resolveOpenGroupIndex (route, items) {
90
90
 
91
91
  function descendantIsActive (route, item) {
92
92
  if (item.type === 'group') {
93
- return item.children.some(child => {
93
+ const childIsActive = item.path && isActive(route, item.path)
94
+ const grandChildIsActive = item.children.some(child => {
94
95
  if (child.type === 'group') {
95
96
  return descendantIsActive(route, child)
96
97
  } else {
97
98
  return child.type === 'page' && isActive(route, child.path)
98
99
  }
99
100
  })
101
+
102
+ return childIsActive || grandChildIsActive
100
103
  }
101
104
  return false
102
105
  }
@@ -19,6 +19,11 @@ export default {
19
19
  type: Boolean,
20
20
  default: false
21
21
  }
22
+ },
23
+ mounted () {
24
+ if (this.$parent && this.$parent.loadTabs) {
25
+ this.$parent.loadTabs()
26
+ }
22
27
  }
23
28
  }
24
29
  </script>
@@ -1,30 +1,32 @@
1
1
  <template>
2
- <div class="theme-code-group">
3
- <div class="theme-code-group__nav">
4
- <ul class="theme-code-group__ul">
5
- <li
6
- v-for="(tab, i) in codeTabs"
7
- :key="tab.title"
8
- class="theme-code-group__li"
9
- >
10
- <button
11
- class="theme-code-group__nav-tab"
12
- :class="{
13
- 'theme-code-group__nav-tab-active': i === activeCodeTabIndex,
14
- }"
15
- @click="changeCodeTab(i)"
2
+ <ClientOnly>
3
+ <div class="theme-code-group">
4
+ <div class="theme-code-group__nav">
5
+ <ul class="theme-code-group__ul">
6
+ <li
7
+ v-for="(tab, i) in codeTabs"
8
+ :key="tab.title"
9
+ class="theme-code-group__li"
16
10
  >
17
- {{ tab.title }}
18
- </button>
19
- </li>
20
- </ul>
11
+ <button
12
+ class="theme-code-group__nav-tab"
13
+ :class="{
14
+ 'theme-code-group__nav-tab-active': i === activeCodeTabIndex,
15
+ }"
16
+ @click="changeCodeTab(i)"
17
+ >
18
+ {{ tab.title }}
19
+ </button>
20
+ </li>
21
+ </ul>
22
+ </div>
23
+ <slot />
24
+ <pre
25
+ v-if="codeTabs.length < 1"
26
+ class="pre-blank"
27
+ >// Make sure to add code blocks to your code group</pre>
21
28
  </div>
22
- <slot />
23
- <pre
24
- v-if="codeTabs.length < 1"
25
- class="pre-blank"
26
- >// Make sure to add code blocks to your code group</pre>
27
- </div>
29
+ </ClientOnly>
28
30
  </template>
29
31
 
30
32
  <script>
@@ -38,31 +40,44 @@ export default {
38
40
  },
39
41
  watch: {
40
42
  activeCodeTabIndex (index) {
41
- this.codeTabs.forEach(tab => {
42
- tab.elm.classList.remove('theme-code-block__active')
43
- })
44
- this.codeTabs[index].elm.classList.add('theme-code-block__active')
43
+ this.activateCodeTab(index)
45
44
  }
46
45
  },
47
46
  mounted () {
48
- this.codeTabs = (this.$slots.default || []).filter(slot => Boolean(slot.componentOptions)).map((slot, index) => {
49
- if (slot.componentOptions.propsData.active === '') {
50
- this.activeCodeTabIndex = index
51
- }
52
-
53
- return {
54
- title: slot.componentOptions.propsData.title,
55
- elm: slot.elm
56
- }
57
- })
58
-
59
- if (this.activeCodeTabIndex === -1 && this.codeTabs.length > 0) {
60
- this.activeCodeTabIndex = 0
61
- }
47
+ this.loadTabs()
62
48
  },
63
49
  methods: {
64
50
  changeCodeTab (index) {
65
51
  this.activeCodeTabIndex = index
52
+ },
53
+ loadTabs () {
54
+ this.codeTabs = (this.$slots.default || []).filter(slot => Boolean(slot.componentOptions)).map((slot, index) => {
55
+ if (slot.componentOptions.propsData.active === '') {
56
+ this.activeCodeTabIndex = index
57
+ }
58
+
59
+ return {
60
+ title: slot.componentOptions.propsData.title,
61
+ elm: slot.elm
62
+ }
63
+ })
64
+
65
+ if (this.activeCodeTabIndex === -1 && this.codeTabs.length > 0) {
66
+ this.activeCodeTabIndex = 0
67
+ }
68
+
69
+ this.activateCodeTab(0)
70
+ },
71
+ activateCodeTab (index) {
72
+ this.codeTabs.forEach(tab => {
73
+ if (tab.elm) {
74
+ tab.elm.classList.remove('theme-code-block__active')
75
+ }
76
+ })
77
+
78
+ if (this.codeTabs[index].elm) {
79
+ this.codeTabs[index].elm.classList.add('theme-code-block__active')
80
+ }
66
81
  }
67
82
  }
68
83
  }
package/index.js CHANGED
@@ -44,7 +44,7 @@ module.exports = (options, ctx) => {
44
44
  ['container', {
45
45
  type: 'danger',
46
46
  defaultTitle: {
47
- '/': 'WARNING',
47
+ '/': 'DANGER',
48
48
  '/zh/': '警告'
49
49
  }
50
50
  }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Default theme for VuePress",
5
5
  "keywords": [
6
6
  "documentation",
@@ -21,9 +21,9 @@
21
21
  "author": "Evan You",
22
22
  "main": "index.js",
23
23
  "dependencies": {
24
- "@vuepress/plugin-active-header-links": "1.8.0",
25
- "@vuepress/plugin-nprogress": "1.8.0",
26
- "@vuepress/plugin-search": "1.8.0",
24
+ "@vuepress/plugin-active-header-links": "1.9.0",
25
+ "@vuepress/plugin-nprogress": "1.9.0",
26
+ "@vuepress/plugin-search": "1.9.0",
27
27
  "docsearch.js": "^2.5.2",
28
28
  "lodash": "^4.17.15",
29
29
  "stylus": "^0.54.8",
@@ -40,5 +40,5 @@
40
40
  "email": "chl814@foxmail.com"
41
41
  }
42
42
  ],
43
- "gitHead": "d2c9e2d148bdc7bc97e28fa8d86b03f2e5927124"
43
+ "gitHead": "1440bbdaf6a12ed26e59c8350763f91526bca33c"
44
44
  }