Add blog extension
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'Published Posts',
|
||||
'category' => 'Blog',
|
||||
'icon' => 'ph ph-article',
|
||||
'cache' => false,
|
||||
];
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
$posts = (new \Plugi\Extensions\Blog\PostsRepository())->getPublishedForListing();
|
||||
?>
|
||||
<section class="space-y-6" aria-label="Blog posts">
|
||||
<?php if (empty($posts)): ?>
|
||||
<div class="alert alert-info" role="status">No published posts yet.</div>
|
||||
<?php else: ?>
|
||||
<div class="grid gap-6 md:grid-cols-2">
|
||||
<?php foreach ($posts as $post): ?>
|
||||
<article class="card h-full border border-base-300 bg-base-100 shadow-sm">
|
||||
<div class="card-body gap-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>
|
||||
<h2 class="card-title text-xl">
|
||||
<a class="link link-hover" href="<?= phpb_e(phpb_full_url('/blog/' . rawurlencode($post['slug']))) ?>"><?= phpb_e($post['title']) ?></a>
|
||||
</h2>
|
||||
<?php if ($post['excerpt'] !== ''): ?>
|
||||
<p class="whitespace-pre-line text-base-content/80"><?= phpb_e($post['excerpt']) ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="card-actions mt-auto justify-end">
|
||||
<a class="btn btn-ghost btn-sm" href="<?= phpb_e(phpb_full_url('/blog/' . rawurlencode($post['slug']))) ?>">
|
||||
Read article<span class="sr-only">: <?= phpb_e($post['title']) ?></span>
|
||||
<i class="ph ph-arrow-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
Reference in New Issue
Block a user