<h1 class="title"><?= __('Latest posts') ?></h1>

<ul class="posts">
    <?php foreach ($posts as $post): ?>
        <li>
            <?= util('Posts.Posts')->postType($post['type']) ?>
            <a<?= empty($post['link']) ? ' data-ajax' : ' target="_blank"' ?> href="<?= url_to('/post/' . $post['slug']) ?>"><?= $post['title'] ?></a>
            <p class="author-created"><?= __('Posted by') ?> <strong><?= $post['username'] ?></strong> <?= __('in') ?> <strong><?= util('Date')->dateTime($post['create_date']) ?></strong></p>

            <?php if (config('posts.show_preview')): ?>
                <p class="body">
                    <?php if ($post['description']): ?>
                        <?= nl2br($post['description']) ?>
                    <?php else: ?>
                        <?= util('Text')->truncate(strip_tags(nl2br($post['body']), '<br>'), 10) ?>
                    <?php endif ?>
                </p>
            <?php endif ?>
        </li>
    <?php endforeach ?>
</ul>