<?php
/**
 * Blog Article Head
 * Outputs full HTML head + BlogPosting schema for blog articles
 * Requires: $page_title, $page_description, $canonical_url, $article array
 */
$og_image = 'https://ukaiautomation.co.uk/assets/images/ukaiautomation-og.png';
$base_url  = 'https://ukaiautomation.co.uk';
$date_pub  = $article['date'] ?? date('Y-m-d');
$category  = $article['category'] ?? 'AI Automation';

$schema = [
    '@context'        => 'https://schema.org',
    '@type'           => 'BlogPosting',
    '@id'             => $canonical_url . '#blogposting',
    'headline'        => $article['title'] ?? $page_title,
    'description'     => $page_description,
    'url'             => $canonical_url,
    'datePublished'   => $date_pub . 'T09:00:00+00:00',
    'dateModified'    => $date_pub . 'T09:00:00+00:00',
    'author'          => [
        '@type' => 'Organization',
        '@id'   => $base_url . '/#organization',
        'name'  => 'UK AI Automation',
        'url'   => $base_url
    ],
    'publisher'       => [
        '@type' => 'Organization',
        '@id'   => $base_url . '/#organization',
        'name'  => 'UK AI Automation',
        'logo'  => [
            '@type'  => 'ImageObject',
            'url'    => $base_url . '/assets/images/ukaiautomation-logo.svg',
            'width'  => 300,
            'height' => 100
        ]
    ],
    'image'           => [
        '@type'  => 'ImageObject',
        'url'    => $og_image,
        'width'  => 1200,
        'height' => 630
    ],
    'mainEntityOfPage'=> [
        '@type' => 'WebPage',
        '@id'   => $canonical_url
    ],
    'isPartOf'        => [
        '@type' => 'Blog',
        '@id'   => $base_url . '/blog/#blog',
        'name'  => 'UK AI Automation Blog'
    ],
    'articleSection'  => $category,
    'inLanguage'      => 'en-GB'
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($page_title); ?></title>
    <meta name="description" content="<?php echo htmlspecialchars($page_description); ?>">
    <meta name="author" content="UK AI Automation">
    <meta name="robots" content="index, follow">
    <link rel="canonical" href="<?php echo htmlspecialchars($canonical_url); ?>">

    <!-- Open Graph -->
    <meta property="og:type" content="article">
    <meta property="og:url" content="<?php echo htmlspecialchars($canonical_url); ?>">
    <meta property="og:title" content="<?php echo htmlspecialchars($article['title'] ?? $page_title); ?>">
    <meta property="og:description" content="<?php echo htmlspecialchars($page_description); ?>">
    <meta property="og:image" content="<?php echo htmlspecialchars($og_image); ?>">
    <meta property="og:image:width" content="1200">
    <meta property="og:image:height" content="630">
    <meta property="og:site_name" content="UK AI Automation">
    <meta property="og:locale" content="en_GB">
    <meta property="article:published_time" content="<?php echo htmlspecialchars($date_pub); ?>T09:00:00+00:00">
    <meta property="article:section" content="<?php echo htmlspecialchars($category); ?>">

    <!-- Twitter Card -->
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@ukaiautomation">
    <meta name="twitter:title" content="<?php echo htmlspecialchars($article['title'] ?? $page_title); ?>">
    <meta name="twitter:description" content="<?php echo htmlspecialchars($page_description); ?>">
    <meta name="twitter:image" content="<?php echo htmlspecialchars($og_image); ?>">

    <!-- BlogPosting Schema -->
    <script type="application/ld+json">
    <?php echo json_encode($schema, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ?>
    </script>

    <!-- Favicon -->
    <link rel="icon" type="image/svg+xml" href="/assets/images/favicon.svg">

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@300;400;500;600;700&family=Lato:wght@300;400;500;600;700&display=swap" rel="stylesheet">

    <!-- Styles -->
    <link rel="stylesheet" href="/assets/css/main.css?v=20260321">
</head>
<body>
