From a28fd191131102cac1985e96780550dac4f762c7 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Tue, 25 Aug 2026 12:23:25 +0200 Subject: [PATCH] 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 463e0f5..af79a70 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; }