From 6c90149f0cd7dc47690a67fa01fc95c36c4d801c Mon Sep 17 00:00:00 2001 From: interlope Date: Tue, 9 Jun 2026 18:34:18 +0200 Subject: [PATCH] feat: enhance sorting of related posts by date and title for better organization --- php/page.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/php/page.php b/php/page.php index 84ec759..de1244b 100644 --- a/php/page.php +++ b/php/page.php @@ -70,7 +70,12 @@ $bdSp = new Page($bdSk); if (in_array($bdSeriesTag, array_keys($bdSp->tags(true)), true)) { $bdSeriesPosts[] = $bdSp; } } - usort($bdSeriesPosts, function ($a, $b) { return strcmp($a->getValue('date'), $b->getValue('date')); }); + // Oldest first (Part 1 → N); when posts share a date, fall back to + // natural title order so "WIMH #1" precedes "WIMH #2". + usort($bdSeriesPosts, function ($a, $b) { + $d = strcmp((string) $a->getValue('date'), (string) $b->getValue('date')); + return $d !== 0 ? $d : strnatcasecmp($a->title(), $b->title()); + }); } } catch (\Throwable $e) { $bdSeriesPosts = array(); } }