@docusaurus/theme-search-algolia 0.0.0-4379 → 0.0.0-4391
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.d.ts +2 -4
- package/lib/index.js +3 -9
- package/lib/theme/SearchMetadata/index.d.ts +3 -2
- package/lib/theme/SearchMetadata/index.js +1 -1
- package/package.json +11 -10
- package/src/index.ts +4 -14
- package/src/theme/SearchMetadata/index.tsx +2 -6
- package/src/theme-search-algolia.d.ts +16 -11
package/lib/index.d.ts
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
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 {
|
|
8
|
-
export default function
|
|
9
|
-
baseUrl: string;
|
|
10
|
-
}): Plugin<void>;
|
|
7
|
+
import type { LoadContext, Plugin } from '@docusaurus/types';
|
|
8
|
+
export default function themeSearchAlgolia(context: LoadContext): Plugin<void>;
|
|
11
9
|
export { validateThemeConfig } from './validateThemeConfig';
|
package/lib/index.js
CHANGED
|
@@ -22,16 +22,10 @@ function renderOpenSearchTemplate(data) {
|
|
|
22
22
|
return compiled(data, eta_1.defaultConfig);
|
|
23
23
|
}
|
|
24
24
|
const OPEN_SEARCH_FILENAME = 'opensearch.xml';
|
|
25
|
-
function
|
|
25
|
+
function themeSearchAlgolia(context) {
|
|
26
26
|
const { baseUrl, siteConfig: { title, url, favicon }, i18n: { currentLocale }, } = context;
|
|
27
|
-
const pageComponent = './theme/SearchPage/index.js';
|
|
28
|
-
const pagePath = (0, utils_1.getSwizzledComponent)(pageComponent) ||
|
|
29
|
-
path_1.default.resolve(__dirname, pageComponent);
|
|
30
27
|
return {
|
|
31
28
|
name: 'docusaurus-theme-search-algolia',
|
|
32
|
-
getPathsToWatch() {
|
|
33
|
-
return [pagePath];
|
|
34
|
-
},
|
|
35
29
|
getThemePath() {
|
|
36
30
|
return path_1.default.resolve(__dirname, './theme');
|
|
37
31
|
},
|
|
@@ -47,7 +41,7 @@ function theme(context) {
|
|
|
47
41
|
async contentLoaded({ actions: { addRoute } }) {
|
|
48
42
|
addRoute({
|
|
49
43
|
path: (0, utils_1.normalizeUrl)([baseUrl, 'search']),
|
|
50
|
-
component:
|
|
44
|
+
component: '@theme/SearchPage',
|
|
51
45
|
exact: true,
|
|
52
46
|
});
|
|
53
47
|
},
|
|
@@ -81,6 +75,6 @@ function theme(context) {
|
|
|
81
75
|
},
|
|
82
76
|
};
|
|
83
77
|
}
|
|
84
|
-
exports.default =
|
|
78
|
+
exports.default = themeSearchAlgolia;
|
|
85
79
|
var validateThemeConfig_1 = require("./validateThemeConfig");
|
|
86
80
|
Object.defineProperty(exports, "validateThemeConfig", { enumerable: true, get: function () { return validateThemeConfig_1.validateThemeConfig; } });
|
|
@@ -4,7 +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
|
+
/// <reference types="@docusaurus/theme-classic" />
|
|
7
8
|
/// <reference types="react" />
|
|
8
|
-
import type {
|
|
9
|
-
declare function SearchMetadata({ locale, version, tag
|
|
9
|
+
import type { Props } from '@theme/SearchMetadata';
|
|
10
|
+
declare function SearchMetadata({ locale, version, tag }: Props): JSX.Element;
|
|
10
11
|
export default SearchMetadata;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import Head from '@docusaurus/Head';
|
|
9
9
|
// Override default/agnostic SearchMetas to use Algolia-specific metadata
|
|
10
|
-
function SearchMetadata({ locale, version, tag
|
|
10
|
+
function SearchMetadata({ locale, version, tag }) {
|
|
11
11
|
// Seems safe to consider here the locale is the language,
|
|
12
12
|
// as the existing docsearch:language filter is afaik a regular string-based filter
|
|
13
13
|
const language = locale;
|
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-4391",
|
|
4
4
|
"description": "Algolia search component for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -25,21 +25,22 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@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-
|
|
28
|
+
"@docusaurus/core": "0.0.0-4391",
|
|
29
|
+
"@docusaurus/logger": "0.0.0-4391",
|
|
30
|
+
"@docusaurus/theme-common": "0.0.0-4391",
|
|
31
|
+
"@docusaurus/theme-translations": "0.0.0-4391",
|
|
32
|
+
"@docusaurus/utils": "0.0.0-4391",
|
|
33
|
+
"@docusaurus/utils-validation": "0.0.0-4391",
|
|
34
34
|
"algoliasearch": "^4.10.5",
|
|
35
35
|
"algoliasearch-helper": "^3.5.5",
|
|
36
36
|
"clsx": "^1.1.1",
|
|
37
37
|
"eta": "^1.12.3",
|
|
38
38
|
"lodash": "^4.17.20",
|
|
39
|
-
"tslib": "^2.3.1"
|
|
39
|
+
"tslib": "^2.3.1",
|
|
40
|
+
"utility-types": "^3.10.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
43
|
+
"@docusaurus/module-type-aliases": "0.0.0-4391",
|
|
43
44
|
"fs-extra": "^10.0.0"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"engines": {
|
|
50
51
|
"node": ">=14"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "16a313077f39acf0b712f20b277d92a94d7393ac"
|
|
53
54
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import fs from 'fs';
|
|
10
10
|
import {defaultConfig, compile} from 'eta';
|
|
11
|
-
import {normalizeUrl
|
|
11
|
+
import {normalizeUrl} from '@docusaurus/utils';
|
|
12
12
|
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
|
|
13
13
|
import logger from '@docusaurus/logger';
|
|
14
14
|
import openSearchTemplate from './templates/opensearch';
|
|
15
15
|
import {memoize} from 'lodash';
|
|
16
16
|
|
|
17
|
-
import type {
|
|
17
|
+
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
18
18
|
|
|
19
19
|
const getCompiledOpenSearchTemplate = memoize(() =>
|
|
20
20
|
compile(openSearchTemplate.trim()),
|
|
@@ -31,26 +31,16 @@ function renderOpenSearchTemplate(data: {
|
|
|
31
31
|
|
|
32
32
|
const OPEN_SEARCH_FILENAME = 'opensearch.xml';
|
|
33
33
|
|
|
34
|
-
export default function
|
|
35
|
-
context: DocusaurusContext & {baseUrl: string},
|
|
36
|
-
): Plugin<void> {
|
|
34
|
+
export default function themeSearchAlgolia(context: LoadContext): Plugin<void> {
|
|
37
35
|
const {
|
|
38
36
|
baseUrl,
|
|
39
37
|
siteConfig: {title, url, favicon},
|
|
40
38
|
i18n: {currentLocale},
|
|
41
39
|
} = context;
|
|
42
|
-
const pageComponent = './theme/SearchPage/index.js';
|
|
43
|
-
const pagePath =
|
|
44
|
-
getSwizzledComponent(pageComponent) ||
|
|
45
|
-
path.resolve(__dirname, pageComponent);
|
|
46
40
|
|
|
47
41
|
return {
|
|
48
42
|
name: 'docusaurus-theme-search-algolia',
|
|
49
43
|
|
|
50
|
-
getPathsToWatch() {
|
|
51
|
-
return [pagePath];
|
|
52
|
-
},
|
|
53
|
-
|
|
54
44
|
getThemePath() {
|
|
55
45
|
return path.resolve(__dirname, './theme');
|
|
56
46
|
},
|
|
@@ -69,7 +59,7 @@ export default function theme(
|
|
|
69
59
|
async contentLoaded({actions: {addRoute}}) {
|
|
70
60
|
addRoute({
|
|
71
61
|
path: normalizeUrl([baseUrl, 'search']),
|
|
72
|
-
component:
|
|
62
|
+
component: '@theme/SearchPage',
|
|
73
63
|
exact: true,
|
|
74
64
|
});
|
|
75
65
|
},
|
|
@@ -8,14 +8,10 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
10
|
import Head from '@docusaurus/Head';
|
|
11
|
-
import type {
|
|
11
|
+
import type {Props} from '@theme/SearchMetadata';
|
|
12
12
|
|
|
13
13
|
// Override default/agnostic SearchMetas to use Algolia-specific metadata
|
|
14
|
-
function SearchMetadata({
|
|
15
|
-
locale,
|
|
16
|
-
version,
|
|
17
|
-
tag,
|
|
18
|
-
}: SearchMetadataProps): JSX.Element {
|
|
14
|
+
function SearchMetadata({locale, version, tag}: Props): JSX.Element {
|
|
19
15
|
// Seems safe to consider here the locale is the language,
|
|
20
16
|
// as the existing docsearch:language filter is afaik a regular string-based filter
|
|
21
17
|
const language = locale;
|
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
declare module '@docusaurus/theme-search-algolia' {
|
|
9
|
+
import type {DeepPartial} from 'utility-types';
|
|
10
|
+
|
|
11
|
+
export type ThemeConfig = {
|
|
12
|
+
algolia: {
|
|
13
|
+
contextualSearch: boolean;
|
|
14
|
+
externalUrlRegex?: string;
|
|
15
|
+
appId: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
indexName: string;
|
|
18
|
+
searchParameters: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type UserThemeConfig = DeepPartial<ThemeConfig>;
|
|
22
|
+
}
|
|
23
|
+
|
|
8
24
|
declare module '@docusaurus/theme-search-algolia/client' {
|
|
9
25
|
export function useAlgoliaContextualFacetFilters(): [string, string[]];
|
|
10
26
|
}
|
|
@@ -14,17 +30,6 @@ declare module '@theme/SearchPage' {
|
|
|
14
30
|
export default SearchPage;
|
|
15
31
|
}
|
|
16
32
|
|
|
17
|
-
declare module '@theme/SearchMetadata' {
|
|
18
|
-
export type SearchMetadataProps = {
|
|
19
|
-
readonly locale?: string;
|
|
20
|
-
readonly version?: string;
|
|
21
|
-
readonly tag?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const SearchMetadata: (props: SearchMetadataProps) => JSX.Element;
|
|
25
|
-
export default SearchMetadata;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
33
|
declare module '@theme/SearchBar' {
|
|
29
34
|
const SearchBar: () => JSX.Element;
|
|
30
35
|
export default SearchBar;
|