Skip to content

Commit 906375d

Browse files
committed
fix: Download count on homepage
1 parent 2c2c2c1 commit 906375d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/components/DownloadBadge.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
import React, {useEffect, useState} from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import styles from './DownloadBadge.module.css';
33

44
export default function DownloadBadge() {
55
const [downloadsText, setDownloadsText] = useState('Loading...');
66

77
useEffect(() => {
8-
// Fetch from Docker Hub API
9-
fetch('https://hub.docker.com/v2/repositories/sparkison/m3u-editor/')
10-
.then((r) => {
11-
if (!r.ok) throw new Error('Failed to fetch');
12-
return r.json();
8+
// Fetch from shields.io JSON endpoint (no CORS issues)
9+
fetch('https://img.shields.io/docker/pulls/sparkison/m3u-editor.json')
10+
.then((r) => {
11+
if (!r.ok) throw new Error('Failed to fetch');
12+
return r.json();
1313
})
1414
.then((data) => {
15-
if (data && typeof data.pull_count === 'number') {
16-
// Format the number with commas
17-
const formatted = data.pull_count.toLocaleString('en-US');
18-
setDownloadsText(`${formatted}+`);
15+
if (data && data.value) {
16+
// shields.io returns the value already formatted (e.g., "178k")
17+
// If you want to show the exact number with "+", you can parse it
18+
setDownloadsText(`${data.value}+`);
1919
}
2020
})
2121
.catch(() => {
22-
// Fallback to hardcoded value
23-
setDownloadsText('120,000+');
22+
// Fallback to hardcoded value (update periodically)
23+
setDownloadsText('100,000+');
2424
});
2525
}, []);
2626

2727
return (
28-
<a
29-
href="https://hub.docker.com/r/sparkison/m3u-editor"
30-
target="_blank"
28+
<a
29+
href="https://hub.docker.com/r/sparkison/m3u-editor"
30+
target="_blank"
3131
rel="noopener noreferrer"
32-
className={styles.downloadBadge}
33-
role="status"
32+
className={styles.downloadBadge}
33+
role="status"
3434
aria-live="polite"
3535
>
3636
<span className={styles.emoji} aria-hidden="true">🚀</span>

0 commit comments

Comments
 (0)