import { ComponentChildren } from "preact";
import { render_and_copy } from "./common.tsx";
import { Top, Bottom, Hrish } from "./this-post-is-two-posts.tsx";

// this would be a funny time to do multiple posts

export const Post = ({
    children,
    headline,
    n_comments,
    display_name,
    username,
    posted,
    link,
    id,
    alt_text = true,
}: {
    children?: ComponentChildren;

    headline?: string;

    n_comments: number;

    display_name?: string;
    username: string;
    posted: string;
    link?: string;
    id?: string;
    alt_text?: boolean;
}) => (
    <div class="post">
        <Top
            display_name={display_name}
            username={username}
            posted={posted}
            link={link}
            id={id}
            alt_text={alt_text}
        />
        <Hrish />
        <div class="post-inner">
            {headline && (
                <div class="headline">
                    <a href={link}>
                        <h1>{headline}</h1>
                    </a>
                </div>
            )}
            <div style="display: flex;">
                <div class="post-content">{children}</div>
            </div>
        </div>
        <Hrish />
        <Bottom n_comments={n_comments} alt_text={alt_text} />
    </div>
);

render_and_copy(
    <div class="posts">
        <Post
            headline="can i have more than one post please"
            username="mehbark"
            posted="6 hr. ago"
            n_comments={2}
            alt_text={false}
        >
            one post isn't really enough for me
        </Post>
    </div>
);