chore: commit remaining workspace changes
This commit is contained in:
@@ -149,7 +149,7 @@ final class ArtworkPageController extends Controller
|
||||
'md' => $thumbMd,
|
||||
'lg' => $thumbLg,
|
||||
'xl' => $thumbXl,
|
||||
], $canonical)->toArray();
|
||||
], $canonical, $this->artworkBreadcrumbs($artwork, $canonical))->toArray();
|
||||
|
||||
$categoryIds = $artwork->categories->pluck('id')->filter()->values();
|
||||
$tagIds = $artwork->tags->pluck('id')->filter()->values();
|
||||
@@ -364,6 +364,70 @@ final class ArtworkPageController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, url: string}>
|
||||
*/
|
||||
private function artworkBreadcrumbs(Artwork $artwork, string $canonical): array
|
||||
{
|
||||
$primaryCategory = $artwork->categories
|
||||
->sortBy(fn ($category) => [
|
||||
(int) ($category->sort_order ?? 0),
|
||||
(string) ($category->name ?? ''),
|
||||
])
|
||||
->first();
|
||||
|
||||
if ($primaryCategory === null) {
|
||||
return [
|
||||
['name' => 'Explore', 'url' => url('/explore')],
|
||||
['name' => html_entity_decode((string) $artwork->title, ENT_QUOTES | ENT_HTML5, 'UTF-8'), 'url' => $canonical],
|
||||
];
|
||||
}
|
||||
|
||||
$contentType = $primaryCategory->contentType;
|
||||
$chain = collect();
|
||||
$current = $primaryCategory;
|
||||
|
||||
while ($current !== null) {
|
||||
$chain->prepend($current);
|
||||
$current = $current->relationLoaded('parent') ? $current->parent : null;
|
||||
}
|
||||
|
||||
$breadcrumbs = [];
|
||||
$contentTypeSlug = trim((string) ($contentType?->slug ?? ''));
|
||||
$contentTypeName = trim((string) ($contentType?->name ?? ''));
|
||||
|
||||
if ($contentTypeSlug !== '' && $contentTypeName !== '') {
|
||||
$breadcrumbs[] = [
|
||||
'name' => $contentTypeName,
|
||||
'url' => url('/' . $contentTypeSlug),
|
||||
];
|
||||
}
|
||||
|
||||
$pathSegments = [];
|
||||
|
||||
foreach ($chain as $category) {
|
||||
$slug = trim((string) ($category->slug ?? ''));
|
||||
$name = trim((string) ($category->name ?? ''));
|
||||
|
||||
if ($slug === '' || $name === '' || $contentTypeSlug === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pathSegments[] = $slug;
|
||||
$breadcrumbs[] = [
|
||||
'name' => $name,
|
||||
'url' => url('/' . $contentTypeSlug . '/' . implode('/', $pathSegments)),
|
||||
];
|
||||
}
|
||||
|
||||
$breadcrumbs[] = [
|
||||
'name' => html_entity_decode((string) $artwork->title, ENT_QUOTES | ENT_HTML5, 'UTF-8'),
|
||||
'url' => $canonical,
|
||||
];
|
||||
|
||||
return $breadcrumbs;
|
||||
}
|
||||
|
||||
/** Silently catch suggestion query failures so error page never crashes. */
|
||||
private function safeSuggestions(callable $fn): mixed
|
||||
{
|
||||
|
||||
@@ -181,7 +181,7 @@ class BrowseGalleryController extends \App\Http\Controllers\Controller
|
||||
'hero_title' => $contentType->name,
|
||||
'hero_description' => $contentType->description ?? ($contentType->name . ' artworks on Skinbase.'),
|
||||
'breadcrumbs' => collect([
|
||||
(object) ['name' => 'Explore', 'url' => '/browse'],
|
||||
(object) ['name' => 'Explore', 'url' => route('explore.index')],
|
||||
(object) ['name' => $contentType->name, 'url' => '/' . $contentSlug],
|
||||
]),
|
||||
'page_title' => $contentType->name . ' – Skinbase',
|
||||
@@ -237,7 +237,7 @@ class BrowseGalleryController extends \App\Http\Controllers\Controller
|
||||
$breadcrumbs = collect(array_merge([
|
||||
(object) [
|
||||
'name' => 'Explore',
|
||||
'url' => '/browse',
|
||||
'url' => route('explore.index'),
|
||||
],
|
||||
(object) [
|
||||
'name' => $contentType->name,
|
||||
@@ -335,6 +335,8 @@ class BrowseGalleryController extends \App\Http\Controllers\Controller
|
||||
return (object) $this->maturity->decoratePayload([
|
||||
'id' => $artwork->id,
|
||||
'name' => $artwork->title,
|
||||
'slug' => $artwork->slug,
|
||||
'url' => route('art.show', ['id' => $artwork->id, 'slug' => $artwork->slug]),
|
||||
'content_type_name' => $primaryCategory?->contentType?->name ?? '',
|
||||
'content_type_slug' => $primaryCategory?->contentType?->slug ?? '',
|
||||
'category_name' => $primaryCategory->name ?? '',
|
||||
|
||||
@@ -102,7 +102,7 @@ final class SimilarArtworksPageController extends Controller
|
||||
'page_title' => 'Similar to "' . $sourceTitle . '" — Skinbase',
|
||||
'page_meta_description' => 'Discover artworks similar to "' . $sourceTitle . '" on Skinbase.',
|
||||
'page_canonical' => $baseUrl,
|
||||
'page_robots' => 'noindex,follow',
|
||||
'page_robots' => 'index,follow',
|
||||
'breadcrumbs' => collect([
|
||||
(object) ['name' => 'Explore', 'url' => '/explore'],
|
||||
(object) ['name' => $sourceTitle, 'url' => $sourceUrl],
|
||||
|
||||
Reference in New Issue
Block a user