<?php

/**
 * @var $data
 * @var \Blog\Models\BlogArticle $article
 * @var \Blog\Models\BlogSection $current_section
 */

$this->layout('system::layout/default');

?>
<div class="p-no-margin">
    <?= $article->text_safe ?>
</div>

<?php if ($article->view_count): ?>
    <div class="d-flex justify-content-end">
        <div class="text-muted forum-view-counter">
            <svg class="icon download-button-icon mt-n1">
                <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>#eye"></use>
            </svg>
            <?= $article->view_count ?>
        </div>
    </div>
<?php endif ?>

<div class="mt-3">
    <a href="<?= $current_section->url ?>">Назад</a>
</div>

<?php $this->push('styles') ?>
<link rel="stylesheet" href="<?= $this->asset('blog/css/blog.css', true) ?>">
<?php $this->stop(); ?>
<?php $this->push('scripts') ?>
<script async charset="utf-8" src="//cdn.embedly.com/widgets/platform.js"></script>
<script>
    document.querySelectorAll('oembed[url]').forEach(element => {
        const anchor = document.createElement('a');
        anchor.setAttribute('href', element.getAttribute('url'));
        anchor.className = 'embedly-card';
        element.appendChild(anchor);
    });
</script>
<?php $this->stop(); ?>
