'use client' import { usePathname } from 'next/navigation' import Link from 'next/link' import { Home, ListMusic, Github, Star } from 'lucide-react' import { useEffect, useState } from 'react' export default function Navbar() { const pathname = usePathname() const [stars, setStars] = useState(null) const isActive = (path: string) => pathname === path useEffect(() => { const fetchStars = () => { fetch('https://api.github.com/repos/bitc0de/bitify') .then(res => res.json()) .then(data => { if (data.stargazers_count !== undefined) { setStars(data.stargazers_count) } }) .catch((err) => { console.error('Error fetching stars:', err) setStars(null) }) } fetchStars() // Refresh when user comes back to the tab const handleVisibilityChange = () => { if (document.visibilityState === 'visible') { fetchStars() } } document.addEventListener('visibilitychange', handleVisibilityChange) return () => { document.removeEventListener('visibilitychange', handleVisibilityChange) } }, []) const formatStars = (count: number) => { if (count >= 1000) { return `${(count / 1000).toFixed(1)}k` } return count.toString() } return ( ) }