Files
tehnobox/resources/views/partials/breadcrumbs.blade.php
ssww23 93a655235a
Some checks failed
Deploy / deploy (push) Has been cancelled
Initial commit
2026-03-10 00:55:37 +03:00

51 lines
1.6 KiB
PHP

@if (!empty($items))
@php
$breadcrumbSchemaItems = collect($items)
->values()
->map(function ($item, $index) {
if (!is_array($item)) {
return null;
}
$label = trim((string) ($item['label'] ?? ''));
if ($label === '') {
return null;
}
$url = !empty($item['url']) ? (string) $item['url'] : url()->current();
return [
'@type' => 'ListItem',
'position' => $index + 1,
'name' => $label,
'item' => $url,
];
})
->filter()
->values()
->all();
$breadcrumbSchema = [
'@context' => 'https://schema.org',
'@type' => 'BreadcrumbList',
'itemListElement' => $breadcrumbSchemaItems,
];
@endphp
<nav class="pc-breadcrumbs" aria-label="Хлебные крошки">
@foreach ($items as $item)
@if (!$loop->last && !empty($item['url']))
<a href="{{ $item['url'] }}">{{ $item['label'] }}</a>
<span class="pc-breadcrumbs-sep">/</span>
@else
<span class="pc-breadcrumbs-current">{{ $item['label'] }}</span>
@endif
@endforeach
</nav>
@if (!empty($breadcrumbSchemaItems))
<script type="application/ld+json">
@json($breadcrumbSchema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
</script>
@endif
@endif