Files
plugi/extensions/plugi-ext-blog/blocks/post-detail/view.php
T
2026-12-02 10:20:36 +00:00

36 lines
1.8 KiB
PHP

<?php
$slug = phpb_route_parameter('slug');
$post = is_string($slug) && $slug !== ''
? (new \Plugi\Extensions\Blog\PostsRepository())->findPublishedBySlug($slug)
: null;
?>
<?php if ($post === null): ?>
<section class="card border border-base-300 bg-base-100 shadow-sm" aria-labelledby="blog-post-not-found">
<div class="card-body">
<h1 id="blog-post-not-found" class="card-title">Article not found</h1>
<p class="text-base-content/70">This article is unavailable or may no longer be published.</p>
</div>
</section>
<?php else: ?>
<article class="mx-auto w-full max-w-3xl space-y-8">
<header class="space-y-4">
<div class="flex flex-wrap items-center gap-3 text-sm text-base-content/60">
<?php if (!empty($post['category_name'])): ?>
<span class="badge badge-outline"><?= phpb_e($post['category_name']) ?></span>
<?php endif; ?>
<?php if (!empty($post['published_at'])): ?>
<?php $publishedTimestamp = strtotime($post['published_at']); ?>
<?php if ($publishedTimestamp !== false): ?>
<time datetime="<?= phpb_e(date('c', $publishedTimestamp)) ?>"><?= phpb_e(date('F j, Y', $publishedTimestamp)) ?></time>
<?php endif; ?>
<?php endif; ?>
</div>
<h1 class="text-3xl font-bold tracking-tight text-base-content sm:text-4xl"><?= phpb_e($post['title']) ?></h1>
<?php if ($post['excerpt'] !== ''): ?>
<p class="text-lg leading-relaxed text-base-content/70"><?= phpb_e($post['excerpt']) ?></p>
<?php endif; ?>
</header>
<div class="whitespace-pre-line text-base leading-7 text-base-content"><?= nl2br(phpb_e($post['body'])) ?></div>
</article>
<?php endif; ?>