mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-28 17:57:48 +02:00
fix(algolia): properly forward placeholder/translations to DocSearch components (#10799)
This commit is contained in:
parent
e7a8c9db82
commit
e8ad3923ea
2 changed files with 31 additions and 18 deletions
|
@ -7,23 +7,36 @@
|
|||
|
||||
declare module '@docusaurus/theme-search-algolia' {
|
||||
import type {DeepPartial} from 'utility-types';
|
||||
import type {DocSearchProps} from '@docsearch/react';
|
||||
|
||||
export type ThemeConfig = {
|
||||
algolia: {
|
||||
contextualSearch: boolean;
|
||||
externalUrlRegex?: string;
|
||||
appId: string;
|
||||
apiKey: string;
|
||||
indexName: string;
|
||||
searchParameters: {[key: string]: unknown};
|
||||
searchPagePath: string | false | null;
|
||||
replaceSearchResultPathname?: {
|
||||
from: string;
|
||||
to: string;
|
||||
};
|
||||
insights?: boolean;
|
||||
// DocSearch props that Docusaurus exposes directly through props forwarding
|
||||
type DocusaurusDocSearchProps = Pick<
|
||||
DocSearchProps,
|
||||
| 'appId'
|
||||
| 'apiKey'
|
||||
| 'indexName'
|
||||
| 'placeholder'
|
||||
| 'translations'
|
||||
| 'searchParameters'
|
||||
| 'insights'
|
||||
| 'initialQuery'
|
||||
>;
|
||||
|
||||
type ThemeConfigAlgolia = DocusaurusDocSearchProps & {
|
||||
// Docusaurus custom options, not coming from DocSearch
|
||||
contextualSearch: boolean;
|
||||
externalUrlRegex?: string;
|
||||
searchPagePath: string | false | null;
|
||||
replaceSearchResultPathname?: {
|
||||
from: string;
|
||||
to: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type ThemeConfig = DocusaurusDocSearchProps & {
|
||||
algolia: ThemeConfigAlgolia;
|
||||
};
|
||||
|
||||
export type UserThemeConfig = DeepPartial<ThemeConfig>;
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ function DocSearch({
|
|||
onMouseOver={importDocSearchModalIfNeeded}
|
||||
onClick={openModal}
|
||||
ref={searchButtonRef}
|
||||
translations={translations.button}
|
||||
translations={props.translations?.button ?? translations.button}
|
||||
/>
|
||||
|
||||
{isOpen &&
|
||||
|
@ -260,10 +260,10 @@ function DocSearch({
|
|||
{...(props.searchPagePath && {
|
||||
resultsFooterComponent,
|
||||
})}
|
||||
{...props}
|
||||
searchParameters={searchParameters}
|
||||
placeholder={translations.placeholder}
|
||||
translations={translations.modal}
|
||||
{...props}
|
||||
translations={props.translations?.modal ?? translations.modal}
|
||||
searchParameters={searchParameters}
|
||||
/>,
|
||||
searchContainer.current,
|
||||
)}
|
||||
|
|
Loading…
Add table
Reference in a new issue