<?php
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes 2020-present. All rights reserved.
 * This product is licensed per Magento install
 * See https://hyva.io/license
 */

declare(strict_types=1);

use Hyva\Theme\Model\ViewModelRegistry;
use Hyva\Theme\ViewModel\ProductPage;
use Magento\Catalog\Model\Product;
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\Template;

/** @var Template $block */
/** @var Escaper $escaper */
/** @var ViewModelRegistry $viewModels */

/** @var ProductPage $productViewModel */
$productViewModel = $viewModels->require(ProductPage::class);

/** @var Product $product */
$product = $productViewModel->getProduct();

// Create WebPage schema data array with speakable content
$webPageSchemaData = [
    "@context" => "http://schema.org/",
    "@type" => "WebPage",
    "speakable" => [
        "@type" => "SpeakableSpecification",
        "cssSelector" => [
            ".left-product-title", // CSS selector for product title (h1)
            "#description .max-w-none" // CSS selector for product description
        ]
    ]
];
?>
<script type="application/ld+json">
<?= json_encode($webPageSchemaData) ?>
</script>
