feat : page /books et section livres accueil (v1.6.26)
- #99 : page publique /books — catalogue des books avec ≥1 article publié - #100 : section « Livres » sur la homepage (max 6, après redécouvertes) - CSS : .book-grid, .book-home-card*, .home-section-more - .htaccess : règle RewriteRule ^books/?$ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
<div class="container py-4">
|
||||
|
||||
<div class="d-flex align-items-baseline justify-content-between mb-4">
|
||||
<h1 class="h3 mb-0">Livres</h1>
|
||||
<span class="text-muted small"><?= count($booksData) ?> livre<?= count($booksData) > 1 ? 's' : '' ?></span>
|
||||
</div>
|
||||
|
||||
<?php if (empty($booksData)): ?>
|
||||
<p class="text-muted">Aucun livre disponible pour l'instant.</p>
|
||||
<?php else: ?>
|
||||
|
||||
<div class="book-grid">
|
||||
<?php foreach ($booksData as $_bd):
|
||||
$_book = $_bd['book'];
|
||||
$_first = $_bd['first'];
|
||||
$_count = $_bd['count'];
|
||||
$_cover = $_first['cover'] ?? '';
|
||||
$_cat = trim($_first['category'] ?? '');
|
||||
$_coverStyle = $_cover !== ''
|
||||
? "background-image:url('/file?uuid=" . rawurlencode($_first['uuid']) . "&name=" . rawurlencode($_cover) . "')"
|
||||
: 'background:' . coverGradient($_cat !== '' ? $_cat : $_first['uuid'], $allCats ?? []);
|
||||
?>
|
||||
<a href="/book/<?= rawurlencode($_book['slug']) ?>" class="book-home-card">
|
||||
<div class="book-home-card-cover" style="<?= $_coverStyle ?>"></div>
|
||||
<div class="book-home-card-body">
|
||||
<div class="book-home-card-title"><?= htmlspecialchars($_book['title']) ?></div>
|
||||
<?php if (!empty($_book['description'])): ?>
|
||||
<div class="book-home-card-desc"><?= htmlspecialchars(mb_strimwidth($_book['description'], 0, 100, '…')) ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="book-home-card-meta"><?= $_count ?> page<?= $_count > 1 ? 's' : '' ?></div>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
$title = 'Livres — ' . siteTitle();
|
||||
$metaRobots = 'index, follow';
|
||||
$canonical = rtrim((string)($_ENV['APP_URL'] ?? getenv('APP_URL') ?: ''), '/') . '/books';
|
||||
include BASE_PATH . '/templates/layout.php';
|
||||
@@ -214,6 +214,38 @@ function _renderCard(array $post, array $privateCats, array $allCats, \Parsedown
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($homeBooks ?? [])): ?>
|
||||
<section class="home-section">
|
||||
<h2 class="home-section-title">
|
||||
Livres
|
||||
<a href="/books" class="home-section-more">Voir tous →</a>
|
||||
</h2>
|
||||
<div class="book-grid">
|
||||
<?php foreach ($homeBooks as $_hb):
|
||||
$_book = $_hb['book'];
|
||||
$_first = $_hb['first'];
|
||||
$_count = $_hb['count'];
|
||||
$_cover = $_first['cover'] ?? '';
|
||||
$_cat = trim($_first['category'] ?? '');
|
||||
$_coverStyle = $_cover !== ''
|
||||
? "background-image:url('/file?uuid=" . rawurlencode($_first['uuid']) . "&name=" . rawurlencode($_cover) . "')"
|
||||
: 'background:' . coverGradient($_cat !== '' ? $_cat : $_first['uuid'], $allCats ?? []);
|
||||
?>
|
||||
<a href="/book/<?= rawurlencode($_book['slug']) ?>" class="book-home-card">
|
||||
<div class="book-home-card-cover" style="<?= $_coverStyle ?>"></div>
|
||||
<div class="book-home-card-body">
|
||||
<div class="book-home-card-title"><?= htmlspecialchars($_book['title']) ?></div>
|
||||
<?php if (!empty($_book['description'])): ?>
|
||||
<div class="book-home-card-desc"><?= htmlspecialchars(mb_strimwidth($_book['description'], 0, 80, '…')) ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="book-home-card-meta"><?= $_count ?> page<?= $_count > 1 ? 's' : '' ?></div>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else: /* ─── VUE PAGINÉE / FILTRÉE ─────────────────────────────── */ ?>
|
||||
|
||||
<?php if ($cursor === '' && $filterCat === ''): ?>
|
||||
|
||||
Reference in New Issue
Block a user