-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Expand file tree
/
Copy paththeme-search-algolia.d.ts
More file actions
105 lines (90 loc) · 2.77 KB
/
theme-search-algolia.d.ts
File metadata and controls
105 lines (90 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// TODO Docusaurus v4: remove after we drop support for DocSearch v3
declare module '@docsearch/react/button';
declare module '@docsearch/react/useDocSearchKeyboardEvents';
declare module '@docsearch/react/version';
declare module '@docusaurus/theme-search-algolia' {
import type {DeepPartial, Overwrite} from 'utility-types';
import type {DocSearchProps} from '@docsearch/react';
import type {FacetFilters} from 'algoliasearch/lite';
// The config after normalization (e.g. AskAI string -> object)
export type AskAiConfig = {
indexName: string;
apiKey: string;
appId: string;
assistantId: string;
searchParameters?: {
facetFilters?: FacetFilters;
};
};
// DocSearch props that Docusaurus exposes directly through props forwarding
type DocusaurusDocSearchProps = Pick<
DocSearchProps,
| 'appId'
| 'apiKey'
| 'indexName'
| 'placeholder'
| 'translations'
| 'searchParameters'
| 'insights'
| 'initialQuery'
> & {
// Docusaurus normalizes the AskAI config to an object
askAi?: AskAiConfig;
};
export type ThemeConfigAlgolia = DocusaurusDocSearchProps & {
// TODO Docusaurus v4: upgrade to DocSearch v4, migrate indexName to indices
indexName: string;
// Docusaurus custom options, not coming from DocSearch
contextualSearch: boolean;
externalUrlRegex?: string;
searchPagePath: string | false | null;
replaceSearchResultPathname?: {
from: string;
to: string;
};
};
export type ThemeConfig = {
algolia: ThemeConfigAlgolia;
};
export type UserThemeConfig = {
algolia?: Overwrite<
DeepPartial<ThemeConfigAlgolia>,
{
// Required fields:
appId: ThemeConfigAlgolia['appId'];
apiKey: ThemeConfigAlgolia['apiKey'];
indexName: ThemeConfigAlgolia['indexName'];
// askAi also accepts a shorter string form
askAi?: string | AskAiConfig;
}
>;
};
}
declare module '@theme/SearchPage' {
import type {ReactNode} from 'react';
export default function SearchPage(): ReactNode;
}
declare module '@theme/SearchBar' {
import type {ReactNode} from 'react';
export default function SearchBar(): ReactNode;
}
declare module '@theme/SearchTranslations' {
import type {DocSearchTranslations} from '@docsearch/react';
const translations: DocSearchTranslations & {
placeholder: string;
// TODO Docusaurus v4: cleanup after we drop support for DocSearch v3
modal?: {
searchBox?: {
placeholderText?: string;
placeholderTextAskAi?: string;
};
};
};
export default translations;
}