/**
* 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 React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Link from '@docusaurus/Link';
import Translate from '@docusaurus/Translate';
import {
useActivePlugin,
useActiveVersion,
useDocVersionSuggestions,
} from '@theme/hooks/useDocs';
import { useDocsPreferredVersion } from '@docusaurus/theme-common';
function UnreleasedVersionLabel({ siteTitle, versionLabel }) {
return (
{versionLabel},
latestVersionLink: (
docs
),
}}>
{
'This is unreleased documentation for {siteTitle} {versionLabel} version. For up-to-date documentation, see OHIF v2.0 {latestVersionLink}.'
}
);
}
function UnmaintainedVersionLabel({ siteTitle, versionLabel }) {
return (
{versionLabel},
}}>
{
'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.'
}
);
}
function LatestVersionSuggestionLabel({ versionLabel, to, onClick }) {
return (
latest version
),
}}>
{
'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).'
}
);
}
const getVersionMainDoc = (version) =>
version.docs.find((doc) => doc.id === version.mainDocId);
function DocVersionSuggestions() {
const {
siteConfig: { title: siteTitle },
} = useDocusaurusContext();
const { pluginId } = useActivePlugin({
failfast: true,
});
const { savePreferredVersionName } = useDocsPreferredVersion(pluginId);
const activeVersion = useActiveVersion(pluginId);
const {
latestDocSuggestion,
latestVersionSuggestion,
} = useDocVersionSuggestions(pluginId); // No suggestion to be made
if (!latestVersionSuggestion) {
return <>>;
} // try to link to same doc in latest version (not always possible)
// fallback to main doc of latest version
const latestVersionSuggestedDoc =
latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
return (