38751-vm/views/blog/index.php
2026-02-25 20:37:53 +00:00

57 lines
2.7 KiB
PHP

<?php include dirname(__DIR__) . '/header.php'; ?>
<section class="py-5 bg-light">
<div class="container">
<div class="row mb-5">
<div class="col-lg-6 mx-auto text-center">
<h1 class="display-4 fw-bold mb-3">Blog & Articles</h1>
<p class="lead text-muted">Dapatkan informasi terbaru seputar aplikasi, game, dan tips teknologi di sini.</p>
</div>
</div>
<div class="row g-4">
<?php foreach ($posts as $post): ?>
<div class="col-md-6 col-lg-4">
<article class="card h-100 border-0 shadow-sm overflow-hidden hover-lift transition-all">
<?php if ($post['image_path']): ?>
<img src="/<?php echo $post['image_path']; ?>" class="card-img-top" alt="<?php echo htmlspecialchars($post['title']); ?>" style="height: 200px; object-fit: cover;">
<?php else: ?>
<div class="bg-primary bg-opacity-10 d-flex align-items-center justify-content-center" style="height: 200px;">
<i class="fas fa-newspaper fa-3x text-primary opacity-25"></i>
</div>
<?php endif; ?>
<div class="card-body p-4">
<div class="text-muted small mb-2">
<i class="far fa-calendar-alt me-1"></i> <?php echo date('M d, Y', strtotime($post['created_at'])); ?>
</div>
<h2 class="h5 card-title fw-bold mb-3">
<a href="/blog/<?php echo $post['slug']; ?>" class="text-dark text-decoration-none stretched-link">
<?php echo htmlspecialchars($post['title']); ?>
</a>
</h2>
<p class="card-text text-muted mb-0">
<?php
$excerpt = strip_tags($post['content']);
echo mb_strimwidth($excerpt, 0, 120, '...');
?>
</p>
</div>
</article>
</div>
<?php endforeach; ?>
<?php if (empty($posts)): ?>
<div class="col-12 text-center py-5">
<div class="mb-3">
<i class="fas fa-folder-open fa-3x text-muted opacity-25"></i>
</div>
<h3 class="text-muted">Belum ada artikel yang diterbitkan.</h3>
<a href="/" class="btn btn-primary mt-3">Kembali ke Beranda</a>
</div>
<?php endif; ?>
</div>
</div>
</section>
<?php include dirname(__DIR__) . '/footer.php'; ?>