mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 02:08:55 +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' {
|
declare module '@docusaurus/theme-search-algolia' {
|
||||||
import type {DeepPartial} from 'utility-types';
|
import type {DeepPartial} from 'utility-types';
|
||||||
|
import type {DocSearchProps} from '@docsearch/react';
|
||||||
|
|
||||||
export type ThemeConfig = {
|
// DocSearch props that Docusaurus exposes directly through props forwarding
|
||||||
algolia: {
|
type DocusaurusDocSearchProps = Pick<
|
||||||
contextualSearch: boolean;
|
DocSearchProps,
|
||||||
externalUrlRegex?: string;
|
| 'appId'
|
||||||
appId: string;
|
| 'apiKey'
|
||||||
apiKey: string;
|
| 'indexName'
|
||||||
indexName: string;
|
| 'placeholder'
|
||||||
searchParameters: {[key: string]: unknown};
|
| 'translations'
|
||||||
searchPagePath: string | false | null;
|
| 'searchParameters'
|
||||||
replaceSearchResultPathname?: {
|
| 'insights'
|
||||||
from: string;
|
| 'initialQuery'
|
||||||
to: string;
|
>;
|
||||||
};
|
|
||||||
insights?: boolean;
|
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>;
|
export type UserThemeConfig = DeepPartial<ThemeConfig>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ function DocSearch({
|
||||||
onMouseOver={importDocSearchModalIfNeeded}
|
onMouseOver={importDocSearchModalIfNeeded}
|
||||||
onClick={openModal}
|
onClick={openModal}
|
||||||
ref={searchButtonRef}
|
ref={searchButtonRef}
|
||||||
translations={translations.button}
|
translations={props.translations?.button ?? translations.button}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{isOpen &&
|
{isOpen &&
|
||||||
|
@ -260,10 +260,10 @@ function DocSearch({
|
||||||
{...(props.searchPagePath && {
|
{...(props.searchPagePath && {
|
||||||
resultsFooterComponent,
|
resultsFooterComponent,
|
||||||
})}
|
})}
|
||||||
{...props}
|
|
||||||
searchParameters={searchParameters}
|
|
||||||
placeholder={translations.placeholder}
|
placeholder={translations.placeholder}
|
||||||
translations={translations.modal}
|
{...props}
|
||||||
|
translations={props.translations?.modal ?? translations.modal}
|
||||||
|
searchParameters={searchParameters}
|
||||||
/>,
|
/>,
|
||||||
searchContainer.current,
|
searchContainer.current,
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue