Skip to content

Commit a99a46e

Browse files
Merge pull request #3 from Zoo-Code-Org/fix/zoo-code-docs-references-2o7fa8fc0aexl
[Fix] Docs navbar shows the wrong GitHub and VS Code counts
2 parents d231b8b + b83fad3 commit a99a46e

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/components/GitHubInstallButtons/index.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
import React, { useState, useEffect } from 'react';
22
import { RxGithubLogo } from "react-icons/rx";
33
import { 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';
510
import styles from './styles.module.css';
611

712
// Number formatting function
813
function 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
1828
async 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

8090
export 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+
}

src/constants.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
*/
44

55
// GitHub repository information
6-
export const GITHUB_REPO_URL = 'https://github.com/Zoo-Code-Org/Zoo-Code-Docs';
6+
export const GITHUB_REPO_SLUG = 'Zoo-Code-Org/Zoo-Code-Docs';
7+
export const GITHUB_REPO_URL = `https://github.com/${GITHUB_REPO_SLUG}`;
78
export const GITHUB_ISSUES_URL = `${GITHUB_REPO_URL}/issues`;
89
export const GITHUB_NEW_ISSUE_URL = `${GITHUB_ISSUES_URL}/new`;
910

@@ -14,11 +15,13 @@ export const TWITTER_URL = 'https://x.com/ZooCodeDev';
1415
export const LINKEDIN_URL = 'https://www.linkedin.com';
1516

1617
// GitHub links
17-
export const GITHUB_MAIN_REPO_URL = 'https://github.com/Zoo-Code-Org/Zoo-Code';
18+
export const GITHUB_MAIN_REPO_SLUG = 'Zoo-Code-Org/Zoo-Code';
19+
export const GITHUB_MAIN_REPO_URL = `https://github.com/${GITHUB_MAIN_REPO_SLUG}`;
1820
export const GITHUB_ISSUES_MAIN_URL = `${GITHUB_MAIN_REPO_URL}/issues`;
1921
export const GITHUB_FEATURES_URL = `${GITHUB_MAIN_REPO_URL}/discussions/categories/feature-requests?discussions_q=is%3Aopen+category%3A%22Feature+Requests%22+sort%3Atop`;
2022

2123
// Download links
24+
export const VSCODE_MARKETPLACE_EXTENSION_ID = 'ZooCodeOrganization.zoo-code';
2225
export const VSCODE_MARKETPLACE_URL = 'https://marketplace.visualstudio.com/items?itemName=ZooCodeOrganization.zoo-code';
2326
export const OPEN_VSX_URL = 'https://open-vsx.org/extension/ZooCodeOrganization.zoo-code';
2427

0 commit comments

Comments
 (0)