<?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
 */

use Magefan\Blog\Block\Post\Info;
use Magento\Framework\Escaper;

/** @var Info $block */
/** @var Escaper $escaper */

$_post = $block->getPost();
?>

<div class="post-info">
    <?php if ($_post->isPublishDateEnabled()): ?>
        <div class="item post-posed-date">
            <span class="label font-bold">
                <?= $escaper->escapeHtml(__('Posted:')) ?>
            </span>
            <span class="value">
                <?= $escaper->escapeHtml($_post->getPublishDate()) ?>
            </span>
        </div>
    <?php endif; ?>

    <?php if ($_categoriesCount = $_post->getCategoriesCount()): ?>
        <div class="item post-categories">
            <span class="label font-bold">
                <?= $escaper->escapeHtml(__('Categories:')) ?>
            </span>
            <?php $n = 0; ?>
            <?php foreach ($_post->getParentCategories() as $ct): ?>
                <?php $n++; ?>
                <a title="<?= $escaper->escapeHtmlAttr($ct->getTitle()) ?>"
                   href="<?= $escaper->escapeUrl($ct->getCategoryUrl()) ?>"
                   class="value">
                   <?= $escaper->escapeHtml($ct->getTitle()) ?>
                </a>
                <?= /*@noEscape*/ ($n != $_categoriesCount) ? ',' : '' ?>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>

    <?php if ($block->magefanCommentsEnabled() && $_post->getCommentsCount()): ?>
        <div class="item post-comments">
            <span class="label font-bold">
                <?= $escaper->escapeHtml(__('Comments:')) ?>
            </span>
            <a title="<?= $escaper->escapeHtmlAttr($_post->getTitle()) ?>"
               href="<?= $escaper->escapeUrl($_post->getPostUrl()) ?>#post-comments">
               <?= $escaper->escapeHtml($_post->getCommentsCount()) ?>
            </a>
        </div>
    <?php endif; ?>

    <?php if ($block->authorEnabled()): ?>
        <?php if ($_author = $_post->getAuthor()): ?>
            <div class="item post-author">
                <span class="label font-bold">
                    <?= $escaper->escapeHtml(__('Author:')) ?>
                </span>
                <span class="value">
                    <?php if ($authorPageEnabled = $block->authorPageEnabled()): ?>
                        <a title="<?= $escaper->escapeHtmlAttr($_author->getTitle()) ?>"
                           href="<?= $escaper->escapeUrl($_author->getAuthorUrl()) ?>">
                    <?php endif; ?>

                    <?= $escaper->escapeHtml($_author->getTitle()) ?>

                    <?php if ($authorPageEnabled): ?>
                        </a>
                    <?php endif; ?>
                </span>
            </div>
        <?php endif; ?>
    <?php endif; ?>

    <?php if ($block->viewsCountEnabled()): ?>
        <?php if ($viewsCount = $_post->getViewsCount()): ?>
            <div class="item post-views">
                <span class="label font-bold">
                    <?= $escaper->escapeHtml(__('Views:')) ?>
                </span>
                <span class="value">
                    <?= $escaper->escapeHtml($viewsCount)?>
                </span>
            </div>
        <?php endif; ?>
    <?php endif; ?>
</div>
