| 11 | |
| 12 | useEffect(() => { |
| 13 | const fetchStars = async () => { |
| 14 | if (stars > 100) return |
| 15 | try { |
| 16 | const response = await fetch( |
| 17 | 'https://api.github.com/repos/syntaxui/syntaxui', |
| 18 | { |
| 19 | headers: process.env.NEXT_PUBLIC_GITHUB_OAUTH_TOKEN |
| 20 | ? { |
| 21 | Authorization: `Bearer ${process.env.NEXT_PUBLIC_GITHUB_OAUTH_TOKEN}`, |
| 22 | 'Content-Type': 'application/json', |
| 23 | } |
| 24 | : {}, |
| 25 | }, |
| 26 | ) |
| 27 | |
| 28 | if (response.ok) { |
| 29 | const data = await response.json() |
| 30 | setStars(data.stargazers_count || 100) |
| 31 | } |
| 32 | } catch (error) { |
| 33 | console.error('Error fetching GitHub stars:', error) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | fetchStars() |
| 38 | }, [stars, setStars]) |