"use client"; import NumberFlow from "@number-flow/react"; import { useEffect, useState } from "react"; import { getCommentCount } from "@/lib/server/comments"; const CommentCount = ({ slug }: { slug: string }) => { const [count, setCount] = useState(null); const [error, setError] = useState(false); useEffect(() => { getCommentCount(slug) .then((result: number) => { setCount(result); }) .catch((err: unknown) => { console.error("[comment-count] error:", err); setError(true); }); }, [slug]); if (error) { return ?; } if (count === null) { return 0; } return ( ); }; export { CommentCount };