@props(['items']) @php $itemListElement = []; foreach($items as $index => $item) { $listItem = [ '@type' => 'ListItem', 'position' => $index + 1, 'name' => $item['name'] ]; if (isset($item['url'])) { $listItem['item'] = $item['url']; } $itemListElement[] = $listItem; } $schemaJson = json_encode([ '@context' => 'https://schema.org', '@type' => 'BreadcrumbList', 'itemListElement' => $itemListElement, ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); @endphp