{{--
Storefront SEO head (meta description, robots, canonical, OG/Twitter, JSON-LD).
Controllers may pass an optional $seo array:
title — page title for OG/Twitter (defaults to the store name)
description — page-specific meta description
canonical — absolute canonical URL (only emitted on indexable routes)
image — absolute social-share image URL
type — og:type, 'website' (default) or 'product'
jsonLd — Seo::jsonLdEncode() output, rendered raw inside a script tag
Pages without $seo (cart, checkout, auth, account) fall back to store-level
defaults from $settings (injected by the view composer on all storefront views).
Only the catalogue routes are indexable; every other route is always
noindexed. Add future content routes (e.g. category pages) to the allowlist.
--}}
@php
$seo = $seo ?? [];
$seoIndexable = request()->routeIs('storefront.index', 'storefront.product');
$seoNoindex = ! $seoIndexable || ($settings->seo_noindex ?? false);
$seoTitle = $seo['title'] ?? ($settings->company_name ?? 'Shop');
$seoDesc = $seo['description'] ?? $settings->effectiveMetaDescription();
// No canonical alongside noindex — the two are contradictory signals.
$seoCanonical = $seoNoindex ? null : ($seo['canonical'] ?? null);
$seoImagePath = \App\Support\Seo::ogImagePath(null, $settings);
$seoImage = $seo['image'] ?? ($seoImagePath ? url('/storage/'.$seoImagePath) : null);
$seoType = $seo['type'] ?? 'website';
@endphp
@if($seoNoindex)
@endif
@if($seoDesc)
@endif
@if($seoCanonical)
@endif
@if($seoDesc)
@endif
@if($seoCanonical)
@endif
@if($seoImage)
@endif
@if($seoDesc)
@endif
@isset($seo['jsonLd'])
{{-- Safe raw output: Seo::jsonLdEncode() hex-escapes < > ' & (no {!! $seo['jsonLd'] !!}
@endisset