|
| 1 | +import React, { useEffect, useState } from 'react'; |
| 2 | + |
| 3 | +export default function GitHubBadge() { |
| 4 | + const [stats, setStats] = useState(null); |
| 5 | + |
| 6 | + useEffect(() => { |
| 7 | + fetch('https://api.github.com/repos/SPID-Protocol-project/spidprotocol-docs') |
| 8 | + .then((res) => res.json()) |
| 9 | + .then((data) => { |
| 10 | + setStats({ |
| 11 | + stars: data.stargazers_count, |
| 12 | + forks: data.forks_count, |
| 13 | + }); |
| 14 | + }) |
| 15 | + .catch((err) => console.error('GitHub API error:', err)); |
| 16 | + }, []); |
| 17 | + |
| 18 | + return ( |
| 19 | + <div style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}> |
| 20 | + <a |
| 21 | + href="https://github.com/SPID-Protocol-project/spidprotocol-docs" |
| 22 | + target="_blank" |
| 23 | + rel="noopener noreferrer" |
| 24 | + style={{ |
| 25 | + textDecoration: 'none', |
| 26 | + color: 'inherit', |
| 27 | + display: 'flex', |
| 28 | + alignItems: 'center', |
| 29 | + fontSize: '0.9rem', |
| 30 | + }} |
| 31 | + > |
| 32 | + <svg |
| 33 | + height="20" |
| 34 | + viewBox="0 0 16 16" |
| 35 | + version="1.1" |
| 36 | + width="20" |
| 37 | + aria-hidden="true" |
| 38 | + style={{ marginRight: '0.5rem' }} |
| 39 | + > |
| 40 | + <path |
| 41 | + fill="currentColor" |
| 42 | + d="M8 0C3.58 0 0 3.58 0 8a8 8 0 005.47 7.59c.4.07.55-.17.55-.38v-1.33C4.13 |
| 43 | + 14.91 3.63 13.91 3.63 13.91c-.36-.91-.88-1.15-.88-1.15-.72-.5.06-.49.06-.49.79.06 |
| 44 | + 1.2.82 1.2.82.71 1.21 1.87.86 2.33.66.07-.52.28-.86.5-1.06-2.67-.3-5.47-1.34-5.47-5.96 |
| 45 | + 0-1.31.47-2.38 1.24-3.22-.13-.3-.54-1.52.12-3.18 0 0 1.01-.32 |
| 46 | + 3.3 1.23a11.5 11.5 0 016 0c2.29-1.55 |
| 47 | + 3.3-1.23 3.3-1.23.66 1.66.25 2.88.12 |
| 48 | + 3.18.77.84 1.24 1.91 1.24 3.22 |
| 49 | + 0 4.63-2.8 5.66-5.47 5.96.29.25.54.74.54 |
| 50 | + 1.49v2.21c0 .21.15.46.55.38A8.01 |
| 51 | + 8.01 0 0016 8c0-4.42-3.58-8-8-8z" |
| 52 | + ></path> |
| 53 | + </svg> |
| 54 | + <span>SPID Protocol</span> |
| 55 | + </a> |
| 56 | + {stats && ( |
| 57 | + <ul style={{ listStyle: 'none', display: 'flex', gap: '1rem', margin: 0 }}> |
| 58 | + <li>⭐ {stats.stars}</li> |
| 59 | + <li>🍴 {stats.forks}</li> |
| 60 | + </ul> |
| 61 | + )} |
| 62 | + </div> |
| 63 | + ); |
| 64 | +} |
0 commit comments