Files
varlog/templates/post_list.php
T

37 lines
1.2 KiB
PHP

<?php
require_once BASE_PATH . '/src/Parsedown.php';
$Parsedown = new Parsedown();
ob_start();
?>
<div class="posts-list">
<?php foreach ($posts as $post): ?>
<?php
$html = $Parsedown->text($post['content']);
$preview = mb_strimwidth(strip_tags($html), 0, 240, '…');
?>
<article class="post-entry">
<h2 class="post-entry-title">
<a href="route.php?action=view&id=<?= $post['id'] ?>">
<?= htmlspecialchars($post['title']) ?>
</a>
<?php if (!$post['is_published']): ?>
<span class="badge bg-warning ms-2">Brouillon</span>
<?php endif; ?>
</h2>
<p class="post-entry-excerpt"><?= htmlspecialchars($preview) ?></p>
<div class="post-entry-meta">
<span><?= date('d/m/Y', strtotime($post['created_at'])) ?></span>
<a href="route.php?action=edit&id=<?= $post['id'] ?>" class="post-entry-edit">modifier</a>
<a href="route.php?action=view&id=<?= $post['id'] ?>" class="post-entry-read">→ lire</a>
</div>
</article>
<?php endforeach; ?>
</div>
<?php
$content = ob_get_clean();
$title = 'varlog';
include __DIR__ . '/layout.php';