@easyops-cn/docusaurus-search-local 0.52.0 → 0.52.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,21 @@
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.52.2](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.52.1...v0.52.2) (2025-12-01)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * wrap SearchBar with DocsPreferredVersionContextProvider for Docusaurus 3.9+ compatibility ([5aedc2e](https://github.com/easyops-cn/docusaurus-search-local/commit/5aedc2e7c4f2672d90d793d1a13e75bb5386e15b))
11
+ * wrap SearchBar with DocsPreferredVersionContextProvider for Docusaurus 3.9+ compatibility ([1b4f011](https://github.com/easyops-cn/docusaurus-search-local/commit/1b4f01139be07ba7cfa502db01aef61dd5e97929))
12
+
13
+ ## [0.52.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.52.0...v0.52.1) (2025-07-22)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * Fix non-deterministic search-index.json generation ([964f84a](https://github.com/easyops-cn/docusaurus-search-local/commit/964f84a32e7e683e4e557688764690dbc04d1b87))
19
+
5
20
  ## [0.52.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.51.1...v0.52.0) (2025-07-16)
6
21
 
7
22
 
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import "../../utils/proxiedGenerated";
3
+ import SearchBar from "./SearchBar";
4
+ import { DocsPreferredVersionContextProvider } from "@docusaurus/plugin-content-docs/client";
5
+ export default function SearchBarWrapper(props) {
6
+ return (<DocsPreferredVersionContextProvider>
7
+ <SearchBar {...props}/>
8
+ </DocsPreferredVersionContextProvider>);
9
+ }
@@ -66,7 +66,7 @@ function postBuildFactory(config, searchIndexFilename) {
66
66
  else {
67
67
  docsByDirMap.set("", allDocuments);
68
68
  }
69
- for (const [k, allDocs] of docsByDirMap) {
69
+ for (const [k, allDocs] of Array.from(docsByDirMap.entries()).sort(([a], [b]) => a.localeCompare(b))) {
70
70
  const searchIndex = (0, buildIndex_1.buildIndex)(allDocs, config);
71
71
  (0, debug_1.debugInfo)(`writing index (/${k}) to disk`);
72
72
  yield writeFileAsync(path_1.default.join(versionData.outDir, searchIndexFilename.replace("{dir}", k === "" ? "" : `-${k.replace(/\//g, "-")}`)), JSON.stringify(searchIndex), { encoding: "utf8" });
@@ -36,8 +36,10 @@ function processDocInfos({ routesPaths, outDir, baseUrl, siteConfig, plugins },
36
36
  }
37
37
  // Create a list of files to index per document version. This will always include all pages and blogs.
38
38
  const result = [];
39
- for (const [versionOutDir, docs] of versionData.entries()) {
40
- const versionPaths = routesPaths
39
+ for (const [versionOutDir, docs] of Array.from(versionData.entries()).sort(([a], [b]) => a.localeCompare(b))) {
40
+ // Sort routesPaths to ensure deterministic processing order
41
+ const sortedRoutesPaths = routesPaths.slice().sort();
42
+ const versionPaths = sortedRoutesPaths
41
43
  .map((url) => {
42
44
  // istanbul ignore next
43
45
  if (!url.startsWith(baseUrl)) {
@@ -26,14 +26,23 @@ function scanDocuments(DocInfoWithFilePathList, config) {
26
26
  keywordsDocuments,
27
27
  contentDocuments,
28
28
  ];
29
- yield Promise.all(DocInfoWithFilePathList.map(({ filePath, url, type }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
29
+ // Process documents in parallel but assign IDs deterministically based on input order
30
+ const processedDocs = yield Promise.all(DocInfoWithFilePathList.map(({ filePath, url, type }, index) => tslib_1.__awaiter(this, void 0, void 0, function* () {
30
31
  (0, debug_1.debugVerbose)(`parsing %s file %o of %o`, type, path_1.default.relative(process.cwd(), filePath), url);
31
32
  const html = yield readFileAsync(filePath, { encoding: "utf8" });
32
33
  const parsed = (0, parse_1.parse)(html, type, url, config);
33
34
  if (!parsed) {
34
35
  // Unlisted content
35
- return;
36
+ return null;
36
37
  }
38
+ return { parsed, url, index };
39
+ })));
40
+ // Process results in input order to ensure deterministic ID assignment
41
+ for (let i = 0; i < processedDocs.length; i++) {
42
+ const result = processedDocs[i];
43
+ if (!result)
44
+ continue;
45
+ const { parsed, url } = result;
37
46
  const { pageTitle, description, keywords, sections, breadcrumb } = parsed;
38
47
  const titleId = getNextDocId();
39
48
  titleDocuments.push({
@@ -88,7 +97,7 @@ function scanDocuments(DocInfoWithFilePathList, config) {
88
97
  });
89
98
  }
90
99
  }
91
- })));
100
+ }
92
101
  return allDocuments;
93
102
  });
94
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyops-cn/docusaurus-search-local",
3
- "version": "0.52.0",
3
+ "version": "0.52.2",
4
4
  "description": "An offline/local search plugin for Docusaurus v3",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,3 +0,0 @@
1
- import "../../utils/proxiedGenerated";
2
- import SearchBar from "./SearchBar";
3
- export default SearchBar;