<?php ob_start(); ?>

<article class="blog-article">
    <div class="container container-narrow">
        <?php if (!empty($post['featured_image'])): ?>
        <?= picture_tag($post['featured_image'], $post['title'], 'article-image', false) ?>
        <?php endif; ?>

        <h1 class="article-title"><?= e($post['title']) ?></h1>

        <div class="article-meta">
            <?php if (!empty($post['category_name'])): ?>
            <a href="/blog/category/<?= e($post['category_slug']) ?>" class="article-category"><?= e($post['category_name']) ?></a>
            <?php endif; ?>
            <span><?= e($post['author_name'] ?? '') ?></span>
            <span><?= format_date($post['published_at'] ?? $post['created_at']) ?></span>
        </div>

        <div class="article-content">
            <?= $post['content'] ?? '' ?>
        </div>

        <div class="article-footer">
            <a href="/blog" class="btn btn-secondary">&larr; Back to Blog</a>
        </div>
    </div>
</article>

<?php $content = ob_get_clean(); include __DIR__ . '/layout.php'; ?>
