11import Image from 'next/image' ;
22import Link from 'next/link' ;
3- import { FaGithub , FaStar , FaWindows , FaApple , FaLinux } from 'react-icons/fa' ;
3+ import { FaGithub , FaStar , FaWindows , FaApple , FaLinux , FaDownload } from 'react-icons/fa' ;
4+ import { getLatestVersionDataFOrThisPlatform } from '@/libs/helper' ;
45
56// Fetch GitHub stats at build time (SSR)
67async function getGitHubStats ( ) {
@@ -19,26 +20,45 @@ async function getGitHubStats() {
1920 }
2021}
2122
22- // Fetch latest release version from GitHub
23- async function getLatestVersion ( ) {
24- try {
25- const res = await fetch ( 'https://api.github.com/repos/codad5/google-task-desktop/releases/latest' , {
26- next : { revalidate : 3600 } // Revalidate every hour
27- } ) ;
28- if ( ! res . ok ) return 'latest' ;
29- const data = await res . json ( ) ;
30- return data . tag_name || data . name || 'latest' ;
31- } catch {
32- return 'latest' ;
23+ // Get platform icon based on OS
24+ function getPlatformIcon ( platform : string | undefined ) {
25+ switch ( platform ) {
26+ case 'windows' :
27+ return FaWindows ;
28+ case 'mac' :
29+ case 'darwin' :
30+ return FaApple ;
31+ case 'linux' :
32+ return FaLinux ;
33+ default :
34+ return FaDownload ;
35+ }
36+ }
37+
38+ // Get platform name for display
39+ function getPlatformName ( platform : string | undefined ) {
40+ switch ( platform ) {
41+ case 'windows' :
42+ return 'Windows' ;
43+ case 'mac' :
44+ case 'darwin' :
45+ return 'macOS' ;
46+ case 'linux' :
47+ return 'Linux' ;
48+ default :
49+ return '' ;
3350 }
3451}
3552
3653export default async function Hero ( ) {
37- const [ githubStats , latestVersion ] = await Promise . all ( [
54+ const [ githubStats , platformData ] = await Promise . all ( [
3855 getGitHubStats ( ) ,
39- getLatestVersion ( ) ,
56+ getLatestVersionDataFOrThisPlatform ( ) ,
4057 ] ) ;
4158
59+ const PlatformIcon = getPlatformIcon ( platformData ?. platform ) ;
60+ const platformName = getPlatformName ( platformData ?. platform ) ;
61+
4262 return (
4363 < section className = "relative flex flex-col items-center justify-center px-6 py-20" >
4464 { /* Background gradient blob */ }
@@ -96,17 +116,23 @@ export default async function Hero() {
96116
97117 { /* Download Buttons */ }
98118 < div className = "flex flex-col items-center gap-4 w-full sm:flex-row sm:justify-center" >
99- < Link
100- href = "https://github.com/codad5/google-task-desktop/releases/latest"
101- className = "btn-primary flex items-center justify-center gap-2 w-full sm:w-auto"
102- >
103- Download { latestVersion }
104- < span className = "flex items-center gap-1" >
105- < FaWindows className = "text-sm" />
106- < FaApple className = "text-sm" />
107- < FaLinux className = "text-sm" />
108- </ span >
109- </ Link >
119+ { platformData ?. url ? (
120+ < Link
121+ href = { platformData . url }
122+ className = "btn-primary flex items-center justify-center gap-3 w-full sm:w-auto"
123+ >
124+ < PlatformIcon className = "text-xl" />
125+ < span > Download { platformData . version } for { platformName } </ span >
126+ </ Link >
127+ ) : (
128+ < Link
129+ href = "https://github.com/codad5/google-task-desktop/releases/latest"
130+ className = "btn-primary flex items-center justify-center gap-2 w-full sm:w-auto"
131+ >
132+ < FaDownload />
133+ Download Latest
134+ </ Link >
135+ ) }
110136
111137 < Link
112138 href = "https://github.com/codad5/google-task-desktop"
@@ -118,10 +144,17 @@ export default async function Hero() {
118144 </ Link >
119145 </ div >
120146
121- { /* Version badge */ }
122- < p className = "text-sm text-[var(--color-text-muted)] text-center" >
123- { latestVersion !== 'latest' ? latestVersion : '' } • Available for Windows, macOS, and Linux
124- </ p >
147+ { /* Other platforms link */ }
148+ < Link
149+ href = "https://github.com/codad5/google-task-desktop/releases/latest"
150+ target = "_blank"
151+ className = "text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors"
152+ >
153+ Also available for{ ' ' }
154+ { platformData ?. platform !== 'windows' && 'Windows, ' }
155+ { platformData ?. platform !== 'mac' && platformData ?. platform !== 'darwin' && 'macOS, ' }
156+ { platformData ?. platform !== 'linux' && 'Linux' }
157+ </ Link >
125158 </ div >
126159 </ section >
127160 ) ;
0 commit comments