import { Link } from '@inertiajs/react';
import Shell from '../layouts/Shell';
import { displayDate, type PostSummary } from '../types/journal';

export default function Article({ post, body }: { post: PostSummary; body: string }) {
    return (
        <Shell active="journal">
            <article className="wrap reading-page">
                <div className="reading-width">
                    <Link className="back-link" href="/">
                        <span className="arrow arrow-left" aria-hidden="true" /> Back to journal
                    </Link>
                    <p className="kicker">{post.category}</p>
                    <h1>{post.title}</h1>
                    <p className="article-excerpt">{post.excerpt}</p>
                    <div className="byline">
                        <span>{post.author}</span>
                        <time dateTime={post.published_at}>{displayDate(post.published_at)}</time>
                        <span>{post.minutes} min read</span>
                    </div>
                </div>
                {post.cover && <img className="article-cover" src={post.cover} alt="" />}
                <div className="reading-width article-body">{body}</div>
            </article>
        </Shell>
    );
}
