@easyops-cn/docusaurus-search-local 0.44.0 → 0.44.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 +14 -0
- package/dist/client/client/theme/SearchBar/SearchBar.jsx +3 -1
- package/dist/client/client/theme/SearchBar/SearchBar.module.css +20 -0
- package/dist/server/server/utils/buildIndex.js +5 -1
- package/dist/server/server/utils/postBuildFactory.js +6 -11
- package/package.json +1 -1
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.2](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.1...v0.44.2) (2024-06-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* manually make the search bar be LTR even if in RTL ([a5c7184](https://github.com/easyops-cn/docusaurus-search-local/commit/a5c7184c77929410732df022ebb3257bdb491074))
|
|
11
|
+
|
|
12
|
+
## [0.44.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.44.0...v0.44.1) (2024-06-19)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* fix searching within context closes [#424](https://github.com/easyops-cn/docusaurus-search-local/issues/424) ([bbec667](https://github.com/easyops-cn/docusaurus-search-local/commit/bbec66782d6a285338211248f14b4d1d0e5eee50))
|
|
18
|
+
|
|
5
19
|
## [0.44.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.43.0...v0.44.0) (2024-06-06)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -318,7 +318,9 @@ export default function SearchBar({ handleSearchBarToggle, }) {
|
|
|
318
318
|
return (<div className={clsx("navbar__search", styles.searchBarContainer, {
|
|
319
319
|
[styles.searchIndexLoading]: loading && inputChanged,
|
|
320
320
|
[styles.focused]: focused,
|
|
321
|
-
})} hidden={hidden}
|
|
321
|
+
})} hidden={hidden}
|
|
322
|
+
// Manually make the search bar be LTR even if in RTL
|
|
323
|
+
dir="ltr">
|
|
322
324
|
<input placeholder={translate({
|
|
323
325
|
id: "theme.SearchBar.label",
|
|
324
326
|
message: "Search",
|
|
@@ -250,6 +250,26 @@ html[data-theme="dark"] .noResultsIcon {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
/* Manually make the search bar be LTR even if in RTL */
|
|
254
|
+
html[dir="rtl"] .searchHintContainer {
|
|
255
|
+
right: auto;
|
|
256
|
+
left: 10px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
html[dir="rtl"] .searchBarContainer .searchClearButton {
|
|
260
|
+
right: auto;
|
|
261
|
+
left: 0.8rem;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
html[dir="rtl"] .searchBarContainer .searchBarLoadingRing {
|
|
265
|
+
left: auto;
|
|
266
|
+
right: 10px;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
html[dir="rtl"] :global(.navbar__search-input) {
|
|
270
|
+
padding: 0 2.25em 0 0.5em;
|
|
271
|
+
}
|
|
272
|
+
|
|
253
273
|
/* For autocomplete.js only. */
|
|
254
274
|
.input {
|
|
255
275
|
}
|
|
@@ -22,7 +22,11 @@ function buildIndex(allDocuments, { language, removeDefaultStopWordFilter, remov
|
|
|
22
22
|
if (language.length > 1) {
|
|
23
23
|
require("lunr-languages/lunr.multi")(lunr_1.default);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
// Some documents may be empty (unset array item), which is not mapped.
|
|
26
|
+
return new Array(allDocuments.length)
|
|
27
|
+
.fill(null)
|
|
28
|
+
.map((_doc, index) => { var _a; return (_a = allDocuments[index]) !== null && _a !== void 0 ? _a : []; })
|
|
29
|
+
.map((documents) => ({
|
|
26
30
|
documents,
|
|
27
31
|
index: (0, lunr_1.default)(function () {
|
|
28
32
|
if (language.length > 1) {
|
|
@@ -34,17 +34,17 @@ function postBuildFactory(config, searchIndexFilename) {
|
|
|
34
34
|
for (const doc of documents) {
|
|
35
35
|
if (doc.u.startsWith(baseUrl)) {
|
|
36
36
|
const uri = doc.u.substring(baseUrl.length);
|
|
37
|
-
|
|
37
|
+
const matchedPaths = [];
|
|
38
38
|
for (const _path of searchContextByPaths) {
|
|
39
39
|
const path = typeof _path === "string" ? _path : _path.path;
|
|
40
40
|
if (uri === path || uri.startsWith(`${path}/`)) {
|
|
41
|
-
|
|
41
|
+
matchedPaths.push(path);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
for (const matchedPath of
|
|
44
|
+
for (const matchedPath of matchedPaths) {
|
|
45
45
|
let dirAllDocs = docsByDirMap.get(matchedPath);
|
|
46
46
|
if (!dirAllDocs) {
|
|
47
|
-
dirAllDocs =
|
|
47
|
+
dirAllDocs = new Array(allDocuments.length);
|
|
48
48
|
docsByDirMap.set(matchedPath, dirAllDocs);
|
|
49
49
|
}
|
|
50
50
|
let dirDocs = dirAllDocs[docIndex];
|
|
@@ -53,7 +53,8 @@ function postBuildFactory(config, searchIndexFilename) {
|
|
|
53
53
|
}
|
|
54
54
|
dirDocs.push(doc);
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
56
|
+
if (matchedPaths.length > 0 &&
|
|
57
|
+
!useAllContextsWithNoSearchContext) {
|
|
57
58
|
continue;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -61,12 +62,6 @@ function postBuildFactory(config, searchIndexFilename) {
|
|
|
61
62
|
}
|
|
62
63
|
docIndex++;
|
|
63
64
|
}
|
|
64
|
-
for (const [k, v] of docsByDirMap) {
|
|
65
|
-
const docsNotEmpty = v.filter((d) => !!d);
|
|
66
|
-
if (docsNotEmpty.length < v.length) {
|
|
67
|
-
docsByDirMap.set(k, docsNotEmpty);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
65
|
}
|
|
71
66
|
else {
|
|
72
67
|
docsByDirMap.set("", allDocuments);
|