Compare commits

...

5 Commits

Author SHA1 Message Date
Marco Nenciarini
08f03acf89
Merge 8a9aae168a into f9a7ead831 2026-08-27 09:46:34 +02:00
Marco Nenciarini
8a9aae168a
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 <marco.nenciarini@enterprisedb.com>
2026-08-25 14:06:27 +02:00
Marco Nenciarini
766d6f72a2
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 <marco.nenciarini@enterprisedb.com>
2026-08-25 12:23:36 +02:00
Marco Nenciarini
245d744210
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 <marco.nenciarini@enterprisedb.com>
2026-08-25 12:23:25 +02:00
Marco Nenciarini
cc180de661
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 <marco.nenciarini@enterprisedb.com>
2026-08-25 12:23:09 +02:00
2 changed files with 9 additions and 42 deletions

View File

@ -1,16 +1,19 @@
import {ReactElement} from 'react'; import {ReactElement} from 'react';
import CodeBlock from '@theme/CodeBlock'; import CodeBlock from '@theme/CodeBlock';
import {useCurrentVersion} from '@site/src/hooks/versions'; import {useActiveVersion} from '@docusaurus/plugin-content-docs/client';
// InstallationSnippet is the kubectl incantation to install the lastest // InstallationSnippet is the kubectl incantation to install the Barman
// available version of the Barman Cloud Plugin. // 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<null> { export function InstallationSnippet(): ReactElement<null> {
const latest = useCurrentVersion('latestReleased'); const activeVersion = useActiveVersion('default');
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 ( return (
<CodeBlock language="sh"> <CodeBlock language="sh">
{`kubectl apply -f \\ {`kubectl apply -f \\
https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v${latest}/manifest.yaml`} ${url}`}
</CodeBlock> </CodeBlock>
); );
} }

View File

@ -1,36 +0,0 @@
import {useActiveVersion, useLatestVersion, useVersions} 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');
return version?.name ?? useLatestVersion('default')?.name;
}
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 {
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;
}