pagination curseur, layout 3 colonnes article, sidebar fixe
This commit is contained in:
+26
-11
@@ -2,15 +2,6 @@
|
||||
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();
|
||||
?>
|
||||
|
||||
@@ -19,10 +10,13 @@ ob_start();
|
||||
<?php
|
||||
$html = $Parsedown->text($post['content']);
|
||||
$preview = mb_strimwidth(strip_tags($html), 0, 120, '…');
|
||||
$gradient = $coverGradients[$i % count($coverGradients)];
|
||||
$category = trim((string)($post['category'] ?? ''));
|
||||
$gradient = coverGradient($category !== '' ? $category : $post['uuid'], $allCats ?? []);
|
||||
$postUrl = '/post/' . rawurlencode($post['slug']);
|
||||
$isDraft = !$post['published'];
|
||||
$isAvantPremiere = $post['published'] && strtotime((string)($post['published_at'] ?? '')) > time();
|
||||
$postCat = trim($post['category'] ?? '');
|
||||
$isPrivate = $postCat !== '' && in_array($postCat, $privateCats ?? [], true);
|
||||
$isLocked = $isAvantPremiere;
|
||||
?>
|
||||
<div class="col">
|
||||
@@ -31,6 +25,8 @@ ob_start();
|
||||
<div class="draft-ribbon">Brouillon</div>
|
||||
<?php elseif ($isAvantPremiere): ?>
|
||||
<div class="premiere-ribbon">Avant-première</div>
|
||||
<?php elseif ($isPrivate): ?>
|
||||
<div class="private-ribbon">Privé</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$coverFile = $post['cover'] ?? '';
|
||||
@@ -38,7 +34,11 @@ ob_start();
|
||||
? 'background-image: url(\'/file?uuid=' . rawurlencode($post['uuid']) . '&name=' . rawurlencode($coverFile) . '\')'
|
||||
: 'background: ' . $gradient;
|
||||
?>
|
||||
<div class="card-cover" style="<?= $coverStyle ?>"></div>
|
||||
<div class="card-cover" style="<?= $coverStyle ?>">
|
||||
<?php if ($category !== ''): ?>
|
||||
<span class="cover-category"><?= htmlspecialchars($category) ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h2 class="card-title">
|
||||
<?php if ($isLocked): ?>
|
||||
@@ -72,6 +72,21 @@ ob_start();
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($prevCursor !== null || $nextCursor !== null): ?>
|
||||
<nav class="pagination-nav mt-5" aria-label="Navigation">
|
||||
<?php
|
||||
$catParam = $filterCat !== '' ? 'cat=' . rawurlencode($filterCat) . '&' : '';
|
||||
?>
|
||||
<?php if ($prevCursor !== null): ?>
|
||||
<?php $prevHref = $prevCursor === '' ? '/?' . rtrim($catParam, '&') : '/?' . $catParam . 'cursor=' . rawurlencode($prevCursor); ?>
|
||||
<a class="pagination-btn" href="<?= htmlspecialchars($prevHref) ?>">← Plus récents</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($nextCursor !== null): ?>
|
||||
<a class="pagination-btn ms-auto" href="/?<?= $catParam ?>cursor=<?= rawurlencode($nextCursor) ?>">Plus anciens →</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
$title = 'varlog';
|
||||
|
||||
Reference in New Issue
Block a user