11import React , { useState , useEffect } from 'react' ;
22import { RxGithubLogo } from "react-icons/rx" ;
33import { VscVscode } from "react-icons/vsc" ;
4- import { GITHUB_MAIN_REPO_URL , SIGN_IN_URL , SIGN_UP_URL , VSCODE_MARKETPLACE_URL } from '@site/src/constants' ;
4+ import {
5+ GITHUB_MAIN_REPO_SLUG ,
6+ GITHUB_MAIN_REPO_URL ,
7+ VSCODE_MARKETPLACE_EXTENSION_ID ,
8+ VSCODE_MARKETPLACE_URL ,
9+ } from '@site/src/constants' ;
510import styles from './styles.module.css' ;
611
712// Number formatting function
813function formatNumber ( num : number ) : string {
14+ if ( num < 10000 ) {
15+ return num . toLocaleString ( ) ;
16+ }
17+
918 if ( num >= 1000000 ) {
1019 const truncated = Math . floor ( ( num / 1000000 ) * 10 ) / 10 ;
1120 return truncated . toFixed ( 1 ) + "M" ;
1221 }
22+
1323 const truncated = Math . floor ( ( num / 1000 ) * 10 ) / 10 ;
1424 return truncated . toFixed ( 1 ) + "k" ;
1525}
1626
1727// GitHub Stars API
1828async function getGitHubStars ( ) {
1929 try {
20- const res = await fetch ( " https://api.github.com/repos/RooCodeInc/Roo-Code" ) ;
30+ const res = await fetch ( ` https://api.github.com/repos/${ GITHUB_MAIN_REPO_SLUG } ` ) ;
2131 const data = await res . json ( ) ;
2232
2333 if ( typeof data . stargazers_count !== "number" ) {
@@ -47,7 +57,7 @@ async function getVSCodeDownloads() {
4757 criteria : [
4858 {
4959 filterType : 7 ,
50- value : "RooVeterinaryInc.roo-cline" ,
60+ value : VSCODE_MARKETPLACE_EXTENSION_ID ,
5161 } ,
5262 ] ,
5363 } ,
@@ -70,16 +80,16 @@ async function getVSCodeDownloads() {
7080 return null ;
7181 }
7282
73- return formatNumber ( installStat . value ) ;
83+ return installStat . value ;
7484 } catch ( error ) {
7585 console . error ( "Error fetching VSCode downloads:" , error ) ;
7686 return null ;
7787 }
7888}
7989
8090export default function GitHubInstallButtons ( ) : React . JSX . Element {
81- const [ stars , setStars ] = useState < string | null > ( "15.4k" ) ;
82- const [ downloads , setDownloads ] = useState < string | null > ( "574.1k" ) ;
91+ const [ stars , setStars ] = useState < string | null > ( null ) ;
92+ const [ downloads , setDownloads ] = useState < string | null > ( null ) ;
8393
8494 useEffect ( ( ) => {
8595 // Fetch live data
@@ -88,7 +98,7 @@ export default function GitHubInstallButtons(): React.JSX.Element {
8898 } ) ;
8999
90100 getVSCodeDownloads ( ) . then ( count => {
91- if ( count ) setDownloads ( count ) ;
101+ if ( count ) setDownloads ( formatNumber ( count ) ) ;
92102 } ) ;
93103 } , [ ] ) ;
94104
@@ -122,4 +132,4 @@ export default function GitHubInstallButtons(): React.JSX.Element {
122132 </ a >
123133 </ div >
124134 ) ;
125- }
135+ }
0 commit comments