@easyops-cn/docusaurus-search-local 0.22.0 → 0.23.0

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,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.23.0](https://www.github.com/easyops-cn/docusaurus-search-local/compare/v0.22.0...v0.23.0) (2022-03-10)
6
+
7
+
8
+ ### Features
9
+
10
+ * replace nodejieba with @node-rs/jieba ([f3f7594](https://www.github.com/easyops-cn/docusaurus-search-local/commit/f3f7594d0a97075a4aefa19e15f2d1f961bbb824))
11
+
5
12
  ## [0.22.0](https://www.github.com/easyops-cn/docusaurus-search-local/compare/v0.21.4...v0.22.0) (2022-02-28)
6
13
 
7
14
 
package/README.md CHANGED
@@ -58,24 +58,13 @@ module.exports = {
58
58
  // ```
59
59
  // language: ["en", "zh"],
60
60
  // ```
61
- // When applying `zh` in language, please install `nodejieba` in your project.
62
61
  },
63
62
  ],
64
63
  ],
65
64
  };
66
65
  ````
67
66
 
68
- > Notice!
69
- >
70
- > - We present this as a theme instead of plugin now, see [this comment](https://github.com/facebook/docusaurus/issues/6488#issuecomment-1024124096).
71
- >
72
- > - When applying `"zh"` in language, please also install `nodejieba` in your project, which is required for tokenizing Chinese words. It is removed from peerDependencies since v0.20.0, so you have to install it manually even if you're using npm v7+.
73
-
74
- ```shell
75
- npm install nodejieba
76
- # or
77
- yarn add nodejieba
78
- ```
67
+ > Notice: We present this as a theme instead of plugin now, see [this comment](https://github.com/facebook/docusaurus/issues/6488#issuecomment-1024124096).
79
68
 
80
69
  ## Theme Options
81
70
 
@@ -94,7 +83,7 @@ yarn add nodejieba
94
83
  | highlightSearchTermsOnTargetPage | boolean | `false` | Highlight search terms on target page. |
95
84
  | searchResultLimits | number | `8` | Limit the search results. |
96
85
  | searchResultContextMaxLength | number | `50` | Set the max length of characters of each search result to show. |
97
- | translations | TranslationMap | - | Set translations of this theme, see [docs below](#translations). |
86
+ | translations | TranslationMap | - | Set translations of this theme, see [docs below](#translations). |
98
87
  | ignoreFiles | string \| RegExp \| (string \| RegExp)[] | /**meta**\$/ | Set the match rules to ignore some files. |
99
88
 
100
89
  ### Translations
@@ -164,9 +153,6 @@ In case some specific errors occurred:
164
153
  - Try using @easyops-cn/docusaurus-search-local >= v0.16.0 with Docusaurus >= v2.0.0-alpha.73
165
154
  - Try using @easyops-cn/docusaurus-search-local between v0.14.0 and v0.15.1 with Docusaurus between v2.0.0-alpha.68 and v2.0.0-alpha.72
166
155
  - Or try using @easyops-cn/docusaurus-search-local <= v0.13.1 with Docusaurus <= v2.0.0-alpha.66
167
- - `Error: Command failed with signal "SIGSEGV"`:
168
- - This is probably caused by a [known issue](https://github.com/yanyiwu/nodejieba/issues/187) introduced by `nodejieba@2.5.2`, if you enabled language of zh.
169
- - Try downgrading `nodejieba` to `2.4.2` and it will work again, see discussions in [#47](https://github.com/easyops-cn/docusaurus-search-local/issues/47).
170
156
 
171
157
  ## Further Reading
172
158
 
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tokenizer = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const lunr_1 = tslib_1.__importDefault(require("lunr"));
6
- const nodejieba_1 = tslib_1.__importDefault(require("nodejieba"));
6
+ const jieba_1 = tslib_1.__importDefault(require("@node-rs/jieba"));
7
7
  const cutWordByUnderscore_1 = require("./cutWordByUnderscore");
8
8
  // https://zhuanlan.zhihu.com/p/33335629
9
9
  const RegExpConsecutiveWord = /\w+|\p{Unified_Ideograph}+/u;
10
- nodejieba_1.default.load();
11
10
  function tokenizer(input, metadata) {
12
11
  if (input == null) {
13
12
  return [];
@@ -44,7 +43,7 @@ function tokenizer(input, metadata) {
44
43
  start += word.length;
45
44
  }
46
45
  else {
47
- for (const zhWord of nodejieba_1.default.cut(word)) {
46
+ for (const zhWord of jieba_1.default.cut(word)) {
48
47
  tokens.push(new lunr_1.default.Token(zhWord, Object.assign(Object.assign({}, lunr_1.default.utils.clone(metadata)), { position: [start, zhWord.length], index: tokens.length })));
49
48
  start += zhWord.length;
50
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyops-cn/docusaurus-search-local",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
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",
@@ -37,7 +37,8 @@
37
37
  "lunr": "^2.3.9",
38
38
  "lunr-languages": "^1.4.0",
39
39
  "mark.js": "^8.11.1",
40
- "tslib": "^2.2.0"
40
+ "tslib": "^2.2.0",
41
+ "@node-rs/jieba": "^1.6.0"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@babel/core": "^7.12.3",
@@ -73,7 +74,6 @@
73
74
  "identity-obj-proxy": "^3.0.0",
74
75
  "jest": "^26.5.3",
75
76
  "lint-staged": "^10.4.1",
76
- "nodejieba": "^2.4.1",
77
77
  "prettier": "^2.1.2",
78
78
  "rimraf": "^3.0.2",
79
79
  "standard-version": "^9.0.0",