// components/comments.tsx import { cosmic } from "@/cosmic/client" import { UserRound } from "lucide-react" import { CommentForm } from "./CommentForm" type Comment = { title: string slug: string metadata: { comment: string } created_at: string } function Comment({ comment, className, }: { comment: Comment className?: string }) { const date = new Date(comment.created_at).toLocaleDateString("en-us", { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", }) return (
{comment.title}
{date}
{comment.metadata.comment}
) } export async function Comments({ query, sort, limit, skip, className, status, }: { query: any sort?: string limit?: number skip?: number className?: string status?: "draft" | "published" | "any" }) { let comments = [] const resourceId = query["metadata.resource"] try { // Get the id const { objects } = await cosmic.objects .find(query) .props("title,slug,metadata,created_at") .depth(1) .sort(sort ? sort : "created_at") .limit(limit ? limit : 100) .skip(skip ? skip : 0) .status(status ? status : "published") comments = objects } catch (err) {} return (

Comments

{comments.map((comment: Comment) => { return })}
) }