@php
    $locale = app()->getLocale();
    $reglage = \App\Models\Reglage::singleton();
    $seo = ['title' => $reglage->seoTitle(), 'description' => $reglage->seoDescription()];
    $org = \App\Support\SeoContent::organization();
    $biz = \App\Support\SeoContent::localBusiness();
    $founder = \App\Support\SeoContent::founder();

    $currentUrl = url()->current();
    $urlFr = $urlFr ?? route('home', ['locale' => 'fr']);
    $urlEn = $urlEn ?? route('home', ['locale' => 'en']);
    $ogImage = $ogImage ?? asset('assets/hero-ocean.jpg');
    $ogType = $ogType ?? 'website';
    $socialUrls = \App\Models\ReseauSocial::orderBy('soc_ordre')->pluck('soc_url')->all();
@endphp

<title>{{ $title ?? $seo['title'] }}</title>
<meta name="description" content="{{ $description ?? $seo['description'] }}" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="{{ $currentUrl }}" />

{{-- hreflang : versions FR/EN de la page --}}
<link rel="alternate" hreflang="fr" href="{{ $urlFr }}" />
<link rel="alternate" hreflang="en" href="{{ $urlEn }}" />
<link rel="alternate" hreflang="x-default" href="{{ $urlFr }}" />

{{-- Open Graph --}}
<meta property="og:type" content="{{ $ogType }}" />
<meta property="og:site_name" content="Obvious Way" />
<meta property="og:locale" content="{{ $locale === 'en' ? 'en_US' : 'fr_FR' }}" />
<meta property="og:title" content="{{ $title ?? $seo['title'] }}" />
<meta property="og:description" content="{{ $description ?? $seo['description'] }}" />
<meta property="og:url" content="{{ $currentUrl }}" />
<meta property="og:image" content="{{ $ogImage }}" />

{{-- Twitter Card --}}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{{ $title ?? $seo['title'] }}" />
<meta name="twitter:description" content="{{ $description ?? $seo['description'] }}" />
<meta name="twitter:image" content="{{ $ogImage }}" />

{{-- JSON-LD : Organization + LocalBusiness + Person (fondatrice) --}}
<script type="application/ld+json">
{!! json_encode([
    '@context' => 'https://schema.org',
    '@graph' => [
        [
            '@type' => 'Organization',
            '@id' => $org['url'].'#organization',
            'name' => $org['name'],
            'legalName' => $org['legalName'],
            'url' => $org['url'],
            'logo' => $org['logo'],
            'email' => $org['email'],
            'telephone' => $org['telephone'],
            'sameAs' => $socialUrls,
            'founder' => ['@type' => 'Person', 'name' => $founder['name']],
        ],
        [
            '@type' => 'LocalBusiness',
            '@id' => $org['url'].'#localbusiness',
            'name' => $org['name'],
            'image' => $ogImage,
            'email' => $org['email'],
            'telephone' => $org['telephone'],
            'address' => [
                '@type' => 'PostalAddress',
                'streetAddress' => $biz['streetAddress'],
                'addressLocality' => $biz['addressLocality'],
                'addressCountry' => $biz['addressCountry'],
            ],
            'parentOrganization' => ['@id' => $org['url'].'#organization'],
        ],
        [
            '@type' => 'Person',
            '@id' => $org['url'].'#founder',
            'name' => $founder['name'],
            'jobTitle' => $founder['jobTitle'],
            'sameAs' => $founder['sameAs'],
            'worksFor' => ['@id' => $org['url'].'#organization'],
        ],
    ],
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) !!}
</script>

@isset($articleSchema)
<script type="application/ld+json">
{!! json_encode($articleSchema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) !!}
</script>
@endisset
