diff --git a/web/src/components/Installation/index.tsx b/web/src/components/Installation/index.tsx index b2223c4..b149709 100644 --- a/web/src/components/Installation/index.tsx +++ b/web/src/components/Installation/index.tsx @@ -1,17 +1,15 @@ import {ReactElement} from 'react'; import CodeBlock from '@theme/CodeBlock'; import {useActiveVersion} from '@docusaurus/plugin-content-docs/client'; -import {useCurrentVersion} from '@site/src/hooks/versions'; // InstallationSnippet is the kubectl incantation to install the Barman // Cloud Plugin: the manifest matching the doc version being viewed, or // (on the unreleased "current" docs) the latest manifest on main. export function InstallationSnippet(): ReactElement { const activeVersion = useActiveVersion('default'); - const version = useCurrentVersion('latest'); - const url = activeVersion?.name === 'current' - ? 'https://raw.githubusercontent.com/cloudnative-pg/plugin-barman-cloud/refs/heads/main/manifest.yaml' - : `https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v${version}/manifest.yaml`; + const url = activeVersion && activeVersion.name !== 'current' + ? `https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v${activeVersion.name}/manifest.yaml` + : 'https://raw.githubusercontent.com/cloudnative-pg/plugin-barman-cloud/refs/heads/main/manifest.yaml'; return ( {`kubectl apply -f \\ diff --git a/web/src/hooks/versions.ts b/web/src/hooks/versions.ts deleted file mode 100644 index af79a70..0000000 --- a/web/src/hooks/versions.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {useActiveVersion, useLatestVersion} from '@docusaurus/plugin-content-docs/client'; - - -export function useCurrentVersion(fallback: 'latest' | 'latestReleased' = 'latest'): string { - switch (fallback) { - case 'latestReleased': - return useLatestReleasedVersion(); - case 'latest': { - const version = useActiveVersion('default'); - if (version && version.name !== 'current') { - return version.name; - } - return useLatestReleasedVersion(); - } - default: - // The following line ensures that if `fallback` is not 'latest' or 'latestReleased', - // an error is thrown. This can be useful for catching unexpected states. - throw new Error(`Unhandled fallback type: ${fallback}`); - } -} - -export function useLatestReleasedVersion(): string { - return useLatestVersion('default').name; -}