@@ -15,28 +15,44 @@ export default {
15
15
props: [' options' ],
16
16
17
17
mounted () {
18
- this .initialize ()
18
+ this .initialize (this . options , this . $lang )
19
19
},
20
20
21
21
methods: {
22
- initialize () {
22
+ initialize (userOptions , lang ) {
23
23
Promise .all ([
24
24
import (/* webpackChunkName: "docsearch" */ ' docsearch.js/dist/cdn/docsearch.min.js' ),
25
25
import (/* webpackChunkName: "docsearch" */ ' docsearch.js/dist/cdn/docsearch.min.css' )
26
26
]).then (([docsearch ]) => {
27
27
docsearch = docsearch .default
28
- docsearch (Object .assign (this .options , {
29
- debug: true ,
30
- inputSelector: ' #algolia-search-input'
31
- }))
28
+ const { algoliaOptions = {}} = userOptions
29
+ docsearch (Object .assign (
30
+ {},
31
+ userOptions,
32
+ {
33
+ inputSelector: ' #algolia-search-input' ,
34
+ // #697 Make docsearch work well at i18n mode.
35
+ algoliaOptions: Object .assign ({
36
+ ' facetFilters' : [` lang:${ lang} ` ].concat (algoliaOptions .facetFilters || [])
37
+ }, algoliaOptions)
38
+ }
39
+ ))
32
40
})
41
+ },
42
+
43
+ update (options , lang ) {
44
+ this .$el .innerHTML = ' <input id="algolia-search-input" class="search-query">'
45
+ this .initialize (options, lang)
33
46
}
34
47
},
35
48
36
49
watch: {
50
+ $lang (newValue) {
51
+ this .update (this .options , newValue)
52
+ },
53
+
37
54
options (newValue ) {
38
- this .$el .innerHTML = ' <input id="algolia-search-input" class="search-query">'
39
- this .initialize (newValue)
55
+ this .update (newValue, this .$lang )
40
56
}
41
57
}
42
58
}
0 commit comments