11import React , { useState , useEffect } from 'react' ;
22import { RxGithubLogo } from "react-icons/rx" ;
33import { VscVscode } from "react-icons/vsc" ;
4- import { GITHUB_MAIN_REPO_SLUG , GITHUB_MAIN_REPO_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_INSTALLS_FALLBACK ,
9+ VSCODE_MARKETPLACE_URL ,
10+ } from '@site/src/constants' ;
511import styles from './styles.module.css' ;
612
713// Number formatting function
814function formatNumber ( num : number ) : string {
9- if ( num < 1000 ) {
15+ if ( num < 10000 ) {
1016 return num . toLocaleString ( ) ;
1117 }
1218
@@ -52,7 +58,7 @@ async function getVSCodeDownloads() {
5258 criteria : [
5359 {
5460 filterType : 7 ,
55- value : "RooVeterinaryInc.roo-cline" ,
61+ value : VSCODE_MARKETPLACE_EXTENSION_ID ,
5662 } ,
5763 ] ,
5864 } ,
@@ -75,7 +81,7 @@ async function getVSCodeDownloads() {
7581 return null ;
7682 }
7783
78- return formatNumber ( installStat . value ) ;
84+ return installStat . value ;
7985 } catch ( error ) {
8086 console . error ( "Error fetching VSCode downloads:" , error ) ;
8187 return null ;
@@ -84,7 +90,7 @@ async function getVSCodeDownloads() {
8490
8591export default function GitHubInstallButtons ( ) : React . JSX . Element {
8692 const [ stars , setStars ] = useState < string | null > ( null ) ;
87- const [ downloads , setDownloads ] = useState < string | null > ( "574.1k" ) ;
93+ const [ downloads , setDownloads ] = useState < string | null > ( formatNumber ( VSCODE_MARKETPLACE_INSTALLS_FALLBACK ) ) ;
8894
8995 useEffect ( ( ) => {
9096 // Fetch live data
@@ -93,7 +99,7 @@ export default function GitHubInstallButtons(): React.JSX.Element {
9399 } ) ;
94100
95101 getVSCodeDownloads ( ) . then ( count => {
96- if ( count ) setDownloads ( count ) ;
102+ if ( count ) setDownloads ( formatNumber ( Math . max ( count , VSCODE_MARKETPLACE_INSTALLS_FALLBACK ) ) ) ;
97103 } ) ;
98104 } , [ ] ) ;
99105
0 commit comments