Update comments component
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m14s

This commit is contained in:
Ryan Freeman 2025-04-05 19:10:21 +01:00
parent 327b0e67cd
commit e2387beaa3

View File

@ -52,13 +52,10 @@ Comments.ReplyButton = function ReplyButton({comment}: ReplyButton) {
) )
} }
Comments.Comment = function Comment({comment, children, isReply = false}: { Comments.Comment = function Comment({comment, isReply = false}: {
comment: Comment, comment: Comment,
children?: ReactNode,
isReply?: boolean isReply?: boolean
}) { }) {
const {data: session} = useSession()
return ( return (
<> <>
<article <article
@ -78,7 +75,6 @@ Comments.Comment = function Comment({comment, children, isReply = false}: {
<Comments.ReplyButton comment={comment}/> <Comments.ReplyButton comment={comment}/>
</div> </div>
</article> </article>
{children}
</> </>
) )
} }
@ -96,11 +92,14 @@ Comments.List = function List({comments}: CommentsListProps) {
Comments Comments
</h3> </h3>
{comments.map((comment) => ( {comments.map((comment) => (
<Comments.Comment key={comment.id} comment={comment}> <React.Fragment key={comment.id}>
{comment.replies && comment.replies.map(reply => ( <Comments.Comment comment={comment}/>
{(typeof comment.replies !== 'undefined' && comment.replies.length > 0) ?
comment.replies.map(reply => (
<Comments.Comment key={reply.id} comment={reply} isReply={true}/> <Comments.Comment key={reply.id} comment={reply} isReply={true}/>
))} )) : null
</Comments.Comment> }
</React.Fragment>
))} ))}
</section> </section>
} }