feat: enhance sorting of related posts by date and title for better organization

This commit is contained in:
interlope committed 2026-06-09 18:34:18 +02:00
1 parent 7906c15fa7
commit 6c90149f0c
1 file changed
+6 -1
+6 -1
View File
@@ -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(); }
}