Skip to content

Commit f3d75d8

Browse files
committed
Fix styling, update deps
1 parent c6fa62d commit f3d75d8

File tree

6 files changed

+334
-21
lines changed

6 files changed

+334
-21
lines changed

docusaurus.config.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ async function getGitHubStars(): Promise<string> {
1010
return stars >= 1000 ? `${(stars / 1000).toFixed(1)}K` : stars.toString();
1111
} catch (error) {
1212
console.error("Failed to fetch GitHub stars:", error);
13-
return "3.1K";
13+
return "3.2K";
1414
}
1515
}
1616

1717
export default async function createConfig(): Promise<Config> {
1818
const githubStars = await getGitHubStars();
1919

20-
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
21-
2220
const config: Config = {
2321
title: "Hyper-Efficient Message Streaming at Laser Speed.",
2422
tagline:
@@ -132,9 +130,9 @@ export default async function createConfig(): Promise<Config> {
132130
position: "left",
133131
},
134132
{
135-
href: "https://github.com/apache/iggy",
136-
label: `GitHub ⭐ ${githubStars}`,
133+
type: "html",
137134
position: "right",
135+
value: `<a href="https://github.com/apache/iggy" target="_blank" rel="noopener noreferrer" class="navbar__link">GitHub ⭐ <span id="github-stars">${githubStars}</span></a>`,
138136
},
139137
{
140138
type: "dropdown",

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { useEffect, useState } from 'react';
2+
3+
export default function GitHubStars(): JSX.Element {
4+
const [stars, setStars] = useState('3.2K'); // fallback
5+
6+
useEffect(() => {
7+
fetch('https://api.github.com/repos/apache/iggy')
8+
.then(res => res.json())
9+
.then(data => {
10+
const count = data.stargazers_count;
11+
const formatted = count >= 1000
12+
? `${(count / 1000).toFixed(1)}K`
13+
: count.toString();
14+
setStars(formatted);
15+
})
16+
.catch(() => {
17+
// Keep fallback value on error
18+
});
19+
}, []);
20+
21+
return <>{stars}</>;
22+
}

0 commit comments

Comments
 (0)