@@ -7,6 +7,7 @@ import type { DocsearchOptions } from '../../shared/index.js'
7
7
import { useDocsearchShim } from '../composables/index.js'
8
8
9
9
declare const __DOCSEARCH_INJECT_STYLES__ : boolean
10
+ declare const __DOCSEARCH_OPTIONS__ : DocsearchOptions
10
11
11
12
if ( __DOCSEARCH_INJECT_STYLES__ ) {
12
13
import ( '@docsearch/css' )
@@ -24,7 +25,8 @@ export const Docsearch = defineComponent({
24
25
} ,
25
26
options : {
26
27
type : Object as PropType < DocsearchOptions > ,
27
- required : true ,
28
+ required : false ,
29
+ default : ( ) => __DOCSEARCH_OPTIONS__ ,
28
30
} ,
29
31
} ,
30
32
@@ -33,8 +35,8 @@ export const Docsearch = defineComponent({
33
35
const lang = usePageLang ( )
34
36
const docsearchShim = useDocsearchShim ( )
35
37
36
- // resolve docsearch props for current locale
37
- const propsLocale = computed ( ( ) => ( {
38
+ // resolve docsearch options for current locale
39
+ const optionsLocale = computed ( ( ) => ( {
38
40
...props . options ,
39
41
...props . options . locales ?. [ routeLocale . value ] ,
40
42
} ) )
@@ -43,7 +45,7 @@ export const Docsearch = defineComponent({
43
45
44
46
const initialize = ( ) : void => {
45
47
const rawFacetFilters =
46
- propsLocale . value . searchParameters ?. facetFilters ?? [ ]
48
+ optionsLocale . value . searchParameters ?. facetFilters ?? [ ]
47
49
facetFilters . splice (
48
50
0 ,
49
51
facetFilters . length ,
@@ -53,10 +55,10 @@ export const Docsearch = defineComponent({
53
55
// @ts -expect-error: https://github.com/microsoft/TypeScript/issues/50690
54
56
docsearch ( {
55
57
...docsearchShim ,
56
- ...propsLocale . value ,
58
+ ...optionsLocale . value ,
57
59
container : `#${ props . containerId } ` ,
58
60
searchParameters : {
59
- ...propsLocale . value . searchParameters ,
61
+ ...optionsLocale . value . searchParameters ,
60
62
facetFilters,
61
63
} ,
62
64
} )
@@ -67,7 +69,7 @@ export const Docsearch = defineComponent({
67
69
68
70
// re-initialize if the options is changed
69
71
watch (
70
- [ routeLocale , propsLocale ] ,
72
+ [ routeLocale , optionsLocale ] ,
71
73
(
72
74
[ curRouteLocale , curPropsLocale ] ,
73
75
[ prevRouteLocale , prevPropsLocale ]
0 commit comments