@docusaurus/theme-search-algolia 0.0.0-5957 → 0.0.0-5962
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/theme/SearchPage/index.js +19 -13
- package/package.json +10 -10
- package/src/theme/SearchPage/index.tsx +22 -14
|
@@ -119,7 +119,7 @@ function SearchPageContent() {
|
|
|
119
119
|
i18n: {currentLocale},
|
|
120
120
|
} = useDocusaurusContext();
|
|
121
121
|
const {
|
|
122
|
-
algolia: {appId, apiKey, indexName},
|
|
122
|
+
algolia: {appId, apiKey, indexName, contextualSearch},
|
|
123
123
|
} = useAlgoliaThemeConfig();
|
|
124
124
|
const processSearchResultUrl = useSearchResultUrlProcessor();
|
|
125
125
|
const documentsFoundPlural = useDocumentsFoundPlural();
|
|
@@ -169,11 +169,15 @@ function SearchPageContent() {
|
|
|
169
169
|
},
|
|
170
170
|
initialSearchResultState,
|
|
171
171
|
);
|
|
172
|
+
// respect settings from the theme config for facets
|
|
173
|
+
const disjunctiveFacets = contextualSearch
|
|
174
|
+
? ['language', 'docusaurus_tag']
|
|
175
|
+
: [];
|
|
172
176
|
const algoliaClient = algoliaSearch(appId, apiKey);
|
|
173
177
|
const algoliaHelper = algoliaSearchHelper(algoliaClient, indexName, {
|
|
174
178
|
hitsPerPage: 15,
|
|
175
179
|
advancedSyntax: true,
|
|
176
|
-
disjunctiveFacets
|
|
180
|
+
disjunctiveFacets,
|
|
177
181
|
});
|
|
178
182
|
algoliaHelper.on(
|
|
179
183
|
'result',
|
|
@@ -256,16 +260,18 @@ function SearchPageContent() {
|
|
|
256
260
|
description: 'The search page title for empty query',
|
|
257
261
|
});
|
|
258
262
|
const makeSearch = useEvent((page = 0) => {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
if (contextualSearch) {
|
|
264
|
+
algoliaHelper.addDisjunctiveFacetRefinement('docusaurus_tag', 'default');
|
|
265
|
+
algoliaHelper.addDisjunctiveFacetRefinement('language', currentLocale);
|
|
266
|
+
Object.entries(docsSearchVersionsHelpers.searchVersions).forEach(
|
|
267
|
+
([pluginId, searchVersion]) => {
|
|
268
|
+
algoliaHelper.addDisjunctiveFacetRefinement(
|
|
269
|
+
'docusaurus_tag',
|
|
270
|
+
`docs-${pluginId}-${searchVersion}`,
|
|
271
|
+
);
|
|
272
|
+
},
|
|
273
|
+
);
|
|
274
|
+
}
|
|
269
275
|
algoliaHelper.setQuery(searchQuery).setPage(page).search();
|
|
270
276
|
});
|
|
271
277
|
useEffect(() => {
|
|
@@ -335,7 +341,7 @@ function SearchPageContent() {
|
|
|
335
341
|
/>
|
|
336
342
|
</div>
|
|
337
343
|
|
|
338
|
-
{docsSearchVersionsHelpers.versioningEnabled && (
|
|
344
|
+
{contextualSearch && docsSearchVersionsHelpers.versioningEnabled && (
|
|
339
345
|
<SearchVersionSelectList
|
|
340
346
|
docsSearchVersionsHelpers={docsSearchVersionsHelpers}
|
|
341
347
|
/>
|
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-5962",
|
|
4
4
|
"description": "Algolia search component for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": [
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@docsearch/react": "^3.5.2",
|
|
37
|
-
"@docusaurus/core": "0.0.0-
|
|
38
|
-
"@docusaurus/logger": "0.0.0-
|
|
39
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
40
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
41
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
42
|
-
"@docusaurus/utils": "0.0.0-
|
|
43
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
37
|
+
"@docusaurus/core": "0.0.0-5962",
|
|
38
|
+
"@docusaurus/logger": "0.0.0-5962",
|
|
39
|
+
"@docusaurus/plugin-content-docs": "0.0.0-5962",
|
|
40
|
+
"@docusaurus/theme-common": "0.0.0-5962",
|
|
41
|
+
"@docusaurus/theme-translations": "0.0.0-5962",
|
|
42
|
+
"@docusaurus/utils": "0.0.0-5962",
|
|
43
|
+
"@docusaurus/utils-validation": "0.0.0-5962",
|
|
44
44
|
"algoliasearch": "^4.18.0",
|
|
45
45
|
"algoliasearch-helper": "^3.13.3",
|
|
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": "0.0.0-
|
|
54
|
+
"@docusaurus/module-type-aliases": "0.0.0-5962"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "^18.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=18.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "35386a1d384d8e8757ef9f993b84dd5accc00e97"
|
|
64
64
|
}
|
|
@@ -159,8 +159,9 @@ function SearchPageContent(): JSX.Element {
|
|
|
159
159
|
i18n: {currentLocale},
|
|
160
160
|
} = useDocusaurusContext();
|
|
161
161
|
const {
|
|
162
|
-
algolia: {appId, apiKey, indexName},
|
|
162
|
+
algolia: {appId, apiKey, indexName, contextualSearch},
|
|
163
163
|
} = useAlgoliaThemeConfig();
|
|
164
|
+
|
|
164
165
|
const processSearchResultUrl = useSearchResultUrlProcessor();
|
|
165
166
|
const documentsFoundPlural = useDocumentsFoundPlural();
|
|
166
167
|
|
|
@@ -213,11 +214,16 @@ function SearchPageContent(): JSX.Element {
|
|
|
213
214
|
initialSearchResultState,
|
|
214
215
|
);
|
|
215
216
|
|
|
217
|
+
// respect settings from the theme config for facets
|
|
218
|
+
const disjunctiveFacets = contextualSearch
|
|
219
|
+
? ['language', 'docusaurus_tag']
|
|
220
|
+
: [];
|
|
221
|
+
|
|
216
222
|
const algoliaClient = algoliaSearch(appId, apiKey);
|
|
217
223
|
const algoliaHelper = algoliaSearchHelper(algoliaClient, indexName, {
|
|
218
224
|
hitsPerPage: 15,
|
|
219
225
|
advancedSyntax: true,
|
|
220
|
-
disjunctiveFacets
|
|
226
|
+
disjunctiveFacets,
|
|
221
227
|
});
|
|
222
228
|
|
|
223
229
|
algoliaHelper.on(
|
|
@@ -313,17 +319,19 @@ function SearchPageContent(): JSX.Element {
|
|
|
313
319
|
});
|
|
314
320
|
|
|
315
321
|
const makeSearch = useEvent((page: number = 0) => {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
322
|
+
if (contextualSearch) {
|
|
323
|
+
algoliaHelper.addDisjunctiveFacetRefinement('docusaurus_tag', 'default');
|
|
324
|
+
algoliaHelper.addDisjunctiveFacetRefinement('language', currentLocale);
|
|
325
|
+
|
|
326
|
+
Object.entries(docsSearchVersionsHelpers.searchVersions).forEach(
|
|
327
|
+
([pluginId, searchVersion]) => {
|
|
328
|
+
algoliaHelper.addDisjunctiveFacetRefinement(
|
|
329
|
+
'docusaurus_tag',
|
|
330
|
+
`docs-${pluginId}-${searchVersion}`,
|
|
331
|
+
);
|
|
332
|
+
},
|
|
333
|
+
);
|
|
334
|
+
}
|
|
327
335
|
|
|
328
336
|
algoliaHelper.setQuery(searchQuery).setPage(page).search();
|
|
329
337
|
});
|
|
@@ -401,7 +409,7 @@ function SearchPageContent(): JSX.Element {
|
|
|
401
409
|
/>
|
|
402
410
|
</div>
|
|
403
411
|
|
|
404
|
-
{docsSearchVersionsHelpers.versioningEnabled && (
|
|
412
|
+
{contextualSearch && docsSearchVersionsHelpers.versioningEnabled && (
|
|
405
413
|
<SearchVersionSelectList
|
|
406
414
|
docsSearchVersionsHelpers={docsSearchVersionsHelpers}
|
|
407
415
|
/>
|