Skip to content

Commit

Permalink
fix: use the active plugin id when getting the current docs version
Browse files Browse the repository at this point in the history
Fixes #211
  • Loading branch information
Cyriuz committed Jun 12, 2022
1 parent 15f6161 commit 824e134
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
import { useHistory, useLocation } from "@docusaurus/router";
import { translate } from "@docusaurus/Translate";
import { useDocsPreferredVersion } from '@docusaurus/theme-common';
import { useActivePlugin } from '@docusaurus/plugin-content-docs/client';

import { fetchIndexes } from "./fetchIndexes";
import { SearchSourceFactory } from "../../utils/SearchSourceFactory";
Expand Down Expand Up @@ -48,7 +49,8 @@ export default function SearchBar({
let {
siteConfig: { baseUrl },
} = useDocusaurusContext();
const { preferredVersion } = useDocsPreferredVersion();
const { pluginId } = useActivePlugin({failfast: true})!;
const { preferredVersion } = useDocsPreferredVersion(pluginId);
let versionUrl = baseUrl;
if (preferredVersion && !preferredVersion.isLast) {
versionUrl = preferredVersion.path + "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Head from "@docusaurus/Head";
import Link from "@docusaurus/Link";
import { translate } from "@docusaurus/Translate";
import { usePluralForm, useDocsPreferredVersion } from "@docusaurus/theme-common";
import { useActivePlugin } from '@docusaurus/plugin-content-docs/client';

import useSearchQuery from "../hooks/useSearchQuery";
import { fetchIndexes } from "../SearchBar/fetchIndexes";
Expand All @@ -30,7 +31,8 @@ function SearchPageContent(): React.ReactElement {
let {
siteConfig: { baseUrl },
} = useDocusaurusContext();
const { preferredVersion } = useDocsPreferredVersion();
const { pluginId } = useActivePlugin({failfast: true})!;
const { preferredVersion } = useDocsPreferredVersion(pluginId);
if (preferredVersion && !preferredVersion.isLast) {
baseUrl = preferredVersion.path + "/";
}
Expand Down

0 comments on commit 824e134

Please sign in to comment.