@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.
@@ -43,7 +43,7 @@ export function useAlgoliaAskAi(props) {
43
43
  setIsAskAiActive(askAiToggle);
44
44
  }, []);
45
45
  const extraAskAiProps = {
46
- askAi,
46
+ askAi: askAi,
47
47
  canHandleAskAi,
48
48
  isAskAiActive,
49
49
  onAskAiToggle,
@@ -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 + parsedURL.hash}`;
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
- export default function SearchBar(): ReactNode;
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
- return <DocSearch {...siteConfig.themeConfig.algolia} />;
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.9.2",
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
- "@docsearch/react": "^3.9.0 || ^4.1.0",
37
- "@docusaurus/core": "3.9.2",
38
- "@docusaurus/logger": "3.9.2",
39
- "@docusaurus/plugin-content-docs": "3.9.2",
40
- "@docusaurus/theme-common": "3.9.2",
41
- "@docusaurus/theme-translations": "3.9.2",
42
- "@docusaurus/utils": "3.9.2",
43
- "@docusaurus/utils-validation": "3.9.2",
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.9.2"
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": "abfbe5621b08407bc3dcbe6111ff118d4c22f7a1"
64
+ "gitHead": "0d98888a7645a5fb1330c905b75faf868f829f5c"
64
65
  }
@@ -91,7 +91,7 @@ export function useAlgoliaAskAi(props: DocSearchV4PropsLite): UseAskAiResult {
91
91
  }, []);
92
92
 
93
93
  const extraAskAiProps: UseAskAiResult['extraAskAiProps'] = {
94
- askAi,
94
+ askAi: askAi as any,
95
95
  canHandleAskAi,
96
96
  isAskAiActive,
97
97
  onAskAiToggle,
@@ -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 + parsedURL.hash}`;
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
- return (
318
- <DocSearch {...(siteConfig.themeConfig.algolia as DocSearchV4Props)} />
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
@@ -75,6 +75,7 @@ export const Schema = Joi.object<ThemeConfig>({
75
75
  searchParameters: Joi.object({
76
76
  facetFilters: FacetFiltersSchema.optional(),
77
77
  }).optional(),
78
+ suggestedQuestions: Joi.boolean().optional(),
78
79
  }),
79
80
  )
80
81
  .custom(