File tree 2 files changed +30
-17
lines changed
packages/docusaurus-theme-search-algolia/src
2 files changed +30
-17
lines changed Original file line number Diff line number Diff line change 7
7
8
8
declare module '@docusaurus/theme-search-algolia' {
9
9
import type { DeepPartial } from 'utility-types' ;
10
+ import type { DocSearchProps } from '@docsearch/react' ;
10
11
11
- export type ThemeConfig = {
12
- algolia : {
13
- contextualSearch : boolean ;
14
- externalUrlRegex ?: string ;
15
- appId : string ;
16
- apiKey : string ;
17
- indexName : string ;
18
- searchParameters : { [ key : string ] : unknown } ;
19
- searchPagePath : string | false | null ;
20
- replaceSearchResultPathname ?: {
21
- from : string ;
22
- to : string ;
23
- } ;
24
- insights ?: boolean ;
12
+ // DocSearch props that Docusaurus exposes directly through props forwarding
13
+ type DocusaurusDocSearchProps = Pick <
14
+ DocSearchProps ,
15
+ | 'appId'
16
+ | 'apiKey'
17
+ | 'indexName'
18
+ | 'placeholder'
19
+ | 'translations'
20
+ | 'searchParameters'
21
+ | 'insights'
22
+ | 'initialQuery'
23
+ > ;
24
+
25
+ type ThemeConfigAlgolia = DocusaurusDocSearchProps & {
26
+ // Docusaurus custom options, not coming from DocSearch
27
+ contextualSearch : boolean ;
28
+ externalUrlRegex ?: string ;
29
+ searchPagePath : string | false | null ;
30
+ replaceSearchResultPathname ?: {
31
+ from : string ;
32
+ to : string ;
25
33
} ;
26
34
} ;
35
+
36
+ export type ThemeConfig = DocusaurusDocSearchProps & {
37
+ algolia : ThemeConfigAlgolia ;
38
+ } ;
39
+
27
40
export type UserThemeConfig = DeepPartial < ThemeConfig > ;
28
41
}
29
42
Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ function DocSearch({
242
242
onMouseOver = { importDocSearchModalIfNeeded }
243
243
onClick = { openModal }
244
244
ref = { searchButtonRef }
245
- translations = { translations . button }
245
+ translations = { props . translations ?. button ?? translations . button }
246
246
/>
247
247
248
248
{ isOpen &&
@@ -260,10 +260,10 @@ function DocSearch({
260
260
{ ...( props . searchPagePath && {
261
261
resultsFooterComponent,
262
262
} ) }
263
+ placeholder = { translations . placeholder }
263
264
{ ...props }
265
+ translations = { props . translations ?. modal ?? translations . modal }
264
266
searchParameters = { searchParameters }
265
- placeholder = { translations . placeholder }
266
- translations = { translations . modal }
267
267
/> ,
268
268
searchContainer . current ,
269
269
) }
You can’t perform that action at this time.
0 commit comments