File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,25 @@ export const IOS_APP_STORE_URL =
66export const ANDROID_PLAY_STORE_URL =
77 "https://play.google.com/store/apps/details?id=com.t3tools.t3code" ;
88
9+ // Runs at build time, so each deploy picks up the current count.
10+ async function fetchGithubStars ( ) : Promise < string > {
11+ const token = process . env . GITHUB_TOKEN ;
12+ try {
13+ const response = await fetch ( "https://api.github.com/repos/pingdotgg/t3code" , {
14+ headers : token ? { Authorization : `Bearer ${ token } ` } : { } ,
15+ } ) ;
16+ if ( ! response . ok ) throw new Error ( `GitHub API responded ${ response . status } ` ) ;
17+ const { stargazers_count : stars } = ( await response . json ( ) ) as { stargazers_count : number } ;
18+ return stars < 1000 ? String ( stars ) : `${ Math . floor ( stars / 1000 ) } k+` ;
19+ } catch ( error ) {
20+ // A deploy must not ship a made-up count; offline dev should still render.
21+ if ( import . meta. env . PROD ) throw new Error ( "Could not fetch GitHub stars" , { cause : error } ) ;
22+ console . warn ( "Could not fetch GitHub stars" , error ) ;
23+ return "?" ;
24+ }
25+ }
26+
927export const MARKETING_STATS = {
10- githubStars : "40k+" ,
28+ githubStars : await fetchGithubStars ( ) ,
1129 users : "500,000" ,
1230} as const ;
You can’t perform that action at this time.
0 commit comments