@extends('frontend::layouts.app')
@section('title')
    {{ $data->title }}
@endsection
@section('meta_keywords')
    {{ $data['meta_keywords'] }}
@endsection
@section('meta_description')
    {{ $data['meta_description'] }}
@endsection
@section('content')
    @php
        $blogs = \App\Models\Blog::where('locale', app()->getLocale())
            ->latest()
            ->paginate(8);

        $blog_content = \App\Models\Page::where('code', 'blog')
            ->where('theme', 'default')
            ->where('locale', app()->getLocale())
            ->first();

        $blog_data = json_decode($blog_content->data, true);
    @endphp
    <section class="td-terms-conditions section_space has-sticky">
        <div class="breadcrumb-text">
            <h2>{{ $blog_data['title']  }}</h2>
        </div>
    </section>
    <!-- Blog Section Start -->
    <section class="td-blog td-blog-page">
        <div class="td-blog-wrapper">
            <div class="container">
                <div class="td-blog-cards">
                    <div class="row g-2 td-blog-cards-top">
                        @foreach ($blogs as $index => $blog)
                            @if ($index == 0)
                                <div class="col-sm-6 col-lg-8">
                                    <div class="td-blog-card-main">
                                        <div class="td-blog-card-main-full">
                                            <div class="td-blog-card-main-left">
                                                <img class="img-fluid" src="{{ asset($blog->cover) }}">
                                            </div>
                                            <div class="td-blog-card-main-right">
                                                <small class="d-none d-lg-block">{{ $blog->created_at }}</small>
                                                <a href="{{ route('blog-details', $blog->id) }}">{{ $blog->title }}</a>
                                                <p class="d-none d-lg-block">
                                                    {{ Str::limit(strip_tags($blog->details), 100) }}</p>
                                                <div class="td-blog-card-main-userFull">
                                                    <div class="td-blog-card-main-userCard">
                                                        <img src="{{ asset($blog->author_image) }}" alt="">
                                                        <div class="td-blog-card-main-userCard-designation">
                                                            <span>{{ __('Written by') }}</span>
                                                            <h6>{{ $blog->author_name }}</h6>
                                                        </div>
                                                    </div>
                                                    <div class="td-blog-card-main-readMoreBtn"
                                                        onclick="window.location='{{ route('blog-details', $blog->id) }}'">
                                                        {{ __('Read more') }}
                                                        <img src="{{ asset('frontend/default/img/blog-img/right-arrow.svg') }}"
                                                            alt="">
                                                    </div>
                                                </div>
                                                <div class="d-block d-lg-none td-blog-card-main-userSm">
                                                    <h6>{{ $blog->author_name }}</h6>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            @else
                                <div class="col-sm-6 col-lg-4">
                                    <a href="{{ route('blog-details', $blog->id) }}" class="td-blog-card-normal">
                                        <img src="{{ asset($blog->cover) }}" alt="{{ $blog->title }}">
                                        <div class="td-blog-card-normal-content">
                                            <a href="{{ route('blog-details', $blog->id) }}">{{ $blog->title }}</a>
                                            <h6>{{ $blog->author_name }}</h6>
                                        </div>
                                    </a>
                                </div>
                            @endif
                        @endforeach
                    </div>
                    {{ $blogs->links('frontend::include.__pagination') }}
                </div>
            </div>
        </div>
    </section>
    <!-- blog section end -->
@endsection
