style: restaure les couvertures (dégradés + vraie image si dispo)

This commit is contained in:
Cedric Abonnel
2026-05-09 13:25:09 +02:00
parent ddb753fff8
commit 1950d7968a
+18 -5
View File
@@ -2,14 +2,24 @@
require_once BASE_PATH . '/src/Parsedown.php';
$Parsedown = new Parsedown();
$coverGradients = [
'linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%)',
'linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%)',
'linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%)',
'linear-gradient(135deg, #fef3c7 0%, #fde68a 100%)',
'linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%)',
'linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%)',
];
ob_start();
?>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
<?php foreach ($posts as $post): ?>
<?php foreach ($posts as $i => $post): ?>
<?php
$html = $Parsedown->text($post['content']);
$preview = mb_strimwidth(strip_tags($html), 0, 120, '…');
$gradient = $coverGradients[$i % count($coverGradients)];
$postUrl = '/post/' . rawurlencode($post['slug']);
$isDraft = !$post['published'];
$isAvantPremiere = $post['published'] && strtotime((string)($post['published_at'] ?? '')) > time();
@@ -22,10 +32,13 @@ ob_start();
<?php elseif ($isAvantPremiere): ?>
<div class="premiere-ribbon">Avant-première</div>
<?php endif; ?>
<?php $coverFile = $post['cover'] ?? ''; ?>
<?php if ($coverFile !== ''): ?>
<div class="card-cover" style="background-image: url('/file?uuid=<?= rawurlencode($post['uuid']) ?>&name=<?= rawurlencode($coverFile) ?>')"></div>
<?php endif; ?>
<?php
$coverFile = $post['cover'] ?? '';
$coverStyle = $coverFile !== ''
? 'background-image: url(\'/file?uuid=' . rawurlencode($post['uuid']) . '&name=' . rawurlencode($coverFile) . '\')'
: 'background: ' . $gradient;
?>
<div class="card-cover" style="<?= $coverStyle ?>"></div>
<div class="card-body d-flex flex-column">
<h2 class="card-title">
<?php if ($isLocked): ?>