@extends('front.partials.front')

@section('metatags')
    <meta itemprop="image" content="https://taillislabs.com/logo2.png" />
    <meta property="og:image" itemprop="image/*" content="https://taillislabs.com/logo2.png" />
    <meta property="og:image:width" content="256" />
    <meta property="og:image:height" content="256" />
    <meta property="og:site_name" content="Taillis Labs" />
@endsection
@section('title', 'Découvrez sur nos blogs les actualités les plus récentes')

@section('content')
<div class="pegahealth--breadcrumb--area" style="background-image: linear-gradient(to left,rgba(248, 248, 252, 1), rgba(255, 255, 255, 0.8));">
  <div class="container">
    <div class="col-md-12">
      <div class="second--title p-top-40">
        <img src="assets/images/icon--head.svg" alt="" class="second--title--emoji animate--float--1" />
        <h2 class="second--title--h2">Découvrez sur nos blogs les actualités les plus récentes</h2>
      </div>
    </div>
  </div>
</div>


@if(count($posts) !=0 )
<section class="blog--area section p-top-20 p-bottom-40" >
  <div class="container">

    <div class="row justify-content-center">
      <div class="col-md-6 p-bottom-20">
        <form  method="GET" action="{{ route('search') }}" class="search--area--input">
            <div class="search--area--input--container">
              <input type="text" name="query" id="query" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Type and hit Enter..." />
                <i class="fa fa-search icon"></i>
            
                <button type="submit"><i class="fa fa-search"></i></button>
            </div>
        </form>
      </div>
    </div>
   
    <div class="row">
    @if($category->posts->count() > 0)
    @foreach ($category->posts as $post)
      <div class="col-md-6">
        <div class="blog-item ">
          <div class="blog-item-inner shadow-dark">
           
            <div class="blog-img">
              <a href="{{route('showBlog',[$post->id,$post->slug])}}">
                <img src="{{asset('storage/posts/'.$post->image)}}" alt="Blog">
              </a>
              <div class="blog-date">
                {{ $post->created_at->toFormattedDateString() }}
              </div>
            </div>
            <div class="blog-info">
              <h4 class="blog-title">
                <a href="{{route('showBlog',[$post->id,$post->slug])}}">
                  {{ substr(strip_tags($post->title),0, 100) }}
                </a>
              </h4>
              <!-- <p class="blog-description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore, porro rem quod illo
                quam, eum alias id, repellendus magni, quas.</p> -->
              <p class="blog-tags">Categories : 
                @foreach($post->categories as $category)
                    <a href="{{ url('category',$category->slug) }}">{{ $category->name }}</a>
                @endforeach
             </p>
            </div>
            </a>
          </div>
        </div>
      </div>
      @endforeach
      @endif

    </div>
  </div>
</section>
@else
<section class="blog--area section p-top-20 p-bottom-40" >
  <div class="container">
    <div class="row">
      <p>No Post :(</p>
    </div>
  </div>
</section>
@endif





@endsection

@section('scripts')

@endsection