diff --git a/.github/workflows/tests-e2e.yml b/.github/workflows/tests-e2e.yml
index d60d22709e68..f437e5441946 100644
--- a/.github/workflows/tests-e2e.yml
+++ b/.github/workflows/tests-e2e.yml
@@ -102,19 +102,11 @@ jobs:
working-directory: ../test-website
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false # Yarn berry should create the lockfile, despite CI env
- - name: Install missing dependencies
- if: matrix.variant == '-st' && matrix.nodeLinker == 'pnp'
- run: |
- # These dependencies are referenced in the init project, not by our packages
- yarn add @docusaurus/theme-classic @docusaurus/types @types/node
- yarn config set packageExtensions --json '{ "unified@^9.2.2": { "dependencies": { "@types/unist": "^2.0.6" } } }'
- working-directory: ../test-website
- name: Start test-website project
run: yarn start --no-open
working-directory: ../test-website
env:
E2E_TEST: true
-
- name: TypeCheck website
# TODO: there're some lingering issues with PnP + tsc. Enable tsc in PnP later.
if: matrix.variant == '-st' && matrix.nodeLinker != 'pnp'
diff --git a/packages/docusaurus-plugin-content-blog/package.json b/packages/docusaurus-plugin-content-blog/package.json
index 0c6bddf730da..815413ff2cfd 100644
--- a/packages/docusaurus-plugin-content-blog/package.json
+++ b/packages/docusaurus-plugin-content-blog/package.json
@@ -52,7 +52,8 @@
},
"peerDependencies": {
"react": "^18.0.0",
- "react-dom": "^18.0.0"
+ "react-dom": "^18.0.0",
+ "@docusaurus/plugin-content-docs": "*"
},
"engines": {
"node": ">=18.0"
diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json
index 8ee67e76d00c..777777e932b8 100644
--- a/packages/docusaurus-plugin-content-docs/package.json
+++ b/packages/docusaurus-plugin-content-docs/package.json
@@ -39,6 +39,7 @@
"@docusaurus/logger": "3.4.0",
"@docusaurus/mdx-loader": "3.4.0",
"@docusaurus/module-type-aliases": "3.4.0",
+ "@docusaurus/theme-common": "3.4.0",
"@docusaurus/types": "3.4.0",
"@docusaurus/utils": "3.4.0",
"@docusaurus/utils-common": "3.4.0",
diff --git a/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsClientUtils.test.ts b/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsClientUtils.test.ts
index 16fc4e7a9c80..9feebc65ce9f 100644
--- a/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsClientUtils.test.ts
+++ b/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsClientUtils.test.ts
@@ -18,7 +18,7 @@ import type {
GlobalVersion,
ActivePlugin,
GlobalDoc,
-} from '@docusaurus/plugin-content-docs/client';
+} from '../index';
describe('docsClientUtils', () => {
it('getActivePlugin', () => {
diff --git a/packages/docusaurus-theme-common/src/contexts/__tests__/docsSidebar.test.tsx b/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsSidebar.test.tsx
similarity index 100%
rename from packages/docusaurus-theme-common/src/contexts/__tests__/docsSidebar.test.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/__tests__/docsSidebar.test.tsx
diff --git a/packages/docusaurus-theme-common/src/utils/__tests__/docsUtils.test.tsx b/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsUtils.test.tsx
similarity index 99%
rename from packages/docusaurus-theme-common/src/utils/__tests__/docsUtils.test.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/__tests__/docsUtils.test.tsx
index d1285ad2c95b..974eca6ce20a 100644
--- a/packages/docusaurus-theme-common/src/utils/__tests__/docsUtils.test.tsx
+++ b/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsUtils.test.tsx
@@ -18,8 +18,8 @@ import {
useSidebarBreadcrumbs,
isVisibleSidebarItem,
} from '../docsUtils';
-import {DocsSidebarProvider} from '../../contexts/docsSidebar';
-import {DocsVersionProvider} from '../../contexts/docsVersion';
+import {DocsSidebarProvider} from '../docsSidebar';
+import {DocsVersionProvider} from '../docsVersion';
import type {
PropSidebar,
PropSidebarItem,
diff --git a/packages/docusaurus-theme-common/src/contexts/__tests__/docsVersion.test.tsx b/packages/docusaurus-plugin-content-docs/src/client/__tests__/docsVersion.test.tsx
similarity index 100%
rename from packages/docusaurus-theme-common/src/contexts/__tests__/docsVersion.test.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/__tests__/docsVersion.test.tsx
diff --git a/packages/docusaurus-theme-common/src/contexts/doc.tsx b/packages/docusaurus-plugin-content-docs/src/client/doc.tsx
similarity index 97%
rename from packages/docusaurus-theme-common/src/contexts/doc.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/doc.tsx
index 64cc738d5669..6f4ce492e445 100644
--- a/packages/docusaurus-theme-common/src/contexts/doc.tsx
+++ b/packages/docusaurus-plugin-content-docs/src/client/doc.tsx
@@ -6,7 +6,7 @@
*/
import React, {useMemo, type ReactNode, useContext} from 'react';
-import {ReactContextError} from '../utils/reactUtils';
+import {ReactContextError} from '@docusaurus/theme-common/internal';
import type {PropDocContent} from '@docusaurus/plugin-content-docs';
/**
diff --git a/packages/docusaurus-theme-common/src/contexts/docSidebarItemsExpandedState.tsx b/packages/docusaurus-plugin-content-docs/src/client/docSidebarItemsExpandedState.tsx
similarity index 96%
rename from packages/docusaurus-theme-common/src/contexts/docSidebarItemsExpandedState.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/docSidebarItemsExpandedState.tsx
index b3d84a78389d..3aa0d47594f6 100644
--- a/packages/docusaurus-theme-common/src/contexts/docSidebarItemsExpandedState.tsx
+++ b/packages/docusaurus-plugin-content-docs/src/client/docSidebarItemsExpandedState.tsx
@@ -6,7 +6,7 @@
*/
import React, {type ReactNode, useMemo, useState, useContext} from 'react';
-import {ReactContextError} from '../utils/reactUtils';
+import {ReactContextError} from '@docusaurus/theme-common/internal';
type ContextValue = {
/**
diff --git a/packages/docusaurus-theme-common/src/contexts/docsPreferredVersion.tsx b/packages/docusaurus-plugin-content-docs/src/client/docsPreferredVersion.tsx
similarity index 93%
rename from packages/docusaurus-theme-common/src/contexts/docsPreferredVersion.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/docsPreferredVersion.tsx
index 908b4854c926..91dcd3a19ccd 100644
--- a/packages/docusaurus-theme-common/src/contexts/docsPreferredVersion.tsx
+++ b/packages/docusaurus-plugin-content-docs/src/client/docsPreferredVersion.tsx
@@ -20,13 +20,13 @@ import {
type GlobalVersion,
} from '@docusaurus/plugin-content-docs/client';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/constants';
+import {useThemeConfig, type ThemeConfig} from '@docusaurus/theme-common';
import {
- useThemeConfig,
- type DocsVersionPersistence,
-} from '../utils/useThemeConfig';
-import {isDocsPluginEnabled} from '../utils/docsUtils';
-import {ReactContextError} from '../utils/reactUtils';
-import {createStorageSlot} from '../utils/storageUtils';
+ ReactContextError,
+ createStorageSlot,
+} from '@docusaurus/theme-common/internal';
+
+type DocsVersionPersistence = ThemeConfig['docs']['versionPersistence'];
const storageKey = (pluginId: string) => `docs-preferred-version-${pluginId}`;
@@ -177,14 +177,11 @@ export function DocsPreferredVersionContextProvider({
}: {
children: ReactNode;
}): JSX.Element {
- if (isDocsPluginEnabled) {
- return (
-
- {children}
-
- );
- }
- return <>{children}>;
+ return (
+
+ {children}
+
+ );
}
function useDocsPreferredVersionContext(): ContextValue {
diff --git a/packages/docusaurus-theme-common/src/utils/__tests__/searchUtils.test.ts b/packages/docusaurus-plugin-content-docs/src/client/docsSearch.test.ts
similarity index 56%
rename from packages/docusaurus-theme-common/src/utils/__tests__/searchUtils.test.ts
rename to packages/docusaurus-plugin-content-docs/src/client/docsSearch.test.ts
index bb6ab8245e2c..795862d6f71b 100644
--- a/packages/docusaurus-theme-common/src/utils/__tests__/searchUtils.test.ts
+++ b/packages/docusaurus-plugin-content-docs/src/client/docsSearch.test.ts
@@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/
-import {docVersionSearchTag} from '../searchUtils';
+import {getDocsVersionSearchTag} from './docsSearch';
-describe('docVersionSearchTag', () => {
+describe('getDocsVersionSearchTag', () => {
it('works', () => {
- expect(docVersionSearchTag('foo', 'bar')).toBe('docs-foo-bar');
+ expect(getDocsVersionSearchTag('foo', 'bar')).toBe('docs-foo-bar');
});
});
diff --git a/packages/docusaurus-plugin-content-docs/src/client/docsSearch.ts b/packages/docusaurus-plugin-content-docs/src/client/docsSearch.ts
new file mode 100644
index 000000000000..c6b9ca34832e
--- /dev/null
+++ b/packages/docusaurus-plugin-content-docs/src/client/docsSearch.ts
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import {
+ useAllDocsData,
+ useActivePluginAndVersion,
+} from '@docusaurus/plugin-content-docs/client';
+import {useDocsPreferredVersionByPluginId} from './docsPreferredVersion';
+
+/** The search tag to append as each doc's metadata. */
+export function getDocsVersionSearchTag(
+ pluginId: string,
+ versionName: string,
+): string {
+ return `docs-${pluginId}-${versionName}`;
+}
+
+/**
+ * Gets the relevant docs tags to search.
+ * This is the logic that powers the contextual search feature.
+ *
+ * If user is browsing Android 1.4 docs, he'll get presented with:
+ * - Android '1.4' docs
+ * - iOS 'preferred | latest' docs
+ *
+ * The result is generic and not coupled to Algolia/DocSearch on purpose.
+ */
+export function useDocsContextualSearchTags(): string[] {
+ const allDocsData = useAllDocsData();
+ const activePluginAndVersion = useActivePluginAndVersion();
+ const docsPreferredVersionByPluginId = useDocsPreferredVersionByPluginId();
+
+ // This can't use more specialized hooks because we are mapping over all
+ // plugin instances.
+ function getDocPluginTags(pluginId: string) {
+ const activeVersion =
+ activePluginAndVersion?.activePlugin.pluginId === pluginId
+ ? activePluginAndVersion.activeVersion
+ : undefined;
+
+ const preferredVersion = docsPreferredVersionByPluginId[pluginId];
+
+ const latestVersion = allDocsData[pluginId]!.versions.find(
+ (v) => v.isLast,
+ )!;
+
+ const version = activeVersion ?? preferredVersion ?? latestVersion;
+
+ return getDocsVersionSearchTag(pluginId, version.name);
+ }
+
+ return [...Object.keys(allDocsData).map(getDocPluginTags)];
+}
diff --git a/packages/docusaurus-theme-common/src/contexts/docsSidebar.tsx b/packages/docusaurus-plugin-content-docs/src/client/docsSidebar.tsx
similarity index 95%
rename from packages/docusaurus-theme-common/src/contexts/docsSidebar.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/docsSidebar.tsx
index 43f109bf7698..4679ce4e638e 100644
--- a/packages/docusaurus-theme-common/src/contexts/docsSidebar.tsx
+++ b/packages/docusaurus-plugin-content-docs/src/client/docsSidebar.tsx
@@ -6,7 +6,7 @@
*/
import React, {useMemo, useContext, type ReactNode} from 'react';
-import {ReactContextError} from '../utils/reactUtils';
+import {ReactContextError} from '@docusaurus/theme-common/internal';
import type {PropSidebar} from '@docusaurus/plugin-content-docs';
// Using a Symbol because null is a valid context value (a doc with no sidebar)
diff --git a/packages/docusaurus-theme-common/src/utils/docsUtils.tsx b/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx
similarity index 97%
rename from packages/docusaurus-theme-common/src/utils/docsUtils.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx
index 597a5dea3e50..61ef935e09df 100644
--- a/packages/docusaurus-theme-common/src/utils/docsUtils.tsx
+++ b/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx
@@ -9,7 +9,6 @@ import {useMemo} from 'react';
import {matchPath, useLocation} from '@docusaurus/router';
import renderRoutes from '@docusaurus/renderRoutes';
import {
- useAllDocsData,
useActivePlugin,
useActiveDocContext,
useLatestVersion,
@@ -17,12 +16,13 @@ import {
type GlobalSidebar,
type GlobalDoc,
} from '@docusaurus/plugin-content-docs/client';
+import {isSamePath} from '@docusaurus/theme-common/internal';
+import {uniq} from '@docusaurus/theme-common';
import type {Props as DocRootProps} from '@theme/DocRoot';
-import {useDocsPreferredVersion} from '../contexts/docsPreferredVersion';
-import {useDocsVersion} from '../contexts/docsVersion';
-import {useDocsSidebar} from '../contexts/docsSidebar';
-import {uniq} from './jsUtils';
-import {isSamePath} from './routesUtils';
+import {useDocsPreferredVersion} from './docsPreferredVersion';
+import {useDocsVersion} from './docsVersion';
+import {useDocsSidebar} from './docsSidebar';
+
import type {
PropSidebar,
PropSidebarItem,
@@ -31,9 +31,6 @@ import type {
PropSidebarBreadcrumbsItem,
} from '@docusaurus/plugin-content-docs';
-// TODO not ideal, see also "useDocs"
-export const isDocsPluginEnabled: boolean = !!useAllDocsData;
-
/**
* A null-safe way to access a doc's data by ID in the active version.
*/
diff --git a/packages/docusaurus-theme-common/src/contexts/docsVersion.tsx b/packages/docusaurus-plugin-content-docs/src/client/docsVersion.tsx
similarity index 93%
rename from packages/docusaurus-theme-common/src/contexts/docsVersion.tsx
rename to packages/docusaurus-plugin-content-docs/src/client/docsVersion.tsx
index 4a3ad576f917..d89f9827198c 100644
--- a/packages/docusaurus-theme-common/src/contexts/docsVersion.tsx
+++ b/packages/docusaurus-plugin-content-docs/src/client/docsVersion.tsx
@@ -6,7 +6,7 @@
*/
import React, {type ReactNode, useContext} from 'react';
-import {ReactContextError} from '../utils/reactUtils';
+import {ReactContextError} from '@docusaurus/theme-common/internal';
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
const Context = React.createContext(null);
diff --git a/packages/docusaurus-plugin-content-docs/src/client/index.ts b/packages/docusaurus-plugin-content-docs/src/client/index.ts
index 32dd0d926133..f60ba572faef 100644
--- a/packages/docusaurus-plugin-content-docs/src/client/index.ts
+++ b/packages/docusaurus-plugin-content-docs/src/client/index.ts
@@ -20,6 +20,45 @@ import {
} from './docsClientUtils';
import type {UseDataOptions} from '@docusaurus/types';
+export {
+ useDocById,
+ findSidebarCategory,
+ findFirstSidebarItemLink,
+ isActiveSidebarItem,
+ isVisibleSidebarItem,
+ useVisibleSidebarItems,
+ useSidebarBreadcrumbs,
+ useDocsVersionCandidates,
+ useLayoutDoc,
+ useLayoutDocsSidebar,
+ useDocRootMetadata,
+ useCurrentSidebarCategory,
+ filterDocCardListItems,
+} from './docsUtils';
+
+export {useDocsPreferredVersion} from './docsPreferredVersion';
+
+export {
+ DocSidebarItemsExpandedStateProvider,
+ useDocSidebarItemsExpandedState,
+} from './docSidebarItemsExpandedState';
+
+export {DocsVersionProvider, useDocsVersion} from './docsVersion';
+
+export {DocsSidebarProvider, useDocsSidebar} from './docsSidebar';
+
+export {DocProvider, useDoc, type DocContextValue} from './doc';
+
+export {
+ useDocsPreferredVersionByPluginId,
+ DocsPreferredVersionContextProvider,
+} from './docsPreferredVersion';
+
+export {
+ useDocsContextualSearchTags,
+ getDocsVersionSearchTag,
+} from './docsSearch';
+
export type ActivePlugin = {
pluginId: string;
pluginData: GlobalPluginData;
diff --git a/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx
index a0e4ec328308..06d3c4eab80f 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx
@@ -8,10 +8,8 @@
import React, {type ReactNode} from 'react';
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
-import {
- useSidebarBreadcrumbs,
- useHomePageRoute,
-} from '@docusaurus/theme-common/internal';
+import {useSidebarBreadcrumbs} from '@docusaurus/plugin-content-docs/client';
+import {useHomePageRoute} from '@docusaurus/theme-common/internal';
import Link from '@docusaurus/Link';
import {translate} from '@docusaurus/Translate';
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx
index 8348cf801459..f5539701a4b6 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx
@@ -9,9 +9,9 @@ import React, {type ReactNode} from 'react';
import clsx from 'clsx';
import Link from '@docusaurus/Link';
import {
- findFirstSidebarItemLink,
useDocById,
-} from '@docusaurus/theme-common/internal';
+ findFirstSidebarItemLink,
+} from '@docusaurus/plugin-content-docs/client';
import {usePluralForm} from '@docusaurus/theme-common';
import isInternalUrl from '@docusaurus/isInternalUrl';
import {translate} from '@docusaurus/Translate';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocCardList/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCardList/index.tsx
index cde4b22a74da..97b903c0030a 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocCardList/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocCardList/index.tsx
@@ -10,7 +10,7 @@ import clsx from 'clsx';
import {
useCurrentSidebarCategory,
filterDocCardListItems,
-} from '@docusaurus/theme-common';
+} from '@docusaurus/plugin-content-docs/client';
import DocCard from '@theme/DocCard';
import type {Props} from '@theme/DocCardList';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocCategoryGeneratedIndexPage/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCategoryGeneratedIndexPage/index.tsx
index 399957b6d387..9fd576f5369a 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocCategoryGeneratedIndexPage/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocCategoryGeneratedIndexPage/index.tsx
@@ -6,10 +6,8 @@
*/
import React from 'react';
-import {
- PageMetadata,
- useCurrentSidebarCategory,
-} from '@docusaurus/theme-common';
+import {PageMetadata} from '@docusaurus/theme-common';
+import {useCurrentSidebarCategory} from '@docusaurus/plugin-content-docs/client';
import useBaseUrl from '@docusaurus/useBaseUrl';
import DocCardList from '@theme/DocCardList';
import DocPaginator from '@theme/DocPaginator';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/Content/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/Content/index.tsx
index 7ac92026a05f..b1b36cb63677 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/Content/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/Content/index.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import {useDoc} from '@docusaurus/plugin-content-docs/client';
import Heading from '@theme/Heading';
import MDXContent from '@theme/MDXContent';
import type {Props} from '@theme/DocItem/Content';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/Footer/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/Footer/index.tsx
index 3757d1cac2ed..718aa5d45073 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/Footer/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/Footer/index.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import {useDoc} from '@docusaurus/plugin-content-docs/client';
import TagsListInline from '@theme/TagsListInline';
import EditMetaRow from '@theme/EditMetaRow';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/Layout/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/Layout/index.tsx
index 9c46677c7135..864a7896f367 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/Layout/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/Layout/index.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import clsx from 'clsx';
import {useWindowSize} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import {useDoc} from '@docusaurus/plugin-content-docs/client';
import DocItemPaginator from '@theme/DocItem/Paginator';
import DocVersionBanner from '@theme/DocVersionBanner';
import DocVersionBadge from '@theme/DocVersionBadge';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/Metadata/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/Metadata/index.tsx
index 3e75ee053a0d..3296fa747900 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/Metadata/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/Metadata/index.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import {PageMetadata} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import {useDoc} from '@docusaurus/plugin-content-docs/client';
export default function DocItemMetadata(): JSX.Element {
const {metadata, frontMatter, assets} = useDoc();
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/Paginator/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/Paginator/index.tsx
index 0ef558cb529e..69b1900d81f4 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/Paginator/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/Paginator/index.tsx
@@ -6,7 +6,7 @@
*/
import React from 'react';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import {useDoc} from '@docusaurus/plugin-content-docs/client';
import DocPaginator from '@theme/DocPaginator';
/**
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Desktop/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Desktop/index.tsx
index 14bf447cd855..a2d6438a61e5 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Desktop/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Desktop/index.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import {ThemeClassNames} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import {useDoc} from '@docusaurus/plugin-content-docs/client';
import TOC from '@theme/TOC';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Mobile/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Mobile/index.tsx
index c941e77b6274..3566e3bb5a68 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Mobile/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/TOC/Mobile/index.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import {useDoc} from '@docusaurus/plugin-content-docs/client';
import TOCCollapsible from '@theme/TOCCollapsible';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
index 3bde2a0c9927..1e26b215c35a 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import {HtmlClassNameProvider} from '@docusaurus/theme-common';
-import {DocProvider} from '@docusaurus/theme-common/internal';
+import {DocProvider} from '@docusaurus/plugin-content-docs/client';
import DocItemMetadata from '@theme/DocItem/Metadata';
import DocItemLayout from '@theme/DocItem/Layout';
import type {Props} from '@theme/DocItem';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Main/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Main/index.tsx
index b8432909ef37..9df2e2720823 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Main/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Main/index.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import clsx from 'clsx';
-import {useDocsSidebar} from '@docusaurus/theme-common/internal';
+import {useDocsSidebar} from '@docusaurus/plugin-content-docs/client';
import type {Props} from '@theme/DocRoot/Layout/Main';
import styles from './styles.module.css';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/index.tsx
index 36a50a58d92b..4bd5125a45bc 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/index.tsx
@@ -8,7 +8,7 @@
import React, {type ReactNode, useState, useCallback} from 'react';
import clsx from 'clsx';
import {prefersReducedMotion, ThemeClassNames} from '@docusaurus/theme-common';
-import {useDocsSidebar} from '@docusaurus/theme-common/internal';
+import {useDocsSidebar} from '@docusaurus/plugin-content-docs/client';
import {useLocation} from '@docusaurus/router';
import DocSidebar from '@theme/DocSidebar';
import ExpandButton from '@theme/DocRoot/Layout/Sidebar/ExpandButton';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/index.tsx
index 45a12d28cfe5..5babe460addc 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/index.tsx
@@ -6,7 +6,7 @@
*/
import React, {useState} from 'react';
-import {useDocsSidebar} from '@docusaurus/theme-common/internal';
+import {useDocsSidebar} from '@docusaurus/plugin-content-docs/client';
import BackToTopButton from '@theme/BackToTopButton';
import DocRootLayoutSidebar from '@theme/DocRoot/Layout/Sidebar';
import DocRootLayoutMain from '@theme/DocRoot/Layout/Main';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocRoot/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocRoot/index.tsx
index 8c5eb805d13f..c865b2c16652 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocRoot/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocRoot/index.tsx
@@ -11,7 +11,7 @@ import {HtmlClassNameProvider, ThemeClassNames} from '@docusaurus/theme-common';
import {
DocsSidebarProvider,
useDocRootMetadata,
-} from '@docusaurus/theme-common/internal';
+} from '@docusaurus/plugin-content-docs/client';
import DocRootLayout from '@theme/DocRoot/Layout';
import NotFoundContent from '@theme/NotFound/Content';
import type {Props} from '@theme/DocRoot';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx
index 06dad7c76a32..fcfbdfd08e20 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx
@@ -14,12 +14,12 @@ import {
Collapsible,
useCollapsible,
} from '@docusaurus/theme-common';
+import {isSamePath} from '@docusaurus/theme-common/internal';
import {
isActiveSidebarItem,
findFirstSidebarItemLink,
useDocSidebarItemsExpandedState,
- isSamePath,
-} from '@docusaurus/theme-common/internal';
+} from '@docusaurus/plugin-content-docs/client';
import Link from '@docusaurus/Link';
import {translate} from '@docusaurus/Translate';
import useIsBrowser from '@docusaurus/useIsBrowser';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx
index ffa8b0e89602..0b346e3456ea 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
-import {isActiveSidebarItem} from '@docusaurus/theme-common/internal';
+import {isActiveSidebarItem} from '@docusaurus/plugin-content-docs/client';
import Link from '@docusaurus/Link';
import isInternalUrl from '@docusaurus/isInternalUrl';
import IconExternalLink from '@theme/Icon/ExternalLink';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebarItems/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebarItems/index.tsx
index cf59b208d337..792d589feb71 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocSidebarItems/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocSidebarItems/index.tsx
@@ -9,7 +9,7 @@ import React, {memo} from 'react';
import {
DocSidebarItemsExpandedStateProvider,
useVisibleSidebarItems,
-} from '@docusaurus/theme-common/internal';
+} from '@docusaurus/plugin-content-docs/client';
import DocSidebarItem from '@theme/DocSidebarItem';
import type {Props} from '@theme/DocSidebarItems';
diff --git a/packages/docusaurus-theme-classic/src/theme/DocVersionBadge/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocVersionBadge/index.tsx
index d867068d0ad4..b1c373169342 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocVersionBadge/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocVersionBadge/index.tsx
@@ -9,7 +9,7 @@ import React from 'react';
import clsx from 'clsx';
import Translate from '@docusaurus/Translate';
import {ThemeClassNames} from '@docusaurus/theme-common';
-import {useDocsVersion} from '@docusaurus/theme-common/internal';
+import {useDocsVersion} from '@docusaurus/plugin-content-docs/client';
import type {Props} from '@theme/DocVersionBadge';
export default function DocVersionBadge({
diff --git a/packages/docusaurus-theme-classic/src/theme/DocVersionBanner/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocVersionBanner/index.tsx
index a9c1835bdf44..723efbf29d44 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocVersionBanner/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocVersionBanner/index.tsx
@@ -19,7 +19,7 @@ import {ThemeClassNames} from '@docusaurus/theme-common';
import {
useDocsPreferredVersion,
useDocsVersion,
-} from '@docusaurus/theme-common/internal';
+} from '@docusaurus/plugin-content-docs/client';
import type {Props} from '@theme/DocVersionBanner';
import type {
VersionBanner,
diff --git a/packages/docusaurus-theme-classic/src/theme/DocVersionRoot/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocVersionRoot/index.tsx
index 9c1952ce1b5c..dcac550b5cc3 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocVersionRoot/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocVersionRoot/index.tsx
@@ -8,9 +8,9 @@
import React from 'react';
import {HtmlClassNameProvider, PageMetadata} from '@docusaurus/theme-common';
import {
- docVersionSearchTag,
+ getDocsVersionSearchTag,
DocsVersionProvider,
-} from '@docusaurus/theme-common/internal';
+} from '@docusaurus/plugin-content-docs/client';
import renderRoutes from '@docusaurus/renderRoutes';
import SearchMetadata from '@theme/SearchMetadata';
@@ -22,7 +22,7 @@ function DocVersionRootMetadata(props: Props): JSX.Element {
<>
{version.noIndex && }
diff --git a/packages/docusaurus-theme-classic/src/theme/Layout/Provider/index.tsx b/packages/docusaurus-theme-classic/src/theme/Layout/Provider/index.tsx
index 690250554785..0ae6c0430b1d 100644
--- a/packages/docusaurus-theme-classic/src/theme/Layout/Provider/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/Layout/Provider/index.tsx
@@ -10,11 +10,11 @@ import {composeProviders} from '@docusaurus/theme-common';
import {
ColorModeProvider,
AnnouncementBarProvider,
- DocsPreferredVersionContextProvider,
ScrollControllerProvider,
NavbarProvider,
PluginHtmlClassNameProvider,
} from '@docusaurus/theme-common/internal';
+import {DocsPreferredVersionContextProvider} from '@docusaurus/plugin-content-docs/client';
import type {Props} from '@theme/Layout/Provider';
const Provider = composeProviders([
diff --git a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocNavbarItem.tsx b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocNavbarItem.tsx
index af745fd3a001..c4e9dc251bf1 100644
--- a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocNavbarItem.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocNavbarItem.tsx
@@ -6,8 +6,10 @@
*/
import React from 'react';
-import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
-import {useLayoutDoc} from '@docusaurus/theme-common/internal';
+import {
+ useActiveDocContext,
+ useLayoutDoc,
+} from '@docusaurus/plugin-content-docs/client';
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
import type {Props} from '@theme/NavbarItem/DocNavbarItem';
diff --git a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocSidebarNavbarItem.tsx b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocSidebarNavbarItem.tsx
index 2fefc7b3b2a9..d46c8af40704 100644
--- a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocSidebarNavbarItem.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocSidebarNavbarItem.tsx
@@ -6,8 +6,10 @@
*/
import React from 'react';
-import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
-import {useLayoutDocsSidebar} from '@docusaurus/theme-common/internal';
+import {
+ useActiveDocContext,
+ useLayoutDocsSidebar,
+} from '@docusaurus/plugin-content-docs/client';
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
import type {Props} from '@theme/NavbarItem/DocSidebarNavbarItem';
diff --git a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx
index 6e67d938954d..0f6ad2de5973 100644
--- a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx
@@ -9,9 +9,9 @@ import React from 'react';
import {
useVersions,
useActiveDocContext,
+ useDocsVersionCandidates,
+ useDocsPreferredVersion,
} from '@docusaurus/plugin-content-docs/client';
-import {useDocsPreferredVersion} from '@docusaurus/theme-common';
-import {useDocsVersionCandidates} from '@docusaurus/theme-common/internal';
import {translate} from '@docusaurus/Translate';
import {useLocation} from '@docusaurus/router';
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
diff --git a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionNavbarItem.tsx b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionNavbarItem.tsx
index 10d197992b7c..df694d125d8b 100644
--- a/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionNavbarItem.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionNavbarItem.tsx
@@ -6,7 +6,7 @@
*/
import React from 'react';
-import {useDocsVersionCandidates} from '@docusaurus/theme-common/internal';
+import {useDocsVersionCandidates} from '@docusaurus/plugin-content-docs/client';
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
import type {Props} from '@theme/NavbarItem/DocsVersionNavbarItem';
import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
diff --git a/packages/docusaurus-theme-common/package.json b/packages/docusaurus-theme-common/package.json
index 5bc7211f54ac..881d699ef56c 100644
--- a/packages/docusaurus-theme-common/package.json
+++ b/packages/docusaurus-theme-common/package.json
@@ -32,8 +32,6 @@
"dependencies": {
"@docusaurus/mdx-loader": "3.4.0",
"@docusaurus/module-type-aliases": "3.4.0",
- "@docusaurus/plugin-content-docs": "3.4.0",
- "@docusaurus/plugin-content-pages": "3.4.0",
"@docusaurus/utils": "3.4.0",
"@docusaurus/utils-common": "3.4.0",
"@types/history": "^4.7.11",
@@ -54,7 +52,8 @@
},
"peerDependencies": {
"react": "^18.0.0",
- "react-dom": "^18.0.0"
+ "react-dom": "^18.0.0",
+ "@docusaurus/plugin-content-docs": "*"
},
"engines": {
"node": ">=18.0"
diff --git a/packages/docusaurus-theme-common/src/index.ts b/packages/docusaurus-theme-common/src/index.ts
index 809a9e95a8f4..593da9842b34 100644
--- a/packages/docusaurus-theme-common/src/index.ts
+++ b/packages/docusaurus-theme-common/src/index.ts
@@ -5,6 +5,29 @@
* LICENSE file in the root directory of this source tree.
*/
+// 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
+// See https://github.com/facebook/docusaurus/pull/10316
+export function useCurrentSidebarCategory(...args: unknown[]): unknown {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ return require('@docusaurus/plugin-content-docs/client').useCurrentSidebarCategory(
+ ...args,
+ );
+}
+export function filterDocCardListItems(...args: unknown[]): unknown {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ return require('@docusaurus/plugin-content-docs/client').filterDocCardListItems(
+ ...args,
+ );
+}
+export function useDocsPreferredVersion(...args: unknown[]): unknown {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ return require('@docusaurus/plugin-content-docs/client').useDocsPreferredVersion(
+ ...args,
+ );
+}
+
/*
* APIs to document
*/
@@ -32,13 +55,6 @@ export {
listStorageKeys,
} from './utils/storageUtils';
-export {useContextualSearchFilters} from './utils/searchUtils';
-
-export {
- useCurrentSidebarCategory,
- filterDocCardListItems,
-} from './utils/docsUtils';
-
export {usePluralForm} from './utils/usePluralForm';
export {useCollapsible, Collapsible} from './components/Collapsible';
@@ -89,8 +105,6 @@ export {duplicates, uniq, groupBy} from './utils/jsUtils';
export {usePrismTheme} from './hooks/usePrismTheme';
-export {useDocsPreferredVersion} from './contexts/docsPreferredVersion';
-
export {processAdmonitionProps} from './utils/admonitionUtils';
export {
diff --git a/packages/docusaurus-theme-common/src/internal.ts b/packages/docusaurus-theme-common/src/internal.ts
index 166b723d935e..a31b19269f34 100644
--- a/packages/docusaurus-theme-common/src/internal.ts
+++ b/packages/docusaurus-theme-common/src/internal.ts
@@ -18,20 +18,6 @@
// eslint-disable-next-line no-restricted-syntax
export * from './index';
-export {
- DocSidebarItemsExpandedStateProvider,
- useDocSidebarItemsExpandedState,
-} from './contexts/docSidebarItemsExpandedState';
-export {DocsVersionProvider, useDocsVersion} from './contexts/docsVersion';
-export {DocsSidebarProvider, useDocsSidebar} from './contexts/docsSidebar';
-
-export {DocProvider, useDoc, type DocContextValue} from './contexts/doc';
-
-export {
- useDocsPreferredVersionByPluginId,
- DocsPreferredVersionContextProvider,
-} from './contexts/docsPreferredVersion';
-
export {
AnnouncementBarProvider,
useAnnouncementBar,
@@ -54,22 +40,7 @@ export {
containsLineNumbers,
} from './utils/codeBlockUtils';
-export {docVersionSearchTag, DEFAULT_SEARCH_TAG} from './utils/searchUtils';
-
-export {
- isDocsPluginEnabled,
- useDocById,
- findSidebarCategory,
- findFirstSidebarItemLink,
- isActiveSidebarItem,
- isVisibleSidebarItem,
- useVisibleSidebarItems,
- useSidebarBreadcrumbs,
- useDocsVersionCandidates,
- useLayoutDoc,
- useLayoutDocsSidebar,
- useDocRootMetadata,
-} from './utils/docsUtils';
+export {DEFAULT_SEARCH_TAG} from './utils/searchUtils';
export {useTitleFormatter} from './utils/generalUtils';
diff --git a/packages/docusaurus-theme-common/src/types.d.ts b/packages/docusaurus-theme-common/src/types.d.ts
index ba3c6b205c49..6f6f99f12793 100644
--- a/packages/docusaurus-theme-common/src/types.d.ts
+++ b/packages/docusaurus-theme-common/src/types.d.ts
@@ -6,4 +6,3 @@
*/
///
-///
diff --git a/packages/docusaurus-theme-common/src/utils/searchUtils.ts b/packages/docusaurus-theme-common/src/utils/searchUtils.ts
index 082f0fb7085c..f4d8b9a56c95 100644
--- a/packages/docusaurus-theme-common/src/utils/searchUtils.ts
+++ b/packages/docusaurus-theme-common/src/utils/searchUtils.ts
@@ -5,62 +5,4 @@
* LICENSE file in the root directory of this source tree.
*/
-import {
- useAllDocsData,
- useActivePluginAndVersion,
-} from '@docusaurus/plugin-content-docs/client';
-import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
-import {useDocsPreferredVersionByPluginId} from '../contexts/docsPreferredVersion';
-
export const DEFAULT_SEARCH_TAG = 'default';
-
-/** The search tag to append as each doc's metadata. */
-export function docVersionSearchTag(
- pluginId: string,
- versionName: string,
-): string {
- return `docs-${pluginId}-${versionName}`;
-}
-
-/**
- * Gets the relevant context information for contextual search.
- *
- * The value is generic and not coupled to Algolia/DocSearch, since we may want
- * to support multiple search engines, or allowing users to use their own search
- * engine solution.
- */
-export function useContextualSearchFilters(): {locale: string; tags: string[]} {
- const {i18n} = useDocusaurusContext();
- const allDocsData = useAllDocsData();
- const activePluginAndVersion = useActivePluginAndVersion();
- const docsPreferredVersionByPluginId = useDocsPreferredVersionByPluginId();
-
- // This can't use more specialized hooks because we are mapping over all
- // plugin instances.
- function getDocPluginTags(pluginId: string) {
- const activeVersion =
- activePluginAndVersion?.activePlugin.pluginId === pluginId
- ? activePluginAndVersion.activeVersion
- : undefined;
-
- const preferredVersion = docsPreferredVersionByPluginId[pluginId];
-
- const latestVersion = allDocsData[pluginId]!.versions.find(
- (v) => v.isLast,
- )!;
-
- const version = activeVersion ?? preferredVersion ?? latestVersion;
-
- return docVersionSearchTag(pluginId, version.name);
- }
-
- const tags = [
- DEFAULT_SEARCH_TAG,
- ...Object.keys(allDocsData).map(getDocPluginTags),
- ];
-
- return {
- locale: i18n.currentLocale,
- tags,
- };
-}
diff --git a/packages/docusaurus-theme-search-algolia/src/client/useAlgoliaContextualFacetFilters.ts b/packages/docusaurus-theme-search-algolia/src/client/useAlgoliaContextualFacetFilters.ts
index 212c03b4321b..45a334f479e2 100644
--- a/packages/docusaurus-theme-search-algolia/src/client/useAlgoliaContextualFacetFilters.ts
+++ b/packages/docusaurus-theme-search-algolia/src/client/useAlgoliaContextualFacetFilters.ts
@@ -5,11 +5,20 @@
* LICENSE file in the root directory of this source tree.
*/
-import {useContextualSearchFilters} from '@docusaurus/theme-common';
+import {DEFAULT_SEARCH_TAG} from '@docusaurus/theme-common/internal';
+import {useDocsContextualSearchTags} from '@docusaurus/plugin-content-docs/client';
+import useDocusaurusContext from '@docusaurus/core/src/client/exports/useDocusaurusContext';
-// Translate search-engine agnostic search filters to Algolia search filters
+function useSearchTags() {
+ // only docs have custom search tags per version
+ const docsTags = useDocsContextualSearchTags();
+ return [DEFAULT_SEARCH_TAG, ...docsTags];
+}
+
+// Translate search-engine agnostic search tags to Algolia search filters
export function useAlgoliaContextualFacetFilters(): [string, string[]] {
- const {locale, tags} = useContextualSearchFilters();
+ const locale = useDocusaurusContext().i18n.currentLocale;
+ const tags = useSearchTags();
// Seems safe to convert locale->language, see AlgoliaSearchMetadata comment
const languageFilter = `language:${locale}`;
diff --git a/website/src/components/Versions.tsx b/website/src/components/Versions.tsx
index 0dba8c7e26b2..74be4c26b4ea 100644
--- a/website/src/components/Versions.tsx
+++ b/website/src/components/Versions.tsx
@@ -12,8 +12,10 @@ import React, {
useRef,
type ReactNode,
} from 'react';
-import {useDocsPreferredVersion} from '@docusaurus/theme-common';
-import {useVersions} from '@docusaurus/plugin-content-docs/client';
+import {
+ useVersions,
+ useDocsPreferredVersion,
+} from '@docusaurus/plugin-content-docs/client';
import Translate from '@docusaurus/Translate';
import Link from '@docusaurus/Link';
import CodeBlock from '@theme/CodeBlock';
diff --git a/website/src/theme/DocCategoryGeneratedIndexPage/index.tsx b/website/src/theme/DocCategoryGeneratedIndexPage/index.tsx
index f758f09d8205..043356c195b4 100644
--- a/website/src/theme/DocCategoryGeneratedIndexPage/index.tsx
+++ b/website/src/theme/DocCategoryGeneratedIndexPage/index.tsx
@@ -6,7 +6,7 @@
*/
import React from 'react';
-import {useLayoutDoc} from '@docusaurus/theme-common/internal';
+import {useLayoutDoc} from '@docusaurus/plugin-content-docs/client';
import Link from '@docusaurus/Link';
import Translate from '@docusaurus/Translate';
import DocCategoryGeneratedIndexPage from '@theme-original/DocCategoryGeneratedIndexPage';