From 0fb2e0acc72d29c0462a63bc0741246d3651f89b Mon Sep 17 00:00:00 2001 From: Stefan Pejcic Date: Tue, 18 Feb 2025 19:30:06 +0100 Subject: [PATCH] Update landing-hero-github-stars.tsx --- .../landing-hero-github-stars.tsx | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/website/src/refine-theme/landing-hero-github-stars.tsx b/website/src/refine-theme/landing-hero-github-stars.tsx index 18e0c572..ce8caed4 100644 --- a/website/src/refine-theme/landing-hero-github-stars.tsx +++ b/website/src/refine-theme/landing-hero-github-stars.tsx @@ -9,13 +9,13 @@ export const LandingHeroGithubStars = () => { // Function to fetch the latest version tag from Docker Hub const fetchVersion = async () => { try { - const response = await fetch('https://registry.hub.docker.com/v1/repositories/openpanel/openpanel/tags'); + const response = await fetch('https://hub.docker.com/v2/repositories/openpanel/openpanel/tags'); const data = await response.json(); - // Filter out 'latest' and sort the tags to find the highest version number - const versions = data - .map(tag => tag.name) - .filter(tag => /^\d+\.\d+\.\d+$/.test(tag)) // Only keep valid version tags + // Extract tags, filter out 'latest', sort, and get the latest numeric version + const tags = data.results.map(tag => tag.name); + const filteredTags = tags + .filter(tag => /^\d+\.\d+\.\d+$/.test(tag)) // Only valid version tags .sort((a, b) => { // Compare versions numerically const [majorA, minorA, patchA] = a.split('.').map(Number); @@ -25,10 +25,10 @@ export const LandingHeroGithubStars = () => { if (minorA !== minorB) return minorB - minorA; return patchB - patchA; }); - - if (versions.length > 0) { - setVersion(versions[0]); // Set the latest version (highest number) - } + + // Get the latest version from the sorted list + const latestVersion = filteredTags.length > 0 ? filteredTags[0] : '1.0.0'; // Default to '1.0.0' if no valid version found + setVersion(latestVersion); // Update the version state } catch (error) { console.error('Failed to fetch version:', error); } @@ -37,12 +37,6 @@ export const LandingHeroGithubStars = () => { fetchVersion(); }, []); // After initial render - // Function to format version for URL - const formatVersionForURL = (version) => { - const parts = version.split('.'); - return `${parts[0]}.${parts[1]}/#${parts[1]}${parts[2]}`; - }; - return (