36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
require_once 'header.php';
|
|
run_migrations();
|
|
|
|
$stmt = db()->query("SELECT * FROM posts ORDER BY created_at DESC");
|
|
$posts = $stmt->fetchAll();
|
|
?>
|
|
|
|
<div class="row g-5">
|
|
<div class="col-md-8">
|
|
<h3 class="pb-4 mb-4 fst-italic border-bottom">
|
|
From the Firehose
|
|
</h3>
|
|
|
|
<?php foreach ($posts as $post): ?>
|
|
<article class="blog-post mb-5">
|
|
<h2 class="blog-post-title"><?php echo htmlspecialchars($post['title']); ?></h2>
|
|
<p class="blog-post-meta"><?php echo date('F j, Y', strtotime($post['created_at'])); ?> by <a href="#"><?php echo htmlspecialchars($post['author']); ?></a></p>
|
|
<p><?php echo nl2br(htmlspecialchars(substr($post['content'], 0, 200))); ?>...</p>
|
|
<a href="post.php?id=<?php echo $post['id']; ?>" class="btn btn-primary">Read More</a>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
<div class="position-sticky" style="top: 2rem;">
|
|
<div class="p-4 mb-3 bg-light rounded">
|
|
<h4 class="fst-italic">About</h4>
|
|
<p class="mb-0">This is a simple blog created with PHP and Bootstrap. You can find articles about web development, productivity, and more.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'footer.php'; ?>
|