@easyops-cn/docusaurus-search-local 0.44.3 → 0.44.5
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.5](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.4...v0.44.5) (2024-08-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* update cheerio to 1.0.0, closes [#444](https://github.com/easyops-cn/docusaurus-search-local/issues/444) ([0d70f63](https://github.com/easyops-cn/docusaurus-search-local/commit/0d70f63cb170bac2b51461c0dd6f66a53dff4483))
|
|
11
|
+
|
|
12
|
+
## [0.44.4](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.3...v0.44.4) (2024-07-19)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* 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))
|
|
18
|
+
|
|
5
19
|
## [0.44.3](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.2...v0.44.3) (2024-07-08)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -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,
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parse = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const cheerio = tslib_1.__importStar(require("cheerio"));
|
|
6
6
|
const parseDocument_1 = require("./parseDocument");
|
|
7
7
|
const parsePage_1 = require("./parsePage");
|
|
8
8
|
function parse(html, type, url, { ignoreCssSelectors, forceIgnoreNoIndex }) {
|
|
9
9
|
var _a;
|
|
10
|
-
const $ =
|
|
10
|
+
const $ = cheerio.load(html);
|
|
11
11
|
const robotsMeta = $('meta[name="robots"]');
|
|
12
12
|
if (!forceIgnoreNoIndex && ((_a = robotsMeta.attr("content")) === null || _a === void 0 ? void 0 : _a.includes("noindex"))) {
|
|
13
13
|
// Unlisted content
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyops-cn/docusaurus-search-local",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.5",
|
|
4
4
|
"description": "An offline/local search plugin for Docusaurus v3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@docusaurus/utils-validation": "^2 || ^3",
|
|
38
38
|
"@easyops-cn/autocomplete.js": "^0.38.1",
|
|
39
39
|
"@node-rs/jieba": "^1.6.0",
|
|
40
|
-
"cheerio": "^1.0.0
|
|
40
|
+
"cheerio": "^1.0.0",
|
|
41
41
|
"clsx": "^1.1.1",
|
|
42
42
|
"debug": "^4.2.0",
|
|
43
43
|
"fs-extra": "^10.0.0",
|