﻿@using Sitecore.Feature.News
@using Sitecore.Foundation.Alerts
@using Sitecore.Foundation.Alerts.Extensions
@using Sitecore.Foundation.Dictionary.Extensions
@using Sitecore.Foundation.SitecoreExtensions.Extensions
@using Sitecore.Foundation.SitecoreExtensions.Repositories
@using Sitecore.Foundation.Theming.Extensions
@model Sitecore.Mvc.Presentation.RenderingModel
@if (!Model?.Item?.IsDerived(Templates.NewsArticle.ID) ?? true)
{
  @Html.PageEditorError(AlertTexts.InvalidDataSourceTemplate(Templates.NewsArticle.ID), AlertTexts.InvalidDataSourceTemplateFriendlyMessage, Model.Item?.ID, Model.Rendering.Item?.ID)
  return;
}

<div class="thumbnail @Model.Rendering.GetBackgroundClass() m-b-1">
  <header class="thumbnail-header">
    <span class="label">
      @Html.Sitecore().Field(Templates.NewsArticle.Fields.Date.ToString(), new
                                                                           {
                                                                             format = "MMMM dd, yyyy"
                                                                           })
    </span>
    <h3>
      @Html.Sitecore().Field(Templates.NewsArticle.Fields.Title, Model.Item)
    </h3>
  </header>
  <div>
    <a href="@Model.Item.Url()">
      @Html.Sitecore().ImageField(Templates.NewsArticle.Fields.Image, Model.Item, mw: 750, cssClass: "img-responsive")
    </a>
  </div>
  <div class="caption">
    <p>
      @Html.Sitecore().Field(Templates.NewsArticle.Fields.Summary, Model.Item)
    </p>
    <a href="@Html.Sitecore().CurrentRendering.Item.Url()" class="btn btn-default">
      @Html.Sitecore().Dictionary("/news/news teaser/read more", "Read more")
    </a>
  </div>
</div>