feat: clean URLs pour catégories et pagination
This commit is contained in:
@@ -76,7 +76,7 @@
|
||||
$isPriv = in_array($catName, $_layoutPrivateCats, true); ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link nav-cat <?= $_layoutCurrentCat === $catName ? 'active' : '' ?>"
|
||||
href="/?cat=<?= rawurlencode($catName) ?>">
|
||||
href="/categorie/<?= rawurlencode($catName) ?>">
|
||||
<?= htmlspecialchars($catName) ?>
|
||||
<?php if ($isPriv): ?><span class="ms-1" style="font-size:.65em;opacity:.6">🔒</span><?php endif; ?>
|
||||
</a>
|
||||
|
||||
+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, '/') . '/';
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ $hasLeftSidebar = !empty($categorySidebar ?? []);
|
||||
<aside class="left-sidebar">
|
||||
<?php foreach ($categorySidebar as $catName => $catArticles): ?>
|
||||
<div class="left-sidebar-section">
|
||||
<a href="/?cat=<?= rawurlencode($catName) ?>" class="left-sidebar-cat">
|
||||
<a href="/categorie/<?= rawurlencode($catName) ?>" class="left-sidebar-cat">
|
||||
<?= htmlspecialchars($catName) ?>
|
||||
</a>
|
||||
<ul class="left-sidebar-list">
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<article class="search-result">
|
||||
<div class="search-result-meta">
|
||||
<?php if ($cat !== ''): ?>
|
||||
<a class="search-result-cat" href="/?cat=<?= rawurlencode($cat) ?>"><?= htmlspecialchars($cat) ?></a>
|
||||
<a class="search-result-cat" href="/categorie/<?= rawurlencode($cat) ?>"><?= htmlspecialchars($cat) ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($date !== ''): ?>
|
||||
<time class="search-result-date"><?= $date ?></time>
|
||||
|
||||
Reference in New Issue
Block a user