Add GitHub star count to website header#174
Conversation
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
🚀 Preview DeploymentA preview build has been generated for this PR! Download the artifact: To view the preview locally:
Live Preview URL: https://0f2c01a3.razorconsole.pages.dev The live preview will be automatically updated when you push new |
|
@copilot use a more tiny version, like below
|
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
…f 2.0k) Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a GitHub star count display to the website header by introducing a new React hook that fetches repository data from the GitHub API and integrating it into the navigation bar. The star count appears next to the GitHub icon with smart formatting (e.g., "2k" for 2000 stars).
Key changes:
- New custom hook
useGitHubStarsfor fetching and managing star count state - Updated Layout component to display formatted star count in the header button
- Desktop-only display with graceful fallback when stars aren't loaded
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| website/src/hooks/useGitHubStars.ts | New hook that fetches GitHub repository star count with proper cleanup using AbortController |
| website/src/components/Layout.tsx | Integrates the star count hook and displays formatted stars next to the GitHub icon in the header |
|
|
||
| export default function Layout() { | ||
| const [mobileMenuOpen, setMobileMenuOpen] = useState(false) | ||
| const { stars } = useGitHubStars('LittleLittleCloud', 'RazorConsole') |
There was a problem hiding this comment.
The loading and error values returned from the useGitHubStars hook are destructured but never used in the component. Consider using these values to provide better user feedback:
- Show a loading indicator while fetching
- Display an error message or fallback UI when the fetch fails
- Alternatively, if these states are intentionally ignored, remove them from the destructured return value to make the intent clearer.
website/src/components/Layout.tsx
Outdated
| <Button variant="ghost" size="sm" className="gap-1.5"> | ||
| <Github className="w-5 h-5" /> | ||
| {stars !== null && ( | ||
| <span className="text-sm font-medium"> | ||
| {stars >= 1000 | ||
| ? `${(stars / 1000).toFixed(1).replace(/\.0$/, '')}k` | ||
| : stars.toLocaleString()} | ||
| </span> | ||
| )} | ||
| </Button> |
There was a problem hiding this comment.
The button lacks an accessible label for screen readers. When the star count is not loaded (null), the button only contains the GitHub icon without any text, making it unclear to screen reader users what the button represents. Consider adding an aria-label attribute (e.g., aria-label="View on GitHub" or dynamically aria-label={stars !== null ? GitHub - ${stars} stars : "View on GitHub"}) to improve accessibility.
| // Ignore abort errors | ||
| if (err instanceof Error && err.name === 'AbortError') { | ||
| return | ||
| } |
There was a problem hiding this comment.
When an error occurs, the stars state is not reset. This means if the hook successfully fetched stars previously, it will continue to display the old star count even when an error occurs on subsequent fetches. Consider adding setStars(null) in the error handling block to ensure the UI reflects the error state correctly.
| } | |
| } | |
| setStars(null) |
website/src/components/Layout.tsx
Outdated
| <Button variant="ghost" size="sm"> | ||
| <Github className="w-4 h-4 mr-2" /> | ||
| GitHub | ||
| <Button variant="ghost" size="sm" className="gap-1.5"> |
…r, reset stars on error Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
website/src/components/Layout.tsx
Outdated
| <Button | ||
| variant="ghost" | ||
| size="sm" | ||
| className="gap-1.5 cursor-default" |
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>




Adding GitHub star count display to the website app bar header.
Plan:
Implementation Details
Created
src/hooks/useGitHubStars.ts:Updated
src/components/Layout.tsx:hover:cursor-pointer) provides visual feedback for clickabilitygap-1.5for tight spacing between icon and numberVisual Changes
Compact Version (Current)
The new compact design shows:
Accessibility Improvements
Graceful Degradation
The implementation handles edge cases elegantly:
Quality Assurance
Files Changed
website/src/components/Layout.tsx(compact design with aria-label and hover cursor)website/src/hooks/useGitHubStars.ts(resets stars on error)<issue_title>[Feature]: show GitHub stars on webside</issue_title>
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.