import { basePath } from "@/config/siteConfig"; import { cn } from "@/lib/utils"; import Link from "next/link"; import { useEffect, useState } from "react"; import { FaGithub, FaStar } from "react-icons/fa"; import { buttonVariants } from "./button"; import NumberTicker from "./number-ticker"; export default function StarOnGithubButton() { const [stars, setStars] = useState(0); useEffect(() => { const fetchStars = async () => { try { const res = await fetch( `https://api.github.com/repos/community-scripts/${basePath}`, { next: { revalidate: 60 * 60 * 24 }, }, ); if (res.ok) { const data = await res.json(); setStars(data.stargazers_count || stars); } } catch (error) { console.error("Error fetching stars:", error); } }; fetchStars(); }, [stars]); return (
Star on GitHub{" "}
); }