Skip to content

Commit

Permalink
fix(theme-common): restore useContextualSearchFilters public API for …
Browse files Browse the repository at this point in the history
…retrocompatibility (#10397)
  • Loading branch information
slorber authored Aug 13, 2024
1 parent 685730e commit 221ced7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/docusaurus-theme-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import {DEFAULT_SEARCH_TAG} from './utils/searchUtils';

// TODO Docusaurus v4: remove these workarounds as a breaking change
// and remove docs plugin peerDeps in theme-common/package.json
// This is public API surface that we need to keep for v3
Expand All @@ -27,6 +30,14 @@ export function useDocsPreferredVersion(...args: unknown[]): unknown {
...args,
);
}
export function useContextualSearchFilters() {
const {i18n} = useDocusaurusContext();
const docsTags =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@docusaurus/plugin-content-docs/client').useDocsContextualSearchTags();
const tags = [DEFAULT_SEARCH_TAG, ...docsTags];
return {locale: i18n.currentLocale, tags};
}

/*
* APIs to document
Expand Down

0 comments on commit 221ced7

Please sign in to comment.