feat: enhance related posts logic to exclude already shown navigation items

This commit is contained in:
interlope committed 2026-07-12 15:44:35 +02:00
1 parent bacda9011c
commit 150194e11e
1 file changed
+5 -1
+5 -1
View File
@@ -204,8 +204,12 @@
$bdCur = $page->key();
$bdCat = $page->categoryKey();
$bdTags = array_keys($page->tags(true));
// Skip the posts already shown in the older/newer nav just above.
$bdNavShown = array();
if (!empty($bdOlder)) { $bdNavShown[] = $bdOlder->key(); }
if (!empty($bdNewer)) { $bdNavShown[] = $bdNewer->key(); }
foreach ($bdKeys as $bdK) {
if ($bdK === $bdCur) { continue; }
if ($bdK === $bdCur || in_array($bdK, $bdNavShown, true)) { continue; }
if (count($bdRelated) >= 3) { break; }
$bdCand = new Page($bdK);
$bdMatch = ($bdCat && $bdCand->categoryKey() === $bdCat);