From ef7556a9319ecca527c6b63b4009d810314fd08b Mon Sep 17 00:00:00 2001 From: sebastien Date: Tue, 13 Aug 2024 13:00:46 +0200 Subject: [PATCH] restore theme-common useContextualSearchFilters public API for retrocompatibility --- packages/docusaurus-theme-common/src/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/docusaurus-theme-common/src/index.ts b/packages/docusaurus-theme-common/src/index.ts index 003289b5cb7b..bb290cfcb393 100644 --- a/packages/docusaurus-theme-common/src/index.ts +++ b/packages/docusaurus-theme-common/src/index.ts @@ -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 @@ -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