Skip to content

Commit 2c05d08

Browse files
authored
fix: use PH embed badge image with live upvote count (#49)
1 parent 51b62d1 commit 2c05d08

File tree

2 files changed

+9
-36
lines changed

2 files changed

+9
-36
lines changed

docs/skillkit/App.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,14 @@ export default function App(): React.ReactElement {
174174
href="https://www.producthunt.com/products/skillkit-2?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-skillkit-2"
175175
target="_blank"
176176
rel="noopener noreferrer"
177-
className="hidden sm:flex items-center gap-1.5 text-zinc-500 hover:text-white transition-colors group"
177+
className="hidden sm:inline-flex items-center hover:opacity-80 transition-opacity"
178178
>
179-
<svg className="w-3 h-3 text-[#da552f] group-hover:text-[#ff6154]" viewBox="0 0 24 24" fill="currentColor">
180-
<path d="M13.604 8.4h-3.405V12h3.405a1.8 1.8 0 0 0 0-3.6zM12 0C5.372 0 0 5.372 0 12s5.372 12 12 12 12-5.372 12-12S18.628 0 12 0zm1.604 14.4h-3.405V18H7.801V6h5.804a4.2 4.2 0 0 1 0 8.4z"/>
181-
</svg>
182-
<span className="text-zinc-400 group-hover:text-white font-medium">Featured</span>
183-
{stats.phUpvotes > 0 && (
184-
<>
185-
<span className="text-zinc-700 mx-0.5">·</span>
186-
<svg className="w-3 h-3 text-[#da552f]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
187-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2.5} d="M5 15l7-7 7 7" />
188-
</svg>
189-
<span className="text-white font-medium">{stats.phUpvotes}</span>
190-
</>
191-
)}
179+
<img
180+
src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1071813&theme=dark"
181+
alt="SkillKit on Product Hunt"
182+
height="28"
183+
style={{ height: '28px', width: 'auto' }}
184+
/>
192185
</a>
193186
</div>
194187
</div>

docs/skillkit/hooks/useStats.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ interface Stats {
44
version: string;
55
downloads: string;
66
stars: number;
7-
phUpvotes: number;
87
loading: boolean;
98
}
109

@@ -58,7 +57,6 @@ export function useStats(): Stats {
5857
version: '1.9.0',
5958
downloads: '2.4k',
6059
stars: 66,
61-
phUpvotes: 0,
6260
loading: true,
6361
});
6462

@@ -71,19 +69,13 @@ export function useStats(): Stats {
7169

7270
async function fetchStats(): Promise<void> {
7371
try {
74-
const [npmResponse, githubResponse, phResponse] = await Promise.allSettled([
72+
const [npmResponse, githubResponse] = await Promise.allSettled([
7573
fetch('https://api.npmjs.org/downloads/point/last-month/skillkit'),
7674
fetch('https://api.github.com/repos/rohitg00/skillkit'),
77-
fetch('https://api.producthunt.com/v2/api/graphql', {
78-
method: 'POST',
79-
headers: { 'Content-Type': 'application/json' },
80-
body: JSON.stringify({ query: '{ post(slug: "skillkit-2") { votesCount } }' }),
81-
}),
8275
]);
8376

8477
let downloads = '2.4k';
8578
let stars = 66;
86-
let phUpvotes = 0;
8779
let version = '1.9.0';
8880

8981
if (npmResponse.status === 'fulfilled' && npmResponse.value.ok) {
@@ -100,18 +92,6 @@ export function useStats(): Stats {
10092
}
10193
}
10294

103-
if (phResponse.status === 'fulfilled' && phResponse.value.ok) {
104-
try {
105-
const phData = await phResponse.value.json();
106-
const votes = phData?.data?.post?.votesCount;
107-
if (typeof votes === 'number' && Number.isFinite(votes)) {
108-
phUpvotes = votes;
109-
}
110-
} catch {
111-
// PH API may require auth, fall back silently
112-
}
113-
}
114-
11595
try {
11696
const registryResponse = await fetch('https://registry.npmjs.org/skillkit/latest');
11797
if (registryResponse.ok) {
@@ -124,7 +104,7 @@ export function useStats(): Stats {
124104
// Use default version
125105
}
126106

127-
const newStats = { version, downloads, stars, phUpvotes };
107+
const newStats = { version, downloads, stars };
128108
setCachedStats(newStats);
129109
setStats({ ...newStats, loading: false });
130110
} catch {

0 commit comments

Comments
 (0)