diff --git a/components/landing/navbar.tsx b/components/landing/navbar.tsx index bcdba95..efc0373 100644 --- a/components/landing/navbar.tsx +++ b/components/landing/navbar.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import { usePathname } from "next/navigation"; import { Github, Key, BookOpen, User, Plus } from "lucide-react"; import Link from "next/link"; @@ -10,6 +10,7 @@ import { useApiKey } from "@/hooks/use-api-key"; export function Navbar() { const [showApiModal, setShowApiModal] = useState(false); + const [stars, setStars] = useState("-"); const { isLoaded } = useAuth(); const pathname = usePathname(); @@ -20,6 +21,32 @@ export function Navbar() { setShowApiModal(false); }; + useEffect(() => { + async function fetchStars() { + try { + const res = await fetch( + "https://api.github.com/repos/Nutlope/aicommits", + { + headers: { + Accept: "application/vnd.github+json", + "User-Agent": "make-comics-app", + }, + } + ); + if (!res.ok) return; + const data = await res.json(); + setStars( + typeof data.stargazers_count === "number" + ? data.stargazers_count.toLocaleString() + : "-" + ); + } catch { + setStars("-"); + } + } + fetchStars(); + }, []); + const isOnStoriesPage = pathname === "/stories"; if (!isLoaded) @@ -55,17 +82,17 @@ export function Navbar() { - - - - 0 - - + + + + {stars} + +