<?php
/**
 * @var News $post
 * @var \yii\web\View $this
 */

use app\models\base\Image;
use app\models\News;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;

$preview = $post->preview;
?>
<div class="inject" id="<?=$post->uid?>">
    <div class="illustration">
        <?php if($preview instanceof \app\models\base\Image):?>
            <div class="picture-cont-16x9">
                <a href="<?=$post->url?>">
                    <picture class="w-100">
                        <source srcset="<?=$preview->getUrl(Image::SIZE_680x383,"jpg")?>" media="(min-width: 600px)">
                        <source srcset="<?=$preview->getUrl(Image::SIZE_680x383,"webp")?>" media="(min-width: 600px)">
                        <img src="<?=$preview->getUrl(Image::SIZE_680x383)?>" alt="<?=$post->photo_title?>" class="w-100" loading="lazy">
                    </picture>
                </a>
            </div>
        <?php else:?>
            <div class="picture-cont-16x9">
                <a href="<?=$post->url?>">

                </a>
            </div>
        <?php endif;?>

    </div>

    <div class="meta">
        <div class="breadcrumbs">
            <?php
            echo Html::a("НОВОСТИ", ["/news"], ['class' => "breadcrumb"]);
            $topic = ArrayHelper::getValue($post->topics,0);
            if($topic instanceof \app\models\base\NewsTopic) {
                echo Html::a($topic->title, ["news/{$topic->url}"], ['class' => "breadcrumb"]);
            }
            ?>
        </div>
        <h2 class="title"><a href="<?=$post->url?>"><?=$post->title?></a></h2>
    </div>
</div>
