From bc0538f6fa59723f37c66e86bc265747beb35557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Wed, 6 Jul 2022 17:58:18 +0200 Subject: [PATCH] refactor(theme-common): move useDocsPreferredVersion() to public api (#7729) --- .../src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx | 6 ++---- packages/docusaurus-theme-common/src/index.ts | 2 ++ packages/docusaurus-theme-common/src/internal.ts | 1 - website/src/components/Versions.tsx | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx index 831e6fb06b07..1b4d7018308d 100644 --- a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +++ b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx @@ -10,10 +10,8 @@ import { useVersions, useActiveDocContext, } from '@docusaurus/plugin-content-docs/client'; -import { - useDocsPreferredVersion, - useDocsVersionCandidates, -} from '@docusaurus/theme-common/internal'; +import {useDocsPreferredVersion} from '@docusaurus/theme-common'; +import {useDocsVersionCandidates} from '@docusaurus/theme-common/internal'; import {translate} from '@docusaurus/Translate'; import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem'; import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem'; diff --git a/packages/docusaurus-theme-common/src/index.ts b/packages/docusaurus-theme-common/src/index.ts index 9cc56897fe0a..1b450b8182b3 100644 --- a/packages/docusaurus-theme-common/src/index.ts +++ b/packages/docusaurus-theme-common/src/index.ts @@ -73,3 +73,5 @@ export {isRegexpStringMatch} from './utils/regexpUtils'; export {duplicates, uniq} from './utils/jsUtils'; export {usePrismTheme} from './hooks/usePrismTheme'; + +export {useDocsPreferredVersion} from './contexts/docsPreferredVersion'; diff --git a/packages/docusaurus-theme-common/src/internal.ts b/packages/docusaurus-theme-common/src/internal.ts index fc795f847dc6..8c2d4b9fd128 100644 --- a/packages/docusaurus-theme-common/src/internal.ts +++ b/packages/docusaurus-theme-common/src/internal.ts @@ -27,7 +27,6 @@ export {DocsSidebarProvider, useDocsSidebar} from './contexts/docsSidebar'; export {DocProvider, useDoc, type DocContextValue} from './contexts/doc'; export { - useDocsPreferredVersion, useDocsPreferredVersionByPluginId, DocsPreferredVersionContextProvider, } from './contexts/docsPreferredVersion'; diff --git a/website/src/components/Versions.tsx b/website/src/components/Versions.tsx index 98ff4f968231..9542c88a8328 100644 --- a/website/src/components/Versions.tsx +++ b/website/src/components/Versions.tsx @@ -12,7 +12,7 @@ import React, { useRef, type ReactNode, } from 'react'; -import {useDocsPreferredVersion} from '@docusaurus/theme-common/internal'; +import {useDocsPreferredVersion} from '@docusaurus/theme-common'; import {useVersions} from '@docusaurus/plugin-content-docs/client'; import Translate from '@docusaurus/Translate'; import CodeBlock from '@theme/CodeBlock';