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

$collection = $block->getCollection();
?>

<?php if ($collection->getSize()) : ?>
    <?php foreach ($collection as $category) : ?>
        <?php $activeClass = $category->getIsActive() ? '-active' : ''; ?>
        <li class="amblog-category <?= /* @noEscape */ $activeClass; ?>">
            <a href="<?= $block->escapeUrl($category->getUrl()); ?>"
               title="<?= $block->escapeHtml($category->getName()); ?>">
                <?= $block->escapeHtml($category->getName()); ?>
            </a>
            <?php if ($category->hasActiveChildren()) : ?>
                <ul class="categories item level-<?= $category->getLevel() + 1; ?>">
                    <?= /* @noEscape */ $block->renderChildrenItems($category->getCategoryId()); ?>
                </ul>
            <?php endif; ?>
        </li>
    <?php endforeach; ?>
<?php endif; ?>
