Updated README.md to document Markdown rendering and image authoring capabilities. Added PostContentRenderer class for safe Markdown parsing with XSS protection. Updated PostsRepository to fetch and resolve featured image data from the uploads table. Added UI controls in EditPost.php for selecting images and inserting inline Markdown. Updated views to display featured images on post cards and detail pages.
42 lines
2.3 KiB
PHP
42 lines
2.3 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>
|
|
<?php if (!empty($post['featured_image_url'])): ?>
|
|
<?php $featuredImageAlt = trim((string) ($post['featured_image_alt_text'] ?? '')) ?: $post['title']; ?>
|
|
<figure class="overflow-hidden rounded-box">
|
|
<img src="<?= phpb_e($post['featured_image_url']) ?>" alt="<?= phpb_e($featuredImageAlt) ?>" class="max-h-[32rem] w-full object-cover">
|
|
</figure>
|
|
<?php endif; ?>
|
|
<div class="space-y-4 text-base leading-7 text-base-content"><?= (new \Plugi\Extensions\Blog\PostContentRenderer())->render($post['body']) ?></div>
|
|
</article>
|
|
<?php endif; ?>
|