@docusaurus/theme-search-algolia 3.9.2 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/useAlgoliaAskAi.js +1 -1
- package/lib/client/useSearchResultUrlProcessor.js +1 -1
- package/lib/theme/SearchBar/index.d.ts +17 -1
- package/lib/theme/SearchBar/index.js +8 -2
- package/lib/validateThemeConfig.js +1 -0
- package/package.json +12 -11
- package/src/client/useAlgoliaAskAi.ts +1 -1
- package/src/client/useSearchResultUrlProcessor.ts +1 -1
- package/src/theme/SearchBar/index.tsx +13 -7
- package/src/theme-search-algolia.d.ts +2 -0
- package/src/validateThemeConfig.ts +1 -0
|
@@ -27,7 +27,7 @@ export function useSearchResultUrlProcessor() {
|
|
|
27
27
|
return url;
|
|
28
28
|
}
|
|
29
29
|
// Otherwise => transform to relative URL for SPA navigation
|
|
30
|
-
const relativeUrl = `${parsedURL.pathname
|
|
30
|
+
const relativeUrl = `${parsedURL.pathname}${parsedURL.search}${parsedURL.hash}`;
|
|
31
31
|
return withBaseUrl(replacePathname(relativeUrl, replaceSearchResultPathname));
|
|
32
32
|
}, [withBaseUrl, externalUrlRegex, replaceSearchResultPathname]);
|
|
33
33
|
}
|
|
@@ -5,4 +5,20 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type ReactNode } from 'react';
|
|
8
|
-
|
|
8
|
+
import type { DocSearchModalProps, DocSearchTranslations } from '@docsearch/react';
|
|
9
|
+
import type { ThemeConfigAlgolia } from '@docusaurus/theme-search-algolia';
|
|
10
|
+
type DocSearchProps = Omit<DocSearchModalProps, 'onClose' | 'initialScrollY'> & {
|
|
11
|
+
contextualSearch?: string;
|
|
12
|
+
externalUrlRegex?: string;
|
|
13
|
+
searchPagePath: boolean | string;
|
|
14
|
+
askAi?: Exclude<(DocSearchModalProps & {
|
|
15
|
+
askAi: unknown;
|
|
16
|
+
})['askAi'], string | undefined>;
|
|
17
|
+
};
|
|
18
|
+
interface DocSearchV4Props extends Omit<DocSearchProps, 'askAi'> {
|
|
19
|
+
indexName: string;
|
|
20
|
+
askAi?: ThemeConfigAlgolia['askAi'];
|
|
21
|
+
translations?: DocSearchTranslations;
|
|
22
|
+
}
|
|
23
|
+
export default function SearchBar(props: Partial<DocSearchV4Props>): ReactNode;
|
|
24
|
+
export {};
|
|
@@ -217,7 +217,13 @@ function DocSearch({externalUrlRegex, ...props}) {
|
|
|
217
217
|
</>
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
|
-
export default function SearchBar() {
|
|
220
|
+
export default function SearchBar(props) {
|
|
221
221
|
const {siteConfig} = useDocusaurusContext();
|
|
222
|
-
|
|
222
|
+
const docSearchProps = {
|
|
223
|
+
...siteConfig.themeConfig.algolia,
|
|
224
|
+
// Let props override theme config
|
|
225
|
+
// See https://github.com/facebook/docusaurus/pull/11581
|
|
226
|
+
...props,
|
|
227
|
+
};
|
|
228
|
+
return <DocSearch {...docSearchProps} />;
|
|
223
229
|
}
|
|
@@ -66,6 +66,7 @@ exports.Schema = utils_validation_1.Joi.object({
|
|
|
66
66
|
searchParameters: utils_validation_1.Joi.object({
|
|
67
67
|
facetFilters: FacetFiltersSchema.optional(),
|
|
68
68
|
}).optional(),
|
|
69
|
+
suggestedQuestions: utils_validation_1.Joi.boolean().optional(),
|
|
69
70
|
}))
|
|
70
71
|
.custom((askAiInput, helpers) => {
|
|
71
72
|
if (!askAiInput) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-search-algolia",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "Algolia search component for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": [
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@docusaurus/
|
|
39
|
-
"@docusaurus/
|
|
40
|
-
"@docusaurus/
|
|
41
|
-
"@docusaurus/theme-
|
|
42
|
-
"@docusaurus/
|
|
43
|
-
"@docusaurus/utils
|
|
36
|
+
"@algolia/autocomplete-core": "^1.19.2",
|
|
37
|
+
"@docsearch/react": "^3.9.0 || ^4.3.2",
|
|
38
|
+
"@docusaurus/core": "3.10.0",
|
|
39
|
+
"@docusaurus/logger": "3.10.0",
|
|
40
|
+
"@docusaurus/plugin-content-docs": "3.10.0",
|
|
41
|
+
"@docusaurus/theme-common": "3.10.0",
|
|
42
|
+
"@docusaurus/theme-translations": "3.10.0",
|
|
43
|
+
"@docusaurus/utils": "3.10.0",
|
|
44
|
+
"@docusaurus/utils-validation": "3.10.0",
|
|
44
45
|
"algoliasearch": "^5.37.0",
|
|
45
46
|
"algoliasearch-helper": "^3.26.0",
|
|
46
47
|
"clsx": "^2.0.0",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"utility-types": "^3.10.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@docusaurus/module-type-aliases": "3.
|
|
55
|
+
"@docusaurus/module-type-aliases": "3.10.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"engines": {
|
|
61
62
|
"node": ">=20.0"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "0d98888a7645a5fb1330c905b75faf868f829f5c"
|
|
64
65
|
}
|
|
@@ -43,7 +43,7 @@ export function useSearchResultUrlProcessor(): (url: string) => string {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Otherwise => transform to relative URL for SPA navigation
|
|
46
|
-
const relativeUrl = `${parsedURL.pathname
|
|
46
|
+
const relativeUrl = `${parsedURL.pathname}${parsedURL.search}${parsedURL.hash}`;
|
|
47
47
|
|
|
48
48
|
return withBaseUrl(
|
|
49
49
|
replacePathname(relativeUrl, replaceSearchResultPathname),
|
|
@@ -61,7 +61,7 @@ type DocSearchProps = Omit<
|
|
|
61
61
|
|
|
62
62
|
// extend DocSearchProps for v4 features
|
|
63
63
|
// TODO Docusaurus v4: cleanup after we drop support for DocSearch v3
|
|
64
|
-
interface DocSearchV4Props extends DocSearchProps {
|
|
64
|
+
interface DocSearchV4Props extends Omit<DocSearchProps, 'askAi'> {
|
|
65
65
|
indexName: string;
|
|
66
66
|
askAi?: ThemeConfigAlgolia['askAi'];
|
|
67
67
|
translations?: DocSearchTranslations;
|
|
@@ -199,7 +199,7 @@ function useSearchParameters({
|
|
|
199
199
|
|
|
200
200
|
function DocSearch({externalUrlRegex, ...props}: DocSearchV4Props) {
|
|
201
201
|
const navigator = useNavigator({externalUrlRegex});
|
|
202
|
-
const searchParameters = useSearchParameters({...props});
|
|
202
|
+
const searchParameters = useSearchParameters({...props} as DocSearchProps);
|
|
203
203
|
const transformItems = useTransformItems(props);
|
|
204
204
|
const transformSearchClient = useTransformSearchClient();
|
|
205
205
|
|
|
@@ -301,7 +301,7 @@ function DocSearch({externalUrlRegex, ...props}: DocSearchV4Props) {
|
|
|
301
301
|
resultsFooterComponent,
|
|
302
302
|
})}
|
|
303
303
|
placeholder={currentPlaceholder}
|
|
304
|
-
{...props}
|
|
304
|
+
{...(props as any)}
|
|
305
305
|
translations={props.translations?.modal ?? translations.modal}
|
|
306
306
|
searchParameters={searchParameters}
|
|
307
307
|
{...extraAskAiProps}
|
|
@@ -312,9 +312,15 @@ function DocSearch({externalUrlRegex, ...props}: DocSearchV4Props) {
|
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
export default function SearchBar(): ReactNode {
|
|
315
|
+
export default function SearchBar(props: Partial<DocSearchV4Props>): ReactNode {
|
|
316
316
|
const {siteConfig} = useDocusaurusContext();
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
|
|
318
|
+
const docSearchProps: DocSearchV4Props = {
|
|
319
|
+
...(siteConfig.themeConfig.algolia as DocSearchV4Props),
|
|
320
|
+
// Let props override theme config
|
|
321
|
+
// See https://github.com/facebook/docusaurus/pull/11581
|
|
322
|
+
...props,
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
return <DocSearch {...docSearchProps} />;
|
|
320
326
|
}
|
|
@@ -17,6 +17,7 @@ declare module '@docusaurus/theme-search-algolia' {
|
|
|
17
17
|
import type {FacetFilters} from 'algoliasearch/lite';
|
|
18
18
|
|
|
19
19
|
// The config after normalization (e.g. AskAI string -> object)
|
|
20
|
+
// This matches DocSearch v4.3+ AskAi configuration
|
|
20
21
|
export type AskAiConfig = {
|
|
21
22
|
indexName: string;
|
|
22
23
|
apiKey: string;
|
|
@@ -25,6 +26,7 @@ declare module '@docusaurus/theme-search-algolia' {
|
|
|
25
26
|
searchParameters?: {
|
|
26
27
|
facetFilters?: FacetFilters;
|
|
27
28
|
};
|
|
29
|
+
suggestedQuestions?: boolean;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
// DocSearch props that Docusaurus exposes directly through props forwarding
|