@docusaurus/theme-search-algolia 0.0.0-4527 → 0.0.0-4536
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/index.js +1 -1
- package/lib/client/useAlgoliaContextualFacetFilters.js +6 -6
- package/lib/index.js +84 -67
- package/lib/templates/opensearch.js +2 -2
- package/lib/theme/SearchBar/index.js +176 -120
- package/lib/theme/SearchMetadata/index.js +11 -9
- package/lib/theme/SearchPage/index.js +380 -220
- package/lib/validateThemeConfig.js +31 -27
- package/package.json +13 -12
- package/src/theme/SearchBar/index.tsx +2 -2
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
/**
|
|
3
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
Object.defineProperty(exports,
|
|
8
|
+
Object.defineProperty(exports, '__esModule', {value: true});
|
|
9
9
|
exports.validateThemeConfig = exports.Schema = exports.DEFAULT_CONFIG = void 0;
|
|
10
|
-
const utils_validation_1 = require(
|
|
10
|
+
const utils_validation_1 = require('@docusaurus/utils-validation');
|
|
11
11
|
exports.DEFAULT_CONFIG = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
// enabled by default, as it makes sense in most cases
|
|
13
|
+
// see also https://github.com/facebook/docusaurus/issues/5880
|
|
14
|
+
contextualSearch: true,
|
|
15
|
+
// By default, all Docusaurus sites are using the same AppId
|
|
16
|
+
// This has been designed on purpose with Algolia.
|
|
17
|
+
appId: 'BH4D9OD16A',
|
|
18
|
+
searchParameters: {},
|
|
19
19
|
};
|
|
20
20
|
exports.Schema = utils_validation_1.Joi.object({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
algolia: utils_validation_1.Joi.object({
|
|
22
|
+
// Docusaurus attributes
|
|
23
|
+
contextualSearch: utils_validation_1.Joi.boolean().default(
|
|
24
|
+
exports.DEFAULT_CONFIG.contextualSearch,
|
|
25
|
+
),
|
|
26
|
+
externalUrlRegex: utils_validation_1.Joi.string().optional(),
|
|
27
|
+
// Algolia attributes
|
|
28
|
+
appId: utils_validation_1.Joi.string().default(
|
|
29
|
+
exports.DEFAULT_CONFIG.appId,
|
|
30
|
+
),
|
|
31
|
+
apiKey: utils_validation_1.Joi.string().required(),
|
|
32
|
+
indexName: utils_validation_1.Joi.string().required(),
|
|
33
|
+
searchParameters: utils_validation_1.Joi.object()
|
|
34
|
+
.default(exports.DEFAULT_CONFIG.searchParameters)
|
|
35
|
+
.unknown(),
|
|
36
|
+
})
|
|
37
|
+
.label('themeConfig.algolia')
|
|
38
|
+
.required()
|
|
39
|
+
.unknown(), // DocSearch 3 is still alpha: don't validate the rest for now
|
|
36
40
|
});
|
|
37
|
-
function validateThemeConfig({
|
|
38
|
-
|
|
41
|
+
function validateThemeConfig({validate, themeConfig}) {
|
|
42
|
+
return validate(exports.Schema, themeConfig);
|
|
39
43
|
}
|
|
40
44
|
exports.validateThemeConfig = validateThemeConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-search-algolia",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4536",
|
|
4
4
|
"description": "Algolia search component for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -18,19 +18,20 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "yarn build:server && yarn build:
|
|
21
|
+
"build": "yarn build:server && yarn build:client && yarn build:copy && yarn build:format",
|
|
22
22
|
"build:server": "tsc --project tsconfig.server.json",
|
|
23
|
-
"build:
|
|
24
|
-
"build:copy": "node copyUntypedFiles.mjs"
|
|
23
|
+
"build:client": "tsc --project tsconfig.client.json",
|
|
24
|
+
"build:copy": "node copyUntypedFiles.mjs",
|
|
25
|
+
"build:format": "prettier --config ../../.prettierrc --write \"lib/**/*.js\""
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@docsearch/react": "^3.0.0-alpha.39",
|
|
28
|
-
"@docusaurus/core": "0.0.0-
|
|
29
|
-
"@docusaurus/logger": "0.0.0-
|
|
30
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
31
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
32
|
-
"@docusaurus/utils": "0.0.0-
|
|
33
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
29
|
+
"@docusaurus/core": "0.0.0-4536",
|
|
30
|
+
"@docusaurus/logger": "0.0.0-4536",
|
|
31
|
+
"@docusaurus/theme-common": "0.0.0-4536",
|
|
32
|
+
"@docusaurus/theme-translations": "0.0.0-4536",
|
|
33
|
+
"@docusaurus/utils": "0.0.0-4536",
|
|
34
|
+
"@docusaurus/utils-validation": "0.0.0-4536",
|
|
34
35
|
"algoliasearch": "^4.10.5",
|
|
35
36
|
"algoliasearch-helper": "^3.5.5",
|
|
36
37
|
"clsx": "^1.1.1",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"utility-types": "^3.10.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
44
|
+
"@docusaurus/module-type-aliases": "0.0.0-4536",
|
|
44
45
|
"fs-extra": "^10.0.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"engines": {
|
|
54
55
|
"node": ">=14"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "a9d652056b10bf55db1bc1392672752a8b6250a7"
|
|
57
58
|
}
|
|
@@ -74,8 +74,8 @@ type FacetFilters = Required<
|
|
|
74
74
|
function mergeFacetFilters(f1: FacetFilters, f2: FacetFilters): FacetFilters {
|
|
75
75
|
const normalize = (
|
|
76
76
|
f: FacetFilters,
|
|
77
|
-
): readonly string[] | ReadonlyArray<readonly string[]> =>
|
|
78
|
-
f
|
|
77
|
+
): readonly string[] | ReadonlyArray<string | readonly string[]> =>
|
|
78
|
+
typeof f === 'string' ? [f] : f;
|
|
79
79
|
return [...normalize(f1), ...normalize(f2)] as FacetFilters;
|
|
80
80
|
}
|
|
81
81
|
|