feat: clean URLs pour catégories et pagination
This commit is contained in:
+14
-4
@@ -75,14 +75,24 @@ ob_start();
|
||||
<?php if ($prevCursor !== null || $nextCursor !== null): ?>
|
||||
<nav class="pagination-nav mt-5" aria-label="Navigation">
|
||||
<?php
|
||||
$catParam = $filterCat !== '' ? 'cat=' . rawurlencode($filterCat) . '&' : '';
|
||||
$hasCat = $filterCat !== '';
|
||||
$catBase = $hasCat ? '/categorie/' . rawurlencode($filterCat) : null;
|
||||
?>
|
||||
<?php if ($prevCursor !== null): ?>
|
||||
<?php $prevHref = $prevCursor === '' ? '/?' . rtrim($catParam, '&') : '/?' . $catParam . 'cursor=' . rawurlencode($prevCursor); ?>
|
||||
<?php
|
||||
if ($prevCursor === '') {
|
||||
$prevHref = $hasCat ? $catBase : '/';
|
||||
} elseif ($hasCat) {
|
||||
$prevHref = $catBase . '?cursor=' . rawurlencode($prevCursor);
|
||||
} else {
|
||||
$prevHref = '/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 $nextHref = $hasCat ? $catBase . '?cursor=' . rawurlencode($nextCursor) : '/cursor/' . rawurlencode($nextCursor); ?>
|
||||
<a class="pagination-btn ms-auto" href="<?= htmlspecialchars($nextHref) ?>">Plus anciens →</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
@@ -96,7 +106,7 @@ if (!empty($cursor)) {
|
||||
$metaRobots = 'noindex, follow';
|
||||
$canonical = rtrim(APP_URL, '/') . '/';
|
||||
} elseif ($filterCat !== '') {
|
||||
$canonical = rtrim(APP_URL, '/') . '/?' . http_build_query(['cat' => $filterCat]);
|
||||
$canonical = rtrim(APP_URL, '/') . '/categorie/' . rawurlencode($filterCat);
|
||||
} else {
|
||||
$canonical = rtrim(APP_URL, '/') . '/';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user