@easyops-cn/docusaurus-search-local 0.30.0 → 0.30.1
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/CHANGELOG.md +7 -0
- package/dist/client/client/theme/SearchBar/SearchBar.jsx +9 -7
- package/dist/client/client/theme/SearchPage/SearchPage.jsx +9 -7
- package/dist/client/client/utils/__mocks__/proxiedGenerated.js +1 -0
- package/dist/server/server/utils/generate.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.30.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.30.0...v0.30.1) (2022-07-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* fix building error when docs disabled ([07b1724](https://github.com/easyops-cn/docusaurus-search-local/commit/07b17245ff526783dfc1469de91928d5a64bb909))
|
|
11
|
+
|
|
5
12
|
## [0.30.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.29.4...v0.30.0) (2022-07-22)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -10,7 +10,7 @@ import { fetchIndexes } from "./fetchIndexes";
|
|
|
10
10
|
import { SearchSourceFactory } from "../../utils/SearchSourceFactory";
|
|
11
11
|
import { SuggestionTemplate } from "./SuggestionTemplate";
|
|
12
12
|
import { EmptyTemplate } from "./EmptyTemplate";
|
|
13
|
-
import { searchResultLimits, Mark, searchBarShortcut, searchBarShortcutHint, docsPluginIdForPreferredVersion, } from "../../utils/proxiedGenerated";
|
|
13
|
+
import { searchResultLimits, Mark, searchBarShortcut, searchBarShortcutHint, docsPluginIdForPreferredVersion, indexDocs, } from "../../utils/proxiedGenerated";
|
|
14
14
|
import LoadingRing from "../LoadingRing/LoadingRing";
|
|
15
15
|
import styles from "./SearchBar.module.css";
|
|
16
16
|
async function fetchAutoCompleteJS() {
|
|
@@ -47,12 +47,14 @@ export default function SearchBar({ handleSearchBarToggle, }) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
catch (e) {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
if (indexDocs) {
|
|
51
|
+
if (e instanceof ReactContextError) {
|
|
52
|
+
console.error("useDocsPreferredVersion", e);
|
|
53
|
+
/* ignore, happens when website doesn't use versions */
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
const history = useHistory();
|
|
@@ -14,7 +14,7 @@ import { highlightStemmed } from "../../utils/highlightStemmed";
|
|
|
14
14
|
import { getStemmedPositions } from "../../utils/getStemmedPositions";
|
|
15
15
|
import LoadingRing from "../LoadingRing/LoadingRing";
|
|
16
16
|
import { concatDocumentPath } from "../../utils/concatDocumentPath";
|
|
17
|
-
import { docsPluginIdForPreferredVersion } from "../../utils/proxiedGenerated";
|
|
17
|
+
import { docsPluginIdForPreferredVersion, indexDocs, } from "../../utils/proxiedGenerated";
|
|
18
18
|
import styles from "./SearchPage.module.css";
|
|
19
19
|
export default function SearchPage() {
|
|
20
20
|
return (<Layout>
|
|
@@ -38,12 +38,14 @@ function SearchPageContent() {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
if (indexDocs) {
|
|
42
|
+
if (e instanceof ReactContextError) {
|
|
43
|
+
console.error("useDocsPreferredVersion", e);
|
|
44
|
+
/* ignore, happens when website doesn't use versions */
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
const { selectMessage } = usePluralForm();
|
|
@@ -6,6 +6,7 @@ export const searchResultLimits = 8;
|
|
|
6
6
|
export const searchResultContextMaxLength = 50;
|
|
7
7
|
export const explicitSearchResultPath = false;
|
|
8
8
|
export const docsPluginIdForPreferredVersion = undefined;
|
|
9
|
+
export const indexDocs = true;
|
|
9
10
|
export function __setLanguage(value) {
|
|
10
11
|
language = value;
|
|
11
12
|
}
|
|
@@ -6,7 +6,7 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const getIndexHash_1 = require("./getIndexHash");
|
|
8
8
|
function generate(config, dir) {
|
|
9
|
-
const { language, removeDefaultStopWordFilter, removeDefaultStemmer, highlightSearchTermsOnTargetPage, searchResultLimits, searchResultContextMaxLength, explicitSearchResultPath, searchBarShortcut, searchBarShortcutHint, docsPluginIdForPreferredVersion, } = config;
|
|
9
|
+
const { language, removeDefaultStopWordFilter, removeDefaultStemmer, highlightSearchTermsOnTargetPage, searchResultLimits, searchResultContextMaxLength, explicitSearchResultPath, searchBarShortcut, searchBarShortcutHint, docsPluginIdForPreferredVersion, indexDocs, } = config;
|
|
10
10
|
const indexHash = (0, getIndexHash_1.getIndexHash)(config);
|
|
11
11
|
const contents = [
|
|
12
12
|
`import lunr from ${JSON.stringify(require.resolve("lunr"))};`,
|
|
@@ -54,6 +54,7 @@ function generate(config, dir) {
|
|
|
54
54
|
contents.push(`export const docsPluginIdForPreferredVersion = ${docsPluginIdForPreferredVersion === undefined
|
|
55
55
|
? "undefined"
|
|
56
56
|
: JSON.stringify(docsPluginIdForPreferredVersion)};`);
|
|
57
|
+
contents.push(`export const indexDocs = ${JSON.stringify(indexDocs)};`);
|
|
57
58
|
fs_1.default.writeFileSync(path_1.default.join(dir, "generated.js"), contents.join("\n"));
|
|
58
59
|
return searchIndexFilename;
|
|
59
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyops-cn/docusaurus-search-local",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "An offline/local search plugin for Docusaurus v2",
|
|
5
5
|
"repository": "https://github.com/easyops-cn/docusaurus-search-local",
|
|
6
6
|
"homepage": "https://github.com/easyops-cn/docusaurus-search-local",
|