<?php
/**
 * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved.
 * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
 *
 * Glory to Ukraine! Glory to the heroes!
 */
?>
<?php
/**
 * Blog sidebar recent posts template
 *
 * @var $block \Magefan\Blog\Block\Sidebar\Recent
 */
?>

<?php
	$_postCollection = $block->getPostCollection();
?>
<?php if ($_postCollection->count()) { ?>
<div class="widget block block-recent-posts" data-bind="scope: 'recemt-posts'">
    <div class="block-title">
        <strong><?php echo __('Recent Posts') ?></strong>
    </div>
    <div class="block-content">
        <ul>
    	<?php foreach ($_postCollection as $_post) { ?>
            <li class="clearfix">
                <?php if($post_image = $_post->getFeaturedImage()): ?>
                <div class="post-image">
                    <img src="<?php echo $post_image; ?>" alt=""/>
                </div>
                <?php endif; ?>
                <a class="post-item-link"
                   href="<?php echo $_post->getPostUrl() ?>">
                    <?php echo $block->escapeHtml($_post->getTitle()) ?>
                </a>
                <div class="post-time"><?php echo date("F j, Y", strtotime($_post->getData("publish_time"))); ?></div>
            </li>

        <?php } ?>
        </ul>
    </div>
</div>
<?php } ?>