@props(['product']) @php $siteName = \App\Models\Setting::where('key', 'store_name')->value('value') ?? config('app.name', 'DigiShop'); $appUrl = url('/'); $imageUrl = $product->thumbnail ? url(Storage::url($product->thumbnail)) : asset('favicon.ico'); // Sanitize description $plainDescription = strip_tags($product->description ?: $product->content); $plainDescription = str_replace(["\r", "\n"], ' ', $plainDescription); $shortDescription = \Illuminate\Support\Str::limit($plainDescription, 160); $schemaJson = json_encode([ '@context' => 'https://schema.org/', '@type' => 'Product', 'name' => $product->name, 'image' => $imageUrl, 'description' => $shortDescription, 'sku' => 'PROD-' . $product->id, 'brand' => [ '@type' => 'Brand', 'name' => $siteName, ], 'offers' => [ '@type' => 'Offer', 'url' => route('product.show', $product->slug), 'priceCurrency' => 'IDR', 'price' => (int) $product->price, 'availability' => $product->is_active ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock', ] ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); @endphp