Fix an edge case in sorting

This commit is contained in:
Stéphane Goetz 2020-01-08 08:43:02 +01:00 committed by GitHub
parent 437a52e90e
commit 3276d4b611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -26,14 +26,24 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
];
foreach ($this->children as $key => $entry) {
// In case of generated pages, the name might be empty.
// Thus we are falling back to other solutions, otherwise the page would disappear from the tree.
$name = $entry->getName();
if ($name == 'index' || $name == '_index') {
$buckets['index'][$key] = $entry;
continue;
if (!$name) {
$name = $entry->getTitle();
}
if (!$name) {
$name = $key;
}
if (!$name) {
continue;
}
if ($name == 'index' || $name == '_index') {
$buckets['index'][$key] = $entry;
continue;
}