<?php
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_Blog
 * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */

use Mageplaza\Blog\Helper\Data;

/** @var Data $helper */
$helper = $this->helper(Data::class);
$posts = $helper->getPostList();
$categories = $helper->getObjectList(Data::TYPE_CATEGORY);
$tags = $helper->getObjectList(Data::TYPE_TAG);
$topics = $helper->getObjectList(Data::TYPE_TOPIC);
?>

<?php if ($size = $posts->getSize()) : ?>
    <h2><?= ($size == 1) ? __('Post') : __('Posts') ?></h2>
    <ul>
        <?php foreach ($posts as $post) : ?>
            <li><a href="<?= $post->getUrl() ?>"><?= $post->getName(); ?></a></li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

<?php if ($size = $categories->getSize()) : ?>
    <h2><?= ($size == 1) ? __('Category') : __('Categories') ?></h2>
    <ul>
        <?php foreach ($categories as $category) : ?>
            <li>
                <a href="<?= $helper->getBlogUrl($category, Data::TYPE_CATEGORY) ?>"><?= $category->getName(); ?></a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

<?php if ($size = $tags->getSize()) : ?>
    <h2><?= ($size == 1) ? __('Tag') : __('Tags') ?></h2>
    <ul>
        <?php foreach ($tags as $tag) : ?>
            <li><a href="<?= $helper->getBlogUrl($tag, Data::TYPE_TAG) ?>"><?= $tag->getName(); ?></a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

<?php if ($size = $topics->getSize()) : ?>
    <h2><?= ($size == 1) ? __('Topic') : __('Topics') ?></h2>
    <ul>
        <?php foreach ($topics as $topic) : ?>
            <li>
                <a href="<?= $helper->getBlogUrl($topic, Data::TYPE_TOPIC) ?>"><?= $topic->getName(); ?></a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>
