@easyops-cn/docusaurus-search-local 0.44.2 → 0.44.4
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
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.44.4](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.3...v0.44.4) (2024-07-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* do not initialize lunr multiple times, fixes [#155](https://github.com/easyops-cn/docusaurus-search-local/issues/155) ([0b323d9](https://github.com/easyops-cn/docusaurus-search-local/commit/0b323d97fbc238692e68368582bce72908fd66b0))
|
|
11
|
+
|
|
12
|
+
## [0.44.3](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.2...v0.44.3) (2024-07-08)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* append a `/` to the search link. ([#432](https://github.com/easyops-cn/docusaurus-search-local/issues/432)) ([60c23d4](https://github.com/easyops-cn/docusaurus-search-local/commit/60c23d43c5c9b3ecc6ceb7319762a9c4acb9e32e))
|
|
18
|
+
|
|
5
19
|
## [0.44.2](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.1...v0.44.2) (2024-06-20)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -155,7 +155,7 @@ export default function SearchBar({ handleSearchBarToggle, }) {
|
|
|
155
155
|
}
|
|
156
156
|
params.set("version", versionUrl.substring(baseUrl.length));
|
|
157
157
|
}
|
|
158
|
-
const url = `${baseUrl}search
|
|
158
|
+
const url = `${baseUrl}search/?${params.toString()}`;
|
|
159
159
|
a.href = url;
|
|
160
160
|
a.textContent = linkText;
|
|
161
161
|
a.addEventListener("click", (e) => {
|
|
@@ -4,23 +4,34 @@ exports.buildIndex = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/* eslint @typescript-eslint/no-var-requires: 0 */
|
|
6
6
|
const lunr_1 = tslib_1.__importDefault(require("lunr"));
|
|
7
|
+
let pluginInitialized = false;
|
|
8
|
+
let plugin;
|
|
7
9
|
function buildIndex(allDocuments, { language, removeDefaultStopWordFilter, removeDefaultStemmer, zhUserDict, zhUserDictPath, }) {
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
if (!pluginInitialized) {
|
|
11
|
+
pluginInitialized = true;
|
|
12
|
+
if (language.length > 1 || language.some((item) => item !== "en")) {
|
|
13
|
+
require("lunr-languages/lunr.stemmer.support")(lunr_1.default);
|
|
14
|
+
}
|
|
15
|
+
if (language.includes("ja") || language.includes("jp")) {
|
|
16
|
+
require("lunr-languages/tinyseg")(lunr_1.default);
|
|
17
|
+
}
|
|
18
|
+
for (const lang of language.filter((item) => item !== "en" && item !== "zh")) {
|
|
19
|
+
require(`lunr-languages/lunr.${lang}`)(lunr_1.default);
|
|
20
|
+
}
|
|
21
|
+
if (language.includes("zh")) {
|
|
22
|
+
const { tokenizer, loadUserDict } = require("./tokenizer");
|
|
23
|
+
loadUserDict(zhUserDict, zhUserDictPath);
|
|
24
|
+
require("../../shared/lunrLanguageZh").lunrLanguageZh(lunr_1.default, tokenizer);
|
|
25
|
+
}
|
|
26
|
+
if (language.length > 1) {
|
|
27
|
+
require("lunr-languages/lunr.multi")(lunr_1.default);
|
|
28
|
+
}
|
|
29
|
+
if (language.length > 1) {
|
|
30
|
+
plugin = lunr_1.default.multiLanguage(...language);
|
|
31
|
+
}
|
|
32
|
+
else if (language[0] !== "en") {
|
|
33
|
+
plugin = lunr_1.default[language[0]];
|
|
34
|
+
}
|
|
24
35
|
}
|
|
25
36
|
// Some documents may be empty (unset array item), which is not mapped.
|
|
26
37
|
return new Array(allDocuments.length)
|
|
@@ -29,11 +40,8 @@ function buildIndex(allDocuments, { language, removeDefaultStopWordFilter, remov
|
|
|
29
40
|
.map((documents) => ({
|
|
30
41
|
documents,
|
|
31
42
|
index: (0, lunr_1.default)(function () {
|
|
32
|
-
if (
|
|
33
|
-
this.use(
|
|
34
|
-
}
|
|
35
|
-
else if (language[0] !== "en") {
|
|
36
|
-
this.use(lunr_1.default[language[0]]);
|
|
43
|
+
if (plugin) {
|
|
44
|
+
this.use(plugin);
|
|
37
45
|
}
|
|
38
46
|
if (removeDefaultStopWordFilter) {
|
|
39
47
|
// Sometimes we need no English stop words,
|