@easyops-cn/docusaurus-search-local 0.48.0 → 0.48.2
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.48.2](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.48.1...v0.48.2) (2025-01-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* excludes mobile toc button for search marks, fixes [#473](https://github.com/easyops-cn/docusaurus-search-local/issues/473) ([b8dd155](https://github.com/easyops-cn/docusaurus-search-local/commit/b8dd15559f22b7f914af8123ed7eaa60c0beac3b))
|
|
11
|
+
|
|
12
|
+
## [0.48.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.48.0...v0.48.1) (2025-01-16)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* do not limit the search page result by searchResultLimits ([29f6d69](https://github.com/easyops-cn/docusaurus-search-local/commit/29f6d6962e69d38089a45961ae8dc62636838494))
|
|
18
|
+
|
|
5
19
|
## [0.48.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.47.0...v0.48.0) (2025-01-14)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -11,8 +11,9 @@ import { SuggestionTemplate } from "./SuggestionTemplate";
|
|
|
11
11
|
import { EmptyTemplate } from "./EmptyTemplate";
|
|
12
12
|
import { Mark, searchBarShortcut, searchBarShortcutHint, searchBarPosition, docsPluginIdForPreferredVersion, indexDocs, searchContextByPaths, hideSearchBarWithNoSearchContext, useAllContextsWithNoSearchContext, } from "../../utils/proxiedGenerated";
|
|
13
13
|
import LoadingRing from "../LoadingRing/LoadingRing";
|
|
14
|
-
import styles from "./SearchBar.module.css";
|
|
15
14
|
import { normalizeContextByPath } from "../../utils/normalizeContextByPath";
|
|
15
|
+
import { searchResultLimits } from "../../utils/proxiedGeneratedConstants";
|
|
16
|
+
import styles from "./SearchBar.module.css";
|
|
16
17
|
async function fetchAutoCompleteJS() {
|
|
17
18
|
const autoCompleteModule = await import("@easyops-cn/autocomplete.js");
|
|
18
19
|
const autoComplete = autoCompleteModule.default;
|
|
@@ -187,7 +188,7 @@ export default function SearchBar({ handleSearchBarToggle, }) {
|
|
|
187
188
|
}, [
|
|
188
189
|
{
|
|
189
190
|
source: async (input, callback) => {
|
|
190
|
-
const result = await searchByWorker(versionUrl, searchContext, input);
|
|
191
|
+
const result = await searchByWorker(versionUrl, searchContext, input, searchResultLimits);
|
|
191
192
|
callback(result);
|
|
192
193
|
},
|
|
193
194
|
templates: {
|
|
@@ -254,7 +255,9 @@ export default function SearchBar({ handleSearchBarToggle, }) {
|
|
|
254
255
|
const mark = new Mark(root);
|
|
255
256
|
mark.unmark();
|
|
256
257
|
if (keywords.length !== 0) {
|
|
257
|
-
mark.mark(keywords
|
|
258
|
+
mark.mark(keywords, {
|
|
259
|
+
exclude: [".theme-doc-toc-mobile > button"],
|
|
260
|
+
});
|
|
258
261
|
}
|
|
259
262
|
// Apply any keywords to the search input so that we can clear marks in case we loaded a page with a highlight in the url
|
|
260
263
|
setInputValue(keywords.join(" "));
|
|
@@ -323,7 +326,7 @@ export default function SearchBar({ handleSearchBarToggle, }) {
|
|
|
323
326
|
})} hidden={hidden}
|
|
324
327
|
// Manually make the search bar be LTR even if in RTL
|
|
325
328
|
dir="ltr">
|
|
326
|
-
|
|
329
|
+
<input placeholder={translate({
|
|
327
330
|
id: "theme.SearchBar.label",
|
|
328
331
|
message: "Search",
|
|
329
332
|
description: "The ARIA label and placeholder for search button",
|
|
@@ -46,7 +46,7 @@ function SearchPageContent() {
|
|
|
46
46
|
updateSearchPath(searchQuery);
|
|
47
47
|
if (searchQuery) {
|
|
48
48
|
(async () => {
|
|
49
|
-
const results = await searchByWorker(versionUrl, searchContext, searchQuery);
|
|
49
|
+
const results = await searchByWorker(versionUrl, searchContext, searchQuery, 100);
|
|
50
50
|
setSearchResults(results);
|
|
51
51
|
})();
|
|
52
52
|
}
|
|
@@ -15,10 +15,10 @@ export async function fetchIndexesByWorker(baseUrl, searchContext) {
|
|
|
15
15
|
await remoteWorker.fetchIndexes(baseUrl, searchContext);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
export async function searchByWorker(baseUrl, searchContext, input) {
|
|
18
|
+
export async function searchByWorker(baseUrl, searchContext, input, limit) {
|
|
19
19
|
if (process.env.NODE_ENV === "production") {
|
|
20
20
|
const remoteWorker = await getRemoteWorker();
|
|
21
|
-
return remoteWorker.search(baseUrl, searchContext, input);
|
|
21
|
+
return remoteWorker.search(baseUrl, searchContext, input, limit);
|
|
22
22
|
}
|
|
23
23
|
return [];
|
|
24
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Comlink from "comlink";
|
|
2
2
|
import lunr from "lunr";
|
|
3
|
-
import { searchIndexUrl,
|
|
3
|
+
import { searchIndexUrl, language } from "../utils/proxiedGeneratedConstants";
|
|
4
4
|
import { tokenize } from "../utils/tokenize";
|
|
5
5
|
import { smartQueries } from "../utils/smartQueries";
|
|
6
6
|
import { SearchDocumentType, } from "../../shared/interfaces";
|
|
@@ -20,7 +20,7 @@ export class SearchWorker {
|
|
|
20
20
|
}
|
|
21
21
|
return promise;
|
|
22
22
|
}
|
|
23
|
-
async search(baseUrl, searchContext, input) {
|
|
23
|
+
async search(baseUrl, searchContext, input, limit) {
|
|
24
24
|
const rawTokens = tokenize(input, language);
|
|
25
25
|
if (rawTokens.length === 0) {
|
|
26
26
|
return [];
|
|
@@ -39,10 +39,10 @@ export class SearchWorker {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
})
|
|
42
|
-
.slice(0,
|
|
42
|
+
.slice(0, limit)
|
|
43
43
|
// Remove duplicated results.
|
|
44
44
|
.filter((result) => !results.some((item) => item.document.i.toString() === result.ref))
|
|
45
|
-
.slice(0,
|
|
45
|
+
.slice(0, limit - results.length)
|
|
46
46
|
.map((result) => {
|
|
47
47
|
const document = documents.find((doc) => doc.i.toString() === result.ref);
|
|
48
48
|
return {
|
|
@@ -55,7 +55,7 @@ export class SearchWorker {
|
|
|
55
55
|
score: result.score,
|
|
56
56
|
};
|
|
57
57
|
}));
|
|
58
|
-
if (results.length >=
|
|
58
|
+
if (results.length >= limit) {
|
|
59
59
|
break search;
|
|
60
60
|
}
|
|
61
61
|
}
|