@easyops-cn/docusaurus-search-local 0.52.2 → 0.52.3

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,14 @@
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.3](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.52.2...v0.52.3) (2026-01-29)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * replace useDocsPreferredVersion with useActiveVersion ([7e72ef4](https://github.com/easyops-cn/docusaurus-search-local/commit/7e72ef42c8605f4f4147b2227decc9865ac41afd))
11
+ * replace useDocsPreferredVersion with useActiveVersion ([15ba30d](https://github.com/easyops-cn/docusaurus-search-local/commit/15ba30d8c4aab85984be337f227b3ab166daa93e))
12
+
5
13
  ## [0.52.2](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.52.1...v0.52.2) (2025-12-01)
6
14
 
7
15
 
@@ -4,12 +4,11 @@ import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
4
4
  import useIsBrowser from "@docusaurus/useIsBrowser";
5
5
  import { useHistory, useLocation } from "@docusaurus/router";
6
6
  import { translate } from "@docusaurus/Translate";
7
- import { ReactContextError, useDocsPreferredVersion, } from "@docusaurus/theme-common";
8
- import { useActivePlugin } from "@docusaurus/plugin-content-docs/client";
7
+ import { useActivePlugin, useActiveVersion, } from "@docusaurus/plugin-content-docs/client";
9
8
  import { fetchIndexesByWorker, searchByWorker } from "../searchByWorker";
10
9
  import { SuggestionTemplate } from "./SuggestionTemplate";
11
10
  import { EmptyTemplate } from "./EmptyTemplate";
12
- import { Mark, searchBarShortcut, searchBarShortcutHint, searchBarShortcutKeymap, searchBarPosition, docsPluginIdForPreferredVersion, indexDocs, searchContextByPaths, hideSearchBarWithNoSearchContext, useAllContextsWithNoSearchContext, } from "../../utils/proxiedGenerated";
11
+ import { Mark, searchBarShortcut, searchBarShortcutHint, searchBarShortcutKeymap, searchBarPosition, docsPluginIdForPreferredVersion, searchContextByPaths, hideSearchBarWithNoSearchContext, useAllContextsWithNoSearchContext, } from "../../utils/proxiedGenerated";
13
12
  import LoadingRing from "../LoadingRing/LoadingRing";
14
13
  import { normalizeContextByPath } from "../../utils/normalizeContextByPath";
15
14
  import { searchResultLimits } from "../../utils/proxiedGeneratedConstants";
@@ -36,29 +35,9 @@ export default function SearchBar({ handleSearchBarToggle, }) {
36
35
  // It returns undefined for non-docs pages
37
36
  const activePlugin = useActivePlugin();
38
37
  let versionUrl = baseUrl;
39
- // For non-docs pages while using plugin-content-docs with custom ids,
40
- // this will throw an error of:
41
- // > Docusaurus plugin global data not found for "docusaurus-plugin-content-docs" plugin with id "default".
42
- // It seems that we can not get the correct id for non-docs pages.
43
- try {
44
- // The try-catch is a hack because useDocsPreferredVersion just throws an
45
- // exception when versions are not used.
46
- // The same hack is used in SearchPage.tsx
47
- // eslint-disable-next-line react-hooks/rules-of-hooks
48
- const { preferredVersion } = useDocsPreferredVersion(activePlugin?.pluginId ?? docsPluginIdForPreferredVersion);
49
- if (preferredVersion && !preferredVersion.isLast) {
50
- versionUrl = preferredVersion.path + "/";
51
- }
52
- }
53
- catch (e) {
54
- if (indexDocs) {
55
- if (e instanceof ReactContextError) {
56
- /* ignore, happens when website doesn't use versions */
57
- }
58
- else {
59
- throw e;
60
- }
61
- }
38
+ const activeVersion = useActiveVersion(activePlugin?.pluginId ?? docsPluginIdForPreferredVersion);
39
+ if (activeVersion && !activeVersion.isLast) {
40
+ versionUrl = activeVersion.path + "/";
62
41
  }
63
42
  const history = useHistory();
64
43
  const location = useLocation();
@@ -359,8 +338,11 @@ export default function SearchBar({ handleSearchBarToggle, }) {
359
338
  searchBarShortcutHint &&
360
339
  (inputValue !== "" ? (<button className={styles.searchClearButton} onClick={onClearSearch}>
361
340
 
362
- </button>) : (isBrowser && searchBarShortcutKeymap && (<div className={styles.searchHintContainer}>
363
- {getKeymapHints(searchBarShortcutKeymap, isMac).map((hint, index) => (<kbd key={index} className={styles.searchHint}>{hint}</kbd>))}
341
+ </button>) : (isBrowser &&
342
+ searchBarShortcutKeymap && (<div className={styles.searchHintContainer}>
343
+ {getKeymapHints(searchBarShortcutKeymap, isMac).map((hint, index) => (<kbd key={index} className={styles.searchHint}>
344
+ {hint}
345
+ </kbd>))}
364
346
  </div>)))}
365
347
  </div>);
366
348
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyops-cn/docusaurus-search-local",
3
- "version": "0.52.2",
3
+ "version": "0.52.3",
4
4
  "description": "An offline/local search plugin for Docusaurus v3",
5
5
  "repository": {
6
6
  "type": "git",