@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:
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<div class="theme-code-
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
25
|
-
"@vuepress/plugin-nprogress": "1.
|
|
26
|
-
"@vuepress/plugin-search": "1.
|
|
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": "
|
|
43
|
+
"gitHead": "1440bbdaf6a12ed26e59c8350763f91526bca33c"
|
|
44
44
|
}
|