@docusaurus/theme-search-algolia 2.0.0-beta.17 → 2.0.0-beta.18
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/index.js +2 -2
- package/lib/theme/SearchPage/index.js +11 -3
- package/lib/validateThemeConfig.d.ts +2 -5
- package/package.json +12 -11
- package/src/index.ts +2 -2
- package/src/theme/SearchPage/index.tsx +23 -13
- package/src/theme-search-algolia.d.ts +1 -1
- package/src/validateThemeConfig.ts +5 -5
package/lib/index.js
CHANGED
|
@@ -36,10 +36,10 @@ function themeSearchAlgolia(context) {
|
|
|
36
36
|
return {
|
|
37
37
|
name: 'docusaurus-theme-search-algolia',
|
|
38
38
|
getThemePath() {
|
|
39
|
-
return
|
|
39
|
+
return '../lib/theme';
|
|
40
40
|
},
|
|
41
41
|
getTypeScriptThemePath() {
|
|
42
|
-
return
|
|
42
|
+
return '../src/theme';
|
|
43
43
|
},
|
|
44
44
|
getDefaultCodeTranslationMessages() {
|
|
45
45
|
return (0, theme_translations_1.readDefaultCodeTranslationMessages)({
|
|
@@ -13,6 +13,7 @@ import Head from '@docusaurus/Head';
|
|
|
13
13
|
import Link from '@docusaurus/Link';
|
|
14
14
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
15
15
|
import {
|
|
16
|
+
HtmlClassNameProvider,
|
|
16
17
|
useTitleFormatter,
|
|
17
18
|
usePluralForm,
|
|
18
19
|
isRegexpStringMatch,
|
|
@@ -109,7 +110,7 @@ function SearchVersionSelectList({docsSearchVersionsHelpers}) {
|
|
|
109
110
|
</div>
|
|
110
111
|
);
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
function SearchPageContent() {
|
|
113
114
|
const {
|
|
114
115
|
siteConfig: {themeConfig},
|
|
115
116
|
i18n: {currentLocale},
|
|
@@ -173,7 +174,7 @@ export default function SearchPage() {
|
|
|
173
174
|
algoliaHelper.on(
|
|
174
175
|
'result',
|
|
175
176
|
({results: {query, hits, page, nbHits, nbPages}}) => {
|
|
176
|
-
if (query === '' || !(hits
|
|
177
|
+
if (query === '' || !Array.isArray(hits)) {
|
|
177
178
|
searchResultStateDispatcher({type: 'reset'});
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
@@ -293,7 +294,7 @@ export default function SearchPage() {
|
|
|
293
294
|
makeSearch(searchResultState.lastPage);
|
|
294
295
|
}, [makeSearch, searchResultState.lastPage]);
|
|
295
296
|
return (
|
|
296
|
-
<Layout
|
|
297
|
+
<Layout>
|
|
297
298
|
<Head>
|
|
298
299
|
<title>{useTitleFormatter(getTitle())}</title>
|
|
299
300
|
{/*
|
|
@@ -453,3 +454,10 @@ export default function SearchPage() {
|
|
|
453
454
|
</Layout>
|
|
454
455
|
);
|
|
455
456
|
}
|
|
457
|
+
export default function SearchPage() {
|
|
458
|
+
return (
|
|
459
|
+
<HtmlClassNameProvider className="search-page-wrapper">
|
|
460
|
+
<SearchPageContent />
|
|
461
|
+
</HtmlClassNameProvider>
|
|
462
|
+
);
|
|
463
|
+
}
|
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { Joi } from '@docusaurus/utils-validation';
|
|
8
|
-
import type { ThemeConfig,
|
|
8
|
+
import type { ThemeConfig, ThemeConfigValidationContext } from '@docusaurus/types';
|
|
9
9
|
export declare const DEFAULT_CONFIG: {
|
|
10
10
|
contextualSearch: boolean;
|
|
11
11
|
searchParameters: {};
|
|
12
12
|
searchPagePath: string;
|
|
13
13
|
};
|
|
14
14
|
export declare const Schema: Joi.ObjectSchema<any>;
|
|
15
|
-
export declare function validateThemeConfig({ validate, themeConfig, }:
|
|
16
|
-
validate: Validate<ThemeConfig>;
|
|
17
|
-
themeConfig: ThemeConfig;
|
|
18
|
-
}): ValidationResult<ThemeConfig>;
|
|
15
|
+
export declare function validateThemeConfig({ validate, themeConfig, }: ThemeConfigValidationContext<ThemeConfig>): ThemeConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-search-algolia",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.18",
|
|
4
4
|
"description": "Algolia search component for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@docsearch/react": "^3.0.0",
|
|
29
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
30
|
-
"@docusaurus/logger": "2.0.0-beta.
|
|
31
|
-
"@docusaurus/
|
|
32
|
-
"@docusaurus/theme-
|
|
33
|
-
"@docusaurus/
|
|
34
|
-
"@docusaurus/utils
|
|
35
|
-
"
|
|
36
|
-
"algoliasearch
|
|
29
|
+
"@docusaurus/core": "2.0.0-beta.18",
|
|
30
|
+
"@docusaurus/logger": "2.0.0-beta.18",
|
|
31
|
+
"@docusaurus/plugin-content-docs": "2.0.0-beta.18",
|
|
32
|
+
"@docusaurus/theme-common": "2.0.0-beta.18",
|
|
33
|
+
"@docusaurus/theme-translations": "2.0.0-beta.18",
|
|
34
|
+
"@docusaurus/utils": "2.0.0-beta.18",
|
|
35
|
+
"@docusaurus/utils-validation": "2.0.0-beta.18",
|
|
36
|
+
"algoliasearch": "^4.13.0",
|
|
37
|
+
"algoliasearch-helper": "^3.7.4",
|
|
37
38
|
"clsx": "^1.1.1",
|
|
38
39
|
"eta": "^1.12.3",
|
|
39
40
|
"fs-extra": "^10.0.1",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"utility-types": "^3.10.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
46
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.18"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -51,5 +52,5 @@
|
|
|
51
52
|
"engines": {
|
|
52
53
|
"node": ">=14"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "1a945d06993d53376e61bed2c942799fe07dc336"
|
|
55
56
|
}
|
package/src/index.ts
CHANGED
|
@@ -47,10 +47,10 @@ export default function themeSearchAlgolia(context: LoadContext): Plugin<void> {
|
|
|
47
47
|
name: 'docusaurus-theme-search-algolia',
|
|
48
48
|
|
|
49
49
|
getThemePath() {
|
|
50
|
-
return
|
|
50
|
+
return '../lib/theme';
|
|
51
51
|
},
|
|
52
52
|
getTypeScriptThemePath() {
|
|
53
|
-
return
|
|
53
|
+
return '../src/theme';
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
getDefaultCodeTranslationMessages() {
|
|
@@ -17,6 +17,7 @@ import Head from '@docusaurus/Head';
|
|
|
17
17
|
import Link from '@docusaurus/Link';
|
|
18
18
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
19
19
|
import {
|
|
20
|
+
HtmlClassNameProvider,
|
|
20
21
|
useTitleFormatter,
|
|
21
22
|
usePluralForm,
|
|
22
23
|
isRegexpStringMatch,
|
|
@@ -53,15 +54,16 @@ function useDocsSearchVersionsHelpers() {
|
|
|
53
54
|
|
|
54
55
|
// State of the version select menus / algolia facet filters
|
|
55
56
|
// docsPluginId -> versionName map
|
|
56
|
-
const [searchVersions, setSearchVersions] = useState<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
const [searchVersions, setSearchVersions] = useState<{
|
|
58
|
+
[pluginId: string]: string;
|
|
59
|
+
}>(() =>
|
|
60
|
+
Object.entries(allDocsData).reduce(
|
|
61
|
+
(acc, [pluginId, pluginData]) => ({
|
|
62
|
+
...acc,
|
|
63
|
+
[pluginId]: pluginData.versions[0]!.name,
|
|
64
|
+
}),
|
|
65
|
+
{},
|
|
66
|
+
),
|
|
65
67
|
);
|
|
66
68
|
|
|
67
69
|
// Set the value of a single select menu
|
|
@@ -149,7 +151,7 @@ type ResultDispatcher =
|
|
|
149
151
|
| {type: 'update'; value: ResultDispatcherState}
|
|
150
152
|
| {type: 'advance'; value?: undefined};
|
|
151
153
|
|
|
152
|
-
|
|
154
|
+
function SearchPageContent(): JSX.Element {
|
|
153
155
|
const {
|
|
154
156
|
siteConfig: {themeConfig},
|
|
155
157
|
i18n: {currentLocale},
|
|
@@ -218,7 +220,7 @@ export default function SearchPage(): JSX.Element {
|
|
|
218
220
|
algoliaHelper.on(
|
|
219
221
|
'result',
|
|
220
222
|
({results: {query, hits, page, nbHits, nbPages}}) => {
|
|
221
|
-
if (query === '' || !(hits
|
|
223
|
+
if (query === '' || !Array.isArray(hits)) {
|
|
222
224
|
searchResultStateDispatcher({type: 'reset'});
|
|
223
225
|
return;
|
|
224
226
|
}
|
|
@@ -277,7 +279,7 @@ export default function SearchPage(): JSX.Element {
|
|
|
277
279
|
const {
|
|
278
280
|
isIntersecting,
|
|
279
281
|
boundingClientRect: {y: currentY},
|
|
280
|
-
} = entries[0]
|
|
282
|
+
} = entries[0]!;
|
|
281
283
|
|
|
282
284
|
if (isIntersecting && prevY.current > currentY) {
|
|
283
285
|
searchResultStateDispatcher({type: 'advance'});
|
|
@@ -356,7 +358,7 @@ export default function SearchPage(): JSX.Element {
|
|
|
356
358
|
}, [makeSearch, searchResultState.lastPage]);
|
|
357
359
|
|
|
358
360
|
return (
|
|
359
|
-
<Layout
|
|
361
|
+
<Layout>
|
|
360
362
|
<Head>
|
|
361
363
|
<title>{useTitleFormatter(getTitle())}</title>
|
|
362
364
|
{/*
|
|
@@ -516,3 +518,11 @@ export default function SearchPage(): JSX.Element {
|
|
|
516
518
|
</Layout>
|
|
517
519
|
);
|
|
518
520
|
}
|
|
521
|
+
|
|
522
|
+
export default function SearchPage(): JSX.Element {
|
|
523
|
+
return (
|
|
524
|
+
<HtmlClassNameProvider className="search-page-wrapper">
|
|
525
|
+
<SearchPageContent />
|
|
526
|
+
</HtmlClassNameProvider>
|
|
527
|
+
);
|
|
528
|
+
}
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {Joi} from '@docusaurus/utils-validation';
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
ThemeConfig,
|
|
11
|
+
ThemeConfigValidationContext,
|
|
12
|
+
} from '@docusaurus/types';
|
|
10
13
|
|
|
11
14
|
export const DEFAULT_CONFIG = {
|
|
12
15
|
// enabled by default, as it makes sense in most cases
|
|
@@ -45,9 +48,6 @@ export const Schema = Joi.object({
|
|
|
45
48
|
export function validateThemeConfig({
|
|
46
49
|
validate,
|
|
47
50
|
themeConfig,
|
|
48
|
-
}: {
|
|
49
|
-
validate: Validate<ThemeConfig>;
|
|
50
|
-
themeConfig: ThemeConfig;
|
|
51
|
-
}): ValidationResult<ThemeConfig> {
|
|
51
|
+
}: ThemeConfigValidationContext<ThemeConfig>): ThemeConfig {
|
|
52
52
|
return validate(Schema, themeConfig);
|
|
53
53
|
}
|