From cc180de661f68269d6e45a978fbb45d4fcaef7de Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Tue, 25 Aug 2026 12:23:09 +0200 Subject: [PATCH 1/4] docs(web): use active doc version for install manifest link The install snippet always linked to the manifest of the latest released version, regardless of which versioned docs page it was rendered on. Viewing the 0.13.0 installation page therefore pointed at the 0.14.0 manifest. Fall back to the latest released version only when there is no active version, or the active version is the unreleased "current" docs. Signed-off-by: Marco Nenciarini --- web/src/components/Installation/index.tsx | 3 +-- web/src/hooks/versions.ts | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/components/Installation/index.tsx b/web/src/components/Installation/index.tsx index 064a0ead..9bf8fcae 100644 --- a/web/src/components/Installation/index.tsx +++ b/web/src/components/Installation/index.tsx @@ -5,7 +5,7 @@ import {useCurrentVersion} from '@site/src/hooks/versions'; // InstallationSnippet is the kubectl incantation to install the lastest // available version of the Barman Cloud Plugin. export function InstallationSnippet(): ReactElement { - const latest = useCurrentVersion('latestReleased'); + const latest = useCurrentVersion('latest'); return ( {`kubectl apply -f \\ @@ -13,4 +13,3 @@ export function InstallationSnippet(): ReactElement { ); } - diff --git a/web/src/hooks/versions.ts b/web/src/hooks/versions.ts index 785cc2fb..463e0f5f 100644 --- a/web/src/hooks/versions.ts +++ b/web/src/hooks/versions.ts @@ -7,7 +7,10 @@ export function useCurrentVersion(fallback: 'latest' | 'latestReleased' = 'lates return useLatestReleasedVersion(); case 'latest': { const version = useActiveVersion('default'); - return version?.name ?? useLatestVersion('default')?.name; + if (version && version.name !== 'current') { + return version.name; + } + return useLatestReleasedVersion(); } default: // The following line ensures that if `fallback` is not 'latest' or 'latestReleased', From 245d74421028dc35bad86424d02b5e97dd277932 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Tue, 25 Aug 2026 12:23:25 +0200 Subject: [PATCH 2/4] refactor(web): simplify useLatestReleasedVersion Docusaurus already exposes the latest released version via useLatestVersion (backed by GlobalVersion.isLast), making the manual filter and numeric-string sort redundant. Signed-off-by: Marco Nenciarini --- web/src/hooks/versions.ts | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/web/src/hooks/versions.ts b/web/src/hooks/versions.ts index 463e0f5f..af79a700 100644 --- a/web/src/hooks/versions.ts +++ b/web/src/hooks/versions.ts @@ -1,4 +1,4 @@ -import {useActiveVersion, useLatestVersion, useVersions} from '@docusaurus/plugin-content-docs/client'; +import {useActiveVersion, useLatestVersion} from '@docusaurus/plugin-content-docs/client'; export function useCurrentVersion(fallback: 'latest' | 'latestReleased' = 'latest'): string { @@ -20,20 +20,5 @@ export function useCurrentVersion(fallback: 'latest' | 'latestReleased' = 'lates } export function useLatestReleasedVersion(): string { - const allVersions = useVersions('default'); - - // Filter out "current" to only consider versioned docs - const versionedDocs = allVersions.filter(version => version.name !== 'current'); - - // Handle the case where no versioned documents are found - if (versionedDocs.length === 0) { - return "unknown_version"; - } - - const sortedVersions = versionedDocs.sort((a, b) => { - return b.name.localeCompare(a.name, undefined, { numeric: true, sensitivity: 'base' }); - }); - - // The latest version is the first in the sorted list since versionedDocs was not empty, - return sortedVersions[0].name; + return useLatestVersion('default').name; } From 766d6f72a2dd041a801e7bc14413ef38b88cb223 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Tue, 25 Aug 2026 12:23:36 +0200 Subject: [PATCH 3/4] feat(web): point unreleased docs install snippet at main manifest The unversioned "current" docs describe unreleased functionality, so a tagged release manifest doesn't make sense there. Install from the manifest built off main instead. Signed-off-by: Marco Nenciarini --- web/src/components/Installation/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/web/src/components/Installation/index.tsx b/web/src/components/Installation/index.tsx index 9bf8fcae..b2223c47 100644 --- a/web/src/components/Installation/index.tsx +++ b/web/src/components/Installation/index.tsx @@ -1,15 +1,21 @@ 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 lastest -// available version of the Barman Cloud Plugin. +// 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 latest = useCurrentVersion('latest'); + 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`; return ( {`kubectl apply -f \\ - https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v${latest}/manifest.yaml`} + ${url}`} ); } From 8a9aae168a1ac632c948c21958619b451dbcfa8e Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Tue, 25 Aug 2026 14:06:27 +0200 Subject: [PATCH 4/4] refactor(web): drop the now-dead useCurrentVersion abstraction useCurrentVersion's 'latestReleased' branch had no remaining caller after the previous commit, and InstallationSnippet was calling useActiveVersion twice (once directly, once through the hook) to re-run the same check. Build the manifest URL straight from the active version and drop hooks/versions.ts entirely. Signed-off-by: Marco Nenciarini --- web/src/components/Installation/index.tsx | 8 +++----- web/src/hooks/versions.ts | 24 ----------------------- 2 files changed, 3 insertions(+), 29 deletions(-) delete mode 100644 web/src/hooks/versions.ts diff --git a/web/src/components/Installation/index.tsx b/web/src/components/Installation/index.tsx index b2223c47..b149709e 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 af79a700..00000000 --- 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; -}