1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-19 13:15:31 -04:00

homebrew comments system

This commit is contained in:
2025-05-14 09:47:51 -04:00
parent cce48e558f
commit b196249f25
61 changed files with 3616 additions and 397 deletions
+40
View File
@@ -0,0 +1,40 @@
import Single from "./comment-single";
import { cn } from "@/lib/utils";
import type { CommentWithUser } from "@/lib/server/comments";
const CommentThread = ({
comment,
replies,
allComments,
level = 0,
}: {
comment: CommentWithUser;
replies: CommentWithUser[];
allComments: Record<string, CommentWithUser[]>;
level?: number;
}) => {
// Limit nesting to 3 levels
const maxLevel = 2;
return (
<>
<Single comment={comment} />
{replies.length > 0 && (
<div className={cn("mt-6 space-y-6", level < maxLevel && "ml-6 border-l-2 pl-6")}>
{replies.map((reply) => (
<CommentThread
key={reply.id}
comment={reply}
replies={allComments[reply.id] || []}
allComments={allComments}
level={level + 1}
/>
))}
</div>
)}
</>
);
};
export default CommentThread;