Don't sort pages when a unknown sort method is specified
Specifying a custom sort method usually means that all pages are sort by a plugin, so Pico's default alphabetical order is overwritten anyway. Letting Pico sort the pages first and discarding the result is burned CPU time...
This commit is contained in:
parent
b493ebdb84
commit
82c6dd9795
1 changed files with 7 additions and 1 deletions
|
@ -1279,6 +1279,12 @@ class Pico
|
|||
{
|
||||
// sort pages
|
||||
$order = $this->getConfig('pages_order');
|
||||
$orderBy = $this->getConfig('pages_order_by');
|
||||
|
||||
if (($orderBy !== 'date') && ($orderBy !== 'alpha')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alphaSortClosure = function ($a, $b) use ($order) {
|
||||
$aSortKey = (basename($a['id']) === 'index') ? dirname($a['id']) : $a['id'];
|
||||
$bSortKey = (basename($b['id']) === 'index') ? dirname($b['id']) : $b['id'];
|
||||
|
@ -1287,7 +1293,7 @@ class Pico
|
|||
return $cmp * (($order === 'desc') ? -1 : 1);
|
||||
};
|
||||
|
||||
if ($this->getConfig('pages_order_by') === 'date') {
|
||||
if ($orderBy === 'date') {
|
||||
// sort by date
|
||||
uasort($this->pages, function ($a, $b) use ($alphaSortClosure, $order) {
|
||||
if (empty($a['time']) || empty($b['time'])) {
|
||||
|
|
Loading…
Add table
Reference in a new issue