<?php
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Blog Pro for Magento 2
 */
/** @var \Amasty\Blog\Block\Layout\AuthorInfo $block */
/** @var \Magento\Framework\Escaper $escaper */

$author = $block->getAuthorData();
?>

<?php if ($author): ?>
    <div id="amblog_sidebar_author" class="amblog-author-info" data-amblog-js="accordion">
        <div class="amblog-sidebar-heading-container">
            <h3 class="amblog-title mobile" id="amblog-sidebar-author-info-title" data-amblog-js="heading">
                <?= $escaper->escapeHtml(__('About author')); ?>
            </h3>
        </div>
        <div class="amblog-content" data-amblog-js="content">
            <div class="amblog-image-wrapper <?= $author->getImage() ? '' : '-placeholder' ?>">
                <?php if ($author->getImage()): ?>
                    <figure class="amblog-image"
                          style="background-image: url(<?= $escaper->escapeUrl($author->getImage()); ?>)"></figure>
                <?php endif; ?>
            </div>
            <div class="amblog-title -author"><?= $escaper->escapeHtml($author->getName()); ?></div>

            <?php if ($author->getJobTitle()): ?>
                <h4 class="amblog-job"><?= $escaper->escapeHtml($author->getJobTitle()); ?></h4>
            <?php endif; ?>

            <?php if ($author->getShortDescription()): ?>
                <p class="amblog-description"><?= $escaper->escapeHtml($author->getShortDescription(), ['a']); ?></p>
            <?php endif; ?>

            <?php if ($block->isAnySocial()): ?>
                <ul class="amblog-social-container">
                    <?php if ($author->getTwitterProfile()): ?>
                        <li class="amblog-icon -twitter">
                            <a class="amblog-social"
                               target="_blank"
                               href="<?= $escaper->escapeUrl($author->getTwitterProfile()); ?>"
                               title="<?= $escaper->escapeHtmlAttr(__('Twitter')); ?>"
                               aria-label="<?= $escaper->escapeHtmlAttr(__('Twitter')); ?>">
                            </a>
                        </li>
                    <?php endif; ?>
                    <?php if ($author->getFacebookProfile()): ?>
                        <li class="amblog-icon -facebook">
                            <a class="amblog-social"
                               target="_blank"
                               href="<?= $escaper->escapeUrl($author->getFacebookProfile()); ?>"
                               title="<?= $escaper->escapeHtmlAttr(__('Facebook')); ?>"
                               aria-label="<?= $escaper->escapeHtmlAttr(__('Facebook')); ?>">
                            </a>
                        </li>
                    <?php endif; ?>
                    <?php if ($author->getLinkedinProfile()): ?>
                        <li class="amblog-icon -linkedin">
                            <a class="amblog-social"
                               target="_blank"
                               href="<?= $escaper->escapeUrl($author->getLinkedinProfile()); ?>"
                               title="<?= $escaper->escapeHtmlAttr(__('LinkedIn')); ?>"
                               aria-label="<?= $escaper->escapeHtmlAttr(__('LinkedIn')); ?>">
                            </a>
                        </li>
                    <?php endif; ?>
                    <?php if ($author->getYoutubeProfile()): ?>
                        <li class="amblog-icon -youtube">
                            <a class="amblog-social"
                               target="_blank"
                               href="<?= $escaper->escapeUrl($author->getYoutubeProfile()); ?>"
                               title="<?= $escaper->escapeHtmlAttr(__('Youtube')); ?>"
                               aria-label="<?= $escaper->escapeHtmlAttr(__('Youtube')); ?>">
                            </a>
                        </li>
                    <?php endif; ?>
                    <?php if ($author->getInstagramProfile()): ?>
                        <li class="amblog-icon -instagram">
                            <a class="amblog-social"
                               target="_blank"
                               href="<?= $escaper->escapeUrl($author->getInstagramProfile()); ?>"
                               title="<?= $escaper->escapeHtmlAttr(__('Instagram')); ?>"
                               aria-label="<?= $escaper->escapeHtmlAttr(__('Instagram')); ?>">
                            </a>
                        </li>
                    <?php endif; ?>
                    <?php if ($author->getTiktokProfile()): ?>
                        <li class="amblog-icon -tiktok">
                            <a class="amblog-social"
                               target="_blank"
                               href="<?= $escaper->escapeUrl($author->getTiktokProfile()); ?>"
                               title="<?= $escaper->escapeHtmlAttr(__('TikTok')); ?>"
                               aria-label="<?= $escaper->escapeHtmlAttr(__('TikTok')); ?>">
                            </a>
                        </li>
                    <?php endif; ?>
                </ul>
            <?php endif; ?>
        </div>
    </div>

    <script type="application/ld+json">
        {
            "@context": "https://schema.org/",
            "@type": "Person",
            "name": "<?= $escaper->escapeHtml($author->getName()); ?>",
            "description": "<?= $escaper->escapeHtml($author->getShortDescription()); ?>",
            "image": "<?= $escaper->escapeUrl($author->getImage()); ?>"
        }
    </script>
<?php endif; ?>
