import useSWR from "swr"; import { BlogCommentTool } from "./BlogCommentTool"; import { BlogApi } from "@/lib/api"; import { BlogComment } from "@/lib/types/blogComment"; export function BlogComments({ blogId }: { blogId: string }) { const { data, isLoading, error, mutate } = useSWR( `/api/blog/${blogId}/comments`, () => BlogApi.getComments(blogId), ) const insertComment = async (newOne: BlogComment) => { await mutate( (comments) => { if (!comments) return [newOne]; return [newOne, ...comments] }, { revalidate: false } ) } return ( data &&
{new Date(d.createdAt).toLocaleString()}
未知
回复
{new Date().toLocaleString()}
未知