Skip to content

Commit

Permalink
Breadcrumb rich snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
royduin committed Nov 10, 2021
1 parent 16cc5ee commit 9f7ca61
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
6 changes: 5 additions & 1 deletion resources/views/category/partials/breadcrumbs.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<x-rapidez::breadcrumbs>
@foreach($category->subcategories as $subcategory)
<x-rapidez::breadcrumb :url="$subcategory->url" :active="$subcategory->entity_id == $category->entity_id">
<x-rapidez::breadcrumb
:url="$subcategory->url"
:active="$subcategory->entity_id == $category->entity_id"
:position="$loop->iteration + 1"
>
{{ $subcategory->name }}
</x-rapidez::breadcrumb>
@endforeach
Expand Down
22 changes: 13 additions & 9 deletions resources/views/components/breadcrumb.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
@props(['url', 'active' => false])
@props(['url', 'position', 'active' => false])

@if(!$active)
<a {{ $attributes->merge(['class' => 'text-sm text-primary hover:underline', 'href' => $url]) }}>
{{ $slot }}
</a>
<x-heroicon-s-chevron-right class="h-4 w-4 text-gray-400"/>
@else
<span class="text-sm">{{ $slot }}</span>
@endif
<li class="flex items-center" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
@if(!$active)
<a {{ $attributes->merge(['class' => 'text-sm text-primary hover:underline', 'href' => $url, 'itemprop' => 'item']) }}>
<span itemprop="name">{{ $slot }}</span>
<meta itemprop="position" content="{{ $position }}" />
</a>
<x-heroicon-s-chevron-right class="h-4 w-4 text-gray-400"/>
@else
<span class="text-sm" itemprop="name">{{ $slot }}</span>
<meta itemprop="position" content="{{ $position }}" />
@endif
</li>
6 changes: 3 additions & 3 deletions resources/views/components/breadcrumbs.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="flex items-center mb-3">
<x-rapidez::breadcrumb url="/">@lang('Home')</x-rapidez::breadcrumb>
<ol class="flex mb-3" itemscope itemtype="https://schema.org/BreadcrumbList">
<x-rapidez::breadcrumb url="/" position="1">@lang('Home')</x-rapidez::breadcrumb>
{{ $slot }}
</div>
</ol>
4 changes: 2 additions & 2 deletions resources/views/product/partials/breadcrumbs.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<x-rapidez::breadcrumbs>
@foreach($product->breadcrumb_categories as $category)
<x-rapidez::breadcrumb :url="$category->url">
<x-rapidez::breadcrumb :url="$category->url" :position="$loop->iteration + 1">
{{ $category->name }}
</x-rapidez::breadcrumb>
@endforeach
<x-rapidez::breadcrumb :active="true">{{ $product->name }}</x-rapidez::breadcrumb>
<x-rapidez::breadcrumb :active="true" :position="count($product->breadcrumb_categories) + 2">{{ $product->name }}</x-rapidez::breadcrumb>
</x-rapidez::breadcrumbs>

0 comments on commit 9f7ca61

Please sign in to comment.