@extends('layouts.web')

@section('page-title', $category->category)

@section('content')

<section class="page-header">
  <div class="page-header__bg" style="background-image: url({{asset('assets/images/header.jpg')}});"></div>
  <div class="container">
    <h2>{{$category->category}} </h2>
    <ul class="thm-breadcrumb list-unstyled">
        <li class="text-white"><a href="{{url('/')}}">Inicio</a></li>
    </ul>
  </div>
</section>

@if (Auth::user())
  <div class="row">
    <div class="container py-2">
      <div class="col text-right">
        <a href="{{url('create')}}" class="thm-btn">
          <i class="fas fa-plus"></i>  
          Crear nuevo
        </a>
      </div>
    </div>
  </div>
@endif


<div class="blog-page">
  <div class="container">
    <div class="row">

    @if (count($contents))
    @foreach ($contents as $content)

    <div class="col-sm-12 col-md-6 col-lg-4">
      <div class="blog-card">
        <div class="blog-card__image">
          <div class="blog-card__date">{{ date('d M', strtotime($content->publish_up)) }}</div><!-- /.blog-card__date -->
          <img src="{{asset('assets/img/optimized/image-'.$content->images)}}" alt="{{$content->title}}">
          <a href="{{url($content->category.'/blog/'.$content->slug)}}"></a>
        </div>
        <div class="blog-card__content">
          <div class="blog-card__meta">
            <a href="#"><i class="far fa-user-circle"></i>
              @if ($content->created_by_alias) {{$content->created_by_alias}} @else {{$content->author}} @endif  
            </a>
          </div>
          <h3>
            <a href="{{url($category->slug.'/blog/'.$content->slug)}}">
              <!-- {{$content->title}} -->
              {{ str_limit($content->title, $limit = 50, $end = '...') }}
            </a>
          </h3>
        </div>
      </div>
    </div>

    @endforeach
    @else
      @include('partials.noData')
    @endif


    </div>
  </div>
</div>

@php $paginates=$contents; @endphp

  <div class="container list-unstyled d-flex justify-content-center py-4">
    {{ $paginates->links() }}
  </div>
@stop
