From 8e4163e3f08e29f38fe87c59d8cfb91e0fa98063 Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 29 Aug 2022 19:01:20 +0300 Subject: everything works --- src/components/Thread.astro | 82 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/components/Thread.astro (limited to 'src/components/Thread.astro') diff --git a/src/components/Thread.astro b/src/components/Thread.astro new file mode 100644 index 0000000..6fae3de --- /dev/null +++ b/src/components/Thread.astro @@ -0,0 +1,82 @@ +--- +import type Thread from '../models/Thread'; +import Post from './Post.astro'; +import Image from './Image.astro'; + +export interface Props { + thread: Thread; + board: string; + comments: boolean; +} + +const { thread, board, comments = false } = Astro.props; + +let replies: string[] = []; +const listReplies = (id: string, getReplies: boolean = false): any => { + if(getReplies) return replies; + + replies = []; + thread.comments.forEach(comment => { + if(comment.commentText.includes(id)) + replies.push(comment.id); + }) + + if(replies.length <= 0) return false; + return true; +} +--- + +{(thread.id != "rules") && ( <> + + + {comments && (listReplies(thread.id) && ( + + {listReplies(thread.id, true).map((id) => ( <> + >>{id} + ))} +
+ ))} + + +

{thread.threadName}

+ +

+ + {comments && ( <> + {thread.comments.map((comment) => ( <> + + + {listReplies(comment.id) && ( + + {listReplies(comment.id, true).map((id) => ( <> + >>{id} + ))} +


+ )} + + +

+ + + ))} + )} + + + )} + +{comments && ( <> + + + + )} -- cgit v1.2.3