@docusaurus/theme-search-algolia 3.8.1-canary-6401 → 3.8.1-canary-6402
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.d.ts +1 -1
- package/lib/client/useAlgoliaAskAi.js +1 -1
- package/lib/docSearchVersion.d.ts +7 -0
- package/lib/docSearchVersion.js +13 -0
- package/lib/index.js +20 -0
- package/lib/theme/SearchBar/index.js +2 -1
- package/lib/validateThemeConfig.js +3 -2
- package/package.json +11 -11
- package/src/client/useAlgoliaAskAi.ts +5 -5
- package/src/docSearchVersion.ts +12 -0
- package/src/index.ts +21 -0
- package/src/theme/SearchBar/index.tsx +3 -4
- package/src/theme-search-algolia.d.ts +5 -0
- package/src/validateThemeConfig.ts +3 -2
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import { type DocSearchModalProps, type DocSearchTranslations } from '@docsearch/react';
|
|
8
7
|
import type { AskAiConfig } from '@docusaurus/theme-search-algolia';
|
|
8
|
+
import type { DocSearchModalProps, DocSearchTranslations } from '@docsearch/react';
|
|
9
9
|
interface DocSearchV4PropsLite {
|
|
10
10
|
indexName: string;
|
|
11
11
|
apiKey: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { useCallback, useMemo, useState } from 'react';
|
|
8
|
-
import { version as docsearchVersion
|
|
8
|
+
import { version as docsearchVersion } from '@docsearch/react/version';
|
|
9
9
|
import translations from '@theme/SearchTranslations';
|
|
10
10
|
import { useAlgoliaContextualFacetFiltersIfEnabled } from './useAlgoliaContextualFacetFilters';
|
|
11
11
|
import { mergeFacetFilters } from './utils';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.docSearchV3 = void 0;
|
|
10
|
+
const react_1 = require("@docsearch/react");
|
|
11
|
+
// TODO Docusaurus v4: upgrade to DocSearch v4
|
|
12
|
+
// drop v3 compat, remove this file?
|
|
13
|
+
exports.docSearchV3 = react_1.version.startsWith('3.');
|
package/lib/index.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.default = themeSearchAlgolia;
|
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
const theme_translations_1 = require("@docusaurus/theme-translations");
|
|
13
13
|
const opensearch_1 = require("./opensearch");
|
|
14
|
+
const docSearchVersion_1 = require("./docSearchVersion");
|
|
14
15
|
function themeSearchAlgolia(context) {
|
|
15
16
|
const { baseUrl, siteConfig: { themeConfig }, i18n: { currentLocale }, } = context;
|
|
16
17
|
const { algolia: { searchPagePath }, } = themeConfig;
|
|
@@ -48,6 +49,25 @@ function themeSearchAlgolia(context) {
|
|
|
48
49
|
}
|
|
49
50
|
return {};
|
|
50
51
|
},
|
|
52
|
+
configureWebpack() {
|
|
53
|
+
// TODO Docusaurus v4: remove after dropping DocSearch v3 support
|
|
54
|
+
if (docSearchVersion_1.docSearchV3) {
|
|
55
|
+
// These aliases ensure DocSearch v3 imports are compatible with
|
|
56
|
+
// the newly added DocSearch v4 entry points
|
|
57
|
+
// See https://github.com/algolia/docsearch/pull/2764
|
|
58
|
+
const docSearchV3Entry = require.resolve('@docsearch/react');
|
|
59
|
+
return {
|
|
60
|
+
resolve: {
|
|
61
|
+
alias: {
|
|
62
|
+
'@docsearch/react/version': docSearchV3Entry,
|
|
63
|
+
'@docsearch/react/useDocSearchKeyboardEvents': docSearchV3Entry,
|
|
64
|
+
'@docsearch/react/useTheme': docSearchV3Entry,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
},
|
|
51
71
|
};
|
|
52
72
|
}
|
|
53
73
|
var validateThemeConfig_1 = require("./validateThemeConfig");
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, {useCallback, useMemo, useRef, useState} from 'react';
|
|
8
8
|
import {createPortal} from 'react-dom';
|
|
9
|
-
import {DocSearchButton
|
|
9
|
+
import {DocSearchButton} from '@docsearch/react/button';
|
|
10
|
+
import {useDocSearchKeyboardEvents} from '@docsearch/react/useDocSearchKeyboardEvents';
|
|
10
11
|
import Head from '@docusaurus/Head';
|
|
11
12
|
import Link from '@docusaurus/Link';
|
|
12
13
|
import {useHistory} from '@docusaurus/router';
|
|
@@ -10,7 +10,7 @@ exports.Schema = exports.DEFAULT_CONFIG = void 0;
|
|
|
10
10
|
exports.validateThemeConfig = validateThemeConfig;
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
13
|
-
const
|
|
13
|
+
const docSearchVersion_1 = require("./docSearchVersion");
|
|
14
14
|
exports.DEFAULT_CONFIG = {
|
|
15
15
|
// Enabled by default, as it makes sense in most cases
|
|
16
16
|
// see also https://github.com/facebook/docusaurus/issues/5880
|
|
@@ -103,9 +103,10 @@ exports.Schema = utils_validation_1.Joi.object({
|
|
|
103
103
|
.required()
|
|
104
104
|
.unknown(),
|
|
105
105
|
});
|
|
106
|
+
// TODO Docusaurus v4: remove this check when we drop DocSearch v3
|
|
106
107
|
function ensureAskAISupported(themeConfig) {
|
|
107
108
|
// enforce DocsSearch v4 requirement when AskAI is configured
|
|
108
|
-
if (themeConfig.algolia.askAi &&
|
|
109
|
+
if (themeConfig.algolia.askAi && docSearchVersion_1.docSearchV3) {
|
|
109
110
|
throw new Error('The askAi feature is only supported in DocSearch v4. ' +
|
|
110
111
|
'Please upgrade to DocSearch v4 by installing "@docsearch/react": "^4.0.0" ' +
|
|
111
112
|
'or remove the askAi configuration from your theme config.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-search-algolia",
|
|
3
|
-
"version": "3.8.1-canary-
|
|
3
|
+
"version": "3.8.1-canary-6402",
|
|
4
4
|
"description": "Algolia search component for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": [
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docsearch/react": "^3.9.0",
|
|
37
|
-
"@docusaurus/core": "3.8.1-canary-
|
|
38
|
-
"@docusaurus/logger": "3.8.1-canary-
|
|
39
|
-
"@docusaurus/plugin-content-docs": "3.8.1-canary-
|
|
40
|
-
"@docusaurus/theme-common": "3.8.1-canary-
|
|
41
|
-
"@docusaurus/theme-translations": "3.8.1-canary-
|
|
42
|
-
"@docusaurus/utils": "3.8.1-canary-
|
|
43
|
-
"@docusaurus/utils-validation": "3.8.1-canary-
|
|
36
|
+
"@docsearch/react": "^3.9.0 || ^4.1.0",
|
|
37
|
+
"@docusaurus/core": "3.8.1-canary-6402",
|
|
38
|
+
"@docusaurus/logger": "3.8.1-canary-6402",
|
|
39
|
+
"@docusaurus/plugin-content-docs": "3.8.1-canary-6402",
|
|
40
|
+
"@docusaurus/theme-common": "3.8.1-canary-6402",
|
|
41
|
+
"@docusaurus/theme-translations": "3.8.1-canary-6402",
|
|
42
|
+
"@docusaurus/utils": "3.8.1-canary-6402",
|
|
43
|
+
"@docusaurus/utils-validation": "3.8.1-canary-6402",
|
|
44
44
|
"algoliasearch": "^5.37.0",
|
|
45
45
|
"algoliasearch-helper": "^3.26.0",
|
|
46
46
|
"clsx": "^2.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"utility-types": "^3.10.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@docusaurus/module-type-aliases": "3.8.1-canary-
|
|
54
|
+
"@docusaurus/module-type-aliases": "3.8.1-canary-6402"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=20.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d8576f8e307990a7f8350e753b3034d5e6de53d1"
|
|
64
64
|
}
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {useCallback, useMemo, useState} from 'react';
|
|
9
|
-
import {
|
|
10
|
-
version as docsearchVersion,
|
|
11
|
-
type DocSearchModalProps,
|
|
12
|
-
type DocSearchTranslations,
|
|
13
|
-
} from '@docsearch/react';
|
|
9
|
+
import {version as docsearchVersion} from '@docsearch/react/version';
|
|
14
10
|
import translations from '@theme/SearchTranslations';
|
|
15
11
|
import {useAlgoliaContextualFacetFiltersIfEnabled} from './useAlgoliaContextualFacetFilters';
|
|
16
12
|
import {mergeFacetFilters} from './utils';
|
|
17
13
|
import type {AskAiConfig} from '@docusaurus/theme-search-algolia';
|
|
14
|
+
import type {
|
|
15
|
+
DocSearchModalProps,
|
|
16
|
+
DocSearchTranslations,
|
|
17
|
+
} from '@docsearch/react';
|
|
18
18
|
import type {FacetFilters} from 'algoliasearch/lite';
|
|
19
19
|
|
|
20
20
|
// The minimal props the hook needs from DocSearch v4 props
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {version as docSearchVersion} from '@docsearch/react';
|
|
9
|
+
|
|
10
|
+
// TODO Docusaurus v4: upgrade to DocSearch v4
|
|
11
|
+
// drop v3 compat, remove this file?
|
|
12
|
+
export const docSearchV3: boolean = docSearchVersion.startsWith('3.');
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createOpenSearchHeadTags,
|
|
13
13
|
shouldCreateOpenSearchFile,
|
|
14
14
|
} from './opensearch';
|
|
15
|
+
import {docSearchV3} from './docSearchVersion';
|
|
15
16
|
|
|
16
17
|
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
17
18
|
import type {ThemeConfig} from '@docusaurus/theme-search-algolia';
|
|
@@ -65,6 +66,26 @@ export default function themeSearchAlgolia(context: LoadContext): Plugin<void> {
|
|
|
65
66
|
}
|
|
66
67
|
return {};
|
|
67
68
|
},
|
|
69
|
+
|
|
70
|
+
configureWebpack() {
|
|
71
|
+
// TODO Docusaurus v4: remove after dropping DocSearch v3 support
|
|
72
|
+
if (docSearchV3) {
|
|
73
|
+
// These aliases ensure DocSearch v3 imports are compatible with
|
|
74
|
+
// the newly added DocSearch v4 entry points
|
|
75
|
+
// See https://github.com/algolia/docsearch/pull/2764
|
|
76
|
+
const docSearchV3Entry = require.resolve('@docsearch/react');
|
|
77
|
+
return {
|
|
78
|
+
resolve: {
|
|
79
|
+
alias: {
|
|
80
|
+
'@docsearch/react/version': docSearchV3Entry,
|
|
81
|
+
'@docsearch/react/useDocSearchKeyboardEvents': docSearchV3Entry,
|
|
82
|
+
'@docsearch/react/useTheme': docSearchV3Entry,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
},
|
|
68
89
|
};
|
|
69
90
|
}
|
|
70
91
|
|
|
@@ -13,7 +13,8 @@ import React, {
|
|
|
13
13
|
type ReactNode,
|
|
14
14
|
} from 'react';
|
|
15
15
|
import {createPortal} from 'react-dom';
|
|
16
|
-
import {DocSearchButton
|
|
16
|
+
import {DocSearchButton} from '@docsearch/react/button';
|
|
17
|
+
import {useDocSearchKeyboardEvents} from '@docsearch/react/useDocSearchKeyboardEvents';
|
|
17
18
|
import Head from '@docusaurus/Head';
|
|
18
19
|
import Link from '@docusaurus/Link';
|
|
19
20
|
import {useHistory} from '@docusaurus/router';
|
|
@@ -73,9 +74,7 @@ function importDocSearchModalIfNeeded() {
|
|
|
73
74
|
return Promise.resolve();
|
|
74
75
|
}
|
|
75
76
|
return Promise.all([
|
|
76
|
-
import('@docsearch/react/modal')
|
|
77
|
-
typeof import('@docsearch/react')
|
|
78
|
-
>,
|
|
77
|
+
import('@docsearch/react/modal'),
|
|
79
78
|
import('@docsearch/react/style'),
|
|
80
79
|
import('./styles.css'),
|
|
81
80
|
]).then(([{DocSearchModal: Modal}]) => {
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
// TODO Docusaurus v4: remove after we drop support for DocSearch v3
|
|
9
|
+
declare module '@docsearch/react/button';
|
|
10
|
+
declare module '@docsearch/react/useDocSearchKeyboardEvents';
|
|
11
|
+
declare module '@docsearch/react/version';
|
|
12
|
+
|
|
8
13
|
declare module '@docusaurus/theme-search-algolia' {
|
|
9
14
|
import type {DeepPartial, Overwrite} from 'utility-types';
|
|
10
15
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import {escapeRegexp} from '@docusaurus/utils';
|
|
9
9
|
import {Joi} from '@docusaurus/utils-validation';
|
|
10
|
-
import {
|
|
10
|
+
import {docSearchV3} from './docSearchVersion';
|
|
11
11
|
import type {ThemeConfigValidationContext} from '@docusaurus/types';
|
|
12
12
|
import type {
|
|
13
13
|
ThemeConfig,
|
|
@@ -123,9 +123,10 @@ export const Schema = Joi.object<ThemeConfig>({
|
|
|
123
123
|
.unknown(),
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
// TODO Docusaurus v4: remove this check when we drop DocSearch v3
|
|
126
127
|
function ensureAskAISupported(themeConfig: ThemeConfig) {
|
|
127
128
|
// enforce DocsSearch v4 requirement when AskAI is configured
|
|
128
|
-
if (themeConfig.algolia.askAi &&
|
|
129
|
+
if (themeConfig.algolia.askAi && docSearchV3) {
|
|
129
130
|
throw new Error(
|
|
130
131
|
'The askAi feature is only supported in DocSearch v4. ' +
|
|
131
132
|
'Please upgrade to DocSearch v4 by installing "@docsearch/react": "^4.0.0" ' +
|