Skip to content

Commit

Permalink
Fix regression with breadcrumbs title (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni authored Jun 3, 2022
1 parent b2f2b62 commit 8dc363b
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/View/Cascade.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,11 @@ protected function breadcrumbs(): ?string
return null;
}

$listItems = $this->breadcrumbsListItems()->map(function ($crumb, $key) {
$listItems = $this->breadcrumbsListItems()->map(function ($crumb) {
return Schema::listItem()
->position($key + 1)
->name($crumb->title())
->item($crumb->absoluteUrl());
->position($crumb['position'])
->name($crumb['title'])
->item($crumb['url']);
})->all();

return Schema::breadcrumbList()->itemListElement($listItems);
Expand All @@ -571,13 +571,19 @@ protected function breadcrumbsListItems(): Collection
$uri = URL::tidy(implode('/', $segments));
array_pop($segments);

return $uri;
})->mapWithKeys(function ($uri) {
$uri = Str::ensureLeft($uri, '/');

return [$uri => Data::findByUri($uri, Site::current()->handle())];
})->filter();

return $crumbs->reverse()->values();
return Data::findByUri(Str::ensureLeft($uri, '/'), Site::current()->handle());
})
->filter()
->reverse()
->values()
->map(function ($item, $key) {
return [
'position' => $key + 1,
'title' => method_exists($item, 'title') ? $item->title() : $item->value('title'),
'url' => $item->absoluteUrl(),
];
});

return $crumbs;
}
}

0 comments on commit 8dc363b

Please sign in to comment.