File tree 7 files changed +84
-3
lines changed
7 files changed +84
-3
lines changed Original file line number Diff line number Diff line change
1
+ __tests__
2
+ __mocks__
Original file line number Diff line number Diff line change
1
+ # @vuepress/plugin-search
2
+
3
+ > header-based search plugin for vuepress
4
+
5
+ ## Usage
6
+
7
+ 1 . Enable this plugin:
8
+
9
+ ``` js
10
+ // .vuepress/config.js or themedir/index.js
11
+
12
+ module .exports = {
13
+ plugins: [
14
+ [' @vuepress/search' , {
15
+ searchMaxSuggestions: 10
16
+ }]
17
+ ],
18
+ // Tweak the default color via palette.
19
+ palette: {
20
+ $accentColor: ' #b58900' ,
21
+ $textColor: ' #586e75' ,
22
+ $borderColor: ' #eaecef' ,
23
+ $codeBgColor: ' #282c34' ,
24
+ $arrowBgColor: ' #ccc'
25
+ }
26
+ }
27
+ ```
28
+
29
+ 2 . Using search component:
30
+
31
+ ``` vue
32
+ import SearchBox from '@SearchBox'
33
+ ```
34
+
35
+ ## Options
36
+
37
+ ### searchMaxSuggestions
38
+
39
+ - Type: ` number `
40
+ - Default: ` true `
41
+
42
+ Set the maximum number of results for search
Original file line number Diff line number Diff line change 36
36
</template >
37
37
38
38
<script >
39
+ /* global SEARCH_MAX_SUGGESTIONS */
39
40
export default {
40
41
data () {
41
42
return {
@@ -60,8 +61,8 @@ export default {
60
61
return
61
62
}
62
63
63
- const { pages , themeConfig } = this .$site
64
- const max = themeConfig . searchMaxSuggestions || 5
64
+ const { pages } = this .$site
65
+ const max = SEARCH_MAX_SUGGESTIONS
65
66
const localePath = this .$localePath
66
67
const matches = item => (
67
68
item .title &&
Original file line number Diff line number Diff line change
1
+ const path = require ( 'path' )
2
+
3
+ module . exports = ( options ) => ( {
4
+ alias : {
5
+ '@SearchBox' :
6
+ path . resolve ( __dirname , 'SearchBox.vue' )
7
+ } ,
8
+ define : {
9
+ SEARCH_MAX_SUGGESTIONS : options . searchMaxSuggestions || 5
10
+ }
11
+ } )
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " @vuepress/plugin-search" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " search plugin for vuepress" ,
5
+ "main" : " index.js" ,
6
+ "publishConfig" : {
7
+ "access" : " public"
8
+ },
9
+ "repository" : {
10
+ "type" : " git" ,
11
+ "url" : " git+https://github.com/vuejs/vuepress.git"
12
+ },
13
+ "keywords" : [
14
+ " documentation" ,
15
+ " vue" ,
16
+ " vuepress" ,
17
+ " generator"
18
+ ],
19
+ "author" : " Evan You" ,
20
+ "license" : " MIT" ,
21
+ "bugs" : {
22
+ "url" : " https://github.com/vuejs/vuepress/issues"
23
+ },
24
+ "homepage" : " https://github.com/vuejs/vuepress/packages/@vuepress/plugin-search#readme"
25
+ }
File renamed without changes.
Original file line number Diff line number Diff line change 39
39
<script >
40
40
import SidebarButton from ' ./SidebarButton.vue'
41
41
import AlgoliaSearchBox from ' @AlgoliaSearchBox'
42
- import SearchBox from ' ./ SearchBox.vue '
42
+ import SearchBox from ' @ SearchBox'
43
43
import NavLinks from ' ./NavLinks.vue'
44
44
45
45
export default {
You can’t perform that action at this time.
0 commit comments