@props([
    'item' => null,
    'defaultOrganisation' => '',
    'includeLDJSON' => true,
    'includeFacebook' => true,
    'includeTwitter' => true,
    'imageUrl' => null,
    'seo_name' => null,
    'seo_desc' => null,
    ])
@php
    if($item==null)
        $item=new \App\Models\Page;

    if(empty($imageUrl) && ($includeFacebook || $includeTwitter))
    {   
        $image = Setting::getSettingMedia('seo-media-image',true);
        if(!empty($image))
        {    //$imageUrl = urlencode($image->getUrl());
             $imageUrl = str_replace(' ','%20',$image->getUrl());
        }
    }

    if(empty($seo_name)) {
        $seo_name = @$item->getSEOName();
        $seo_name = str_replace('#039;',';', $seo_name);
        $seo_name = str_replace(';amp;',';', $seo_name);
        $seo_name = str_replace('&amp;amp;','&', $seo_name);
        $seo_name = str_replace('&amp;','&', $seo_name);
    }

    if(empty($seo_desc)) {
        $seo_desc = @$item->getSEODescription();
        $seo_desc = str_replace('#039;',';', $seo_desc);
        $seo_desc = str_replace(';amp;',';', $seo_desc);
        $seo_desc = str_replace('&amp;amp;','&', $seo_desc);
        $seo_desc = str_replace('&amp;','&', $seo_desc);
    }
@endphp
    <title>{{ $seo_name }}</title>
    <meta name="description" content="{{ $seo_desc }}" />
    @if($includeLDJSON)
    <script type="application/ld+json">
    {
        "@context" : "http://schema.org",
        "@type" : "Organization",
        "name" : "{{ Setting::getSetting('seo-organization-name',$defaultOrganisation) }}",
        "url" : "{{ URL::current() }}",
        "description" : "{{ $seo_desc }}",
        "address": [
            {
            "@type": "PostalAddress",
            "addressLocality": "{{ Setting::getSetting('seo-address-locality','UK') }}",
            "addressRegion": "{{ Setting::getSetting('seo-address-region','UK') }}",
            "postalCode": "{{ Setting::getSetting('seo-address-postcode','UK') }}",
            "streetAddress": "{{ Setting::getSetting('seo-address-line','UK') }}"
            }
        ],
        "contactPoint" : [
            { "@type" : "ContactPoint",
            "telephone" : "{{ Setting::getSetting('seo-contact-phone','UK') }}",
            "contactType" : "{{ Setting::getSetting('seo-contact-type','customer service') }}",
            "areaServed" : "{{ Setting::getSetting('seo-contact-area','UK') }}"
            }
        ]
    }
    </script>
    @endif
    @if($includeFacebook)
    <!-- Facebook Meta Tags -->
    <meta property="og:url" content="{{ URL::current() }}">
    <meta property="og:type" content="website">
    <meta property="og:title" content="{!! $seo_name !!}">
    <meta property="og:description" content="{!! $seo_desc !!}">
    <meta property="og:image" content="{!! $imageUrl !!}">
    <meta property="og:image:url" content="{!! $imageUrl !!}">
    @endif
    @if($includeTwitter)
    <!-- Twitter Meta Tags -->
    <meta name="twitter:card" content="summary_large_image">
    <meta property="twitter:domain" content="{{ Request::server('HTTP_HOST') }}">
    <meta property="twitter:url" content="{{ URL::current() }}">
    <meta name="twitter:title" content="{!! $seo_name !!}">
    <meta name="twitter:description" content="{!! $seo_desc !!}">
    <meta name="twitter:image" content="{!! $imageUrl !!}">
    @endif