From 150194e11e1f296f5feeb1c2ede26040acb59be5 Mon Sep 17 00:00:00 2001 From: interlope Date: Sun, 12 Jul 2026 15:44:35 +0200 Subject: [PATCH] feat: enhance related posts logic to exclude already shown navigation items --- php/page.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/php/page.php b/php/page.php index a2e8203..6a4330e 100644 --- a/php/page.php +++ b/php/page.php @@ -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);