feat: section articles proches dans la vue article

This commit is contained in:
Cedric Abonnel
2026-05-12 22:41:48 +02:00
parent b81750616f
commit f273c3fa6a
2 changed files with 66 additions and 0 deletions
+21
View File
@@ -258,6 +258,27 @@ $hasSources = (!empty($externalLinks) || !empty($files))
<p class="text-muted small">Aucun autre article dans cette catégorie.</p>
<?php endif; ?>
<?php if (!empty($similarArticles ?? [])): ?>
<h6 class="related-sidebar-title mt-4">Articles proches</h6>
<?php foreach ($similarArticles as $sim):
$simCover = $sim['cover'] ?? '';
$simCat = trim($sim['category'] ?? '');
$simGradient = coverGradient($simCat !== '' ? $simCat : $sim['uuid'], $allCats ?? []);
$simDate = date('d/m/Y', strtotime((string)($sim['published_at'] ?? $sim['created_at'] ?? '')));
?>
<a href="/post/<?= rawurlencode($sim['slug'] ?? '') ?>" class="related-card">
<div class="related-card-thumb" style="<?= $simCover !== ''
? 'background-image:url(/file?uuid=' . rawurlencode($sim['uuid']) . '&name=' . rawurlencode($simCover) . ');background-size:cover;background-position:center'
: 'background:' . htmlspecialchars($simGradient) ?>">
</div>
<div class="related-card-body">
<div class="related-card-title"><?= htmlspecialchars($sim['title']) ?></div>
<div class="related-card-date"><?= $simDate ?></div>
</div>
</a>
<?php endforeach; ?>
<?php endif; ?>
</aside>
</div>