@extends('front.layout.pages-layout')
@section('pageTitle', isset($pageTitle) ? $pageTitle : 'Document Title')
@section('meta_tags')
    {!! SEO::generate() !!}}
@endsection
@section('content')

    <div class="row">
        <div class="col-lg-8  mb-5 mb-lg-0">

            <article class="row mb-5">
                @if (!empty(get_slides()))
                    <div class="col-12">
                        <div class="post-slider">
                            @foreach (get_slides() as $slide)
                                <div class="slider-item">
                                    <img fetchpriority="high" decoding="async" src="/images/slides/{{ $slide->image }}"
                                        class="img-fluid" alt="post-thumb">
                                    <div class="slider-content">
                                        @if ($slide->link)
                                            <a href="{{ $slide->link }}">
                                                <h2 class="animate__animated">{{ $slide->heading }}</h2>
                                            </a>
                                        @else
                                            <h2 class="animate__animated">{{ $slide->heading }}</h2>
                                        @endif
                                    </div>
                                </div>
                            @endforeach
                        </div>
                    </div>
                @endif
                @if (!empty(latest_posts(0, 1)))
                    @foreach (latest_posts(0, 1) as $post)
                        <div class="col-12 mx-auto">
                            <h3>
                                <a class="post-title" href="{{ route('read_post', $post->slug) }}">
                                    {{ $post->title }}
                                </a>
                            </h3>
                            <ul class="list-inline post-meta mb-4">
                                <li class="list-inline-item"><i class="ti-user mr-1"></i>
                                    <a
                                        href="{{ route('author_posts', $post->author->username) }}">{{ $post->author->name }}</a>
                                </li>
                                <li class="list-inline-item"><i
                                        class="ti-calendar mr-1"></i>{{ date_formatter($post->created_at) }}</li>
                                <li class="list-inline-item">Category : <a
                                        href="{{ route('category_posts', $post->post_category->slug) }}" class="ml-1">Web
                                        {{ $post->post_category->name }}
                                    </a>
                                </li>
                                <li class="list-inline-item"><i class="ti-timer mr-1"></i>
                                    {{ readDuration($post->title, $post->content) }} @choice('min|mins', readDuration($post->title, $post->content))
                                </li>
                            </ul>
                            <p>
                                {!! Str::ucfirst(words($post->content, 45)) !!}
                            </p>
                            <a href="{{ route('read_post', $post->slug) }}" class="btn btn-outline-primary">Mehr
                                lesen...</a>
                        </div>
                    @endforeach
                @endif
            </article>

            <section id="home__latest-posts">
                @if (!empty(latest_posts(1, 3)))
                    @foreach (latest_posts(1, 3) as $post)
                        <article class="row mb-5">
                            <div class="col-md-4 mb-4 mb-md-0">
                                <div class="post-img-box">
                                    <img src="/images/posts/resized/resized_{{ $post->featured_image }}"
                                        class="img-fluid rounded-lg" alt="post-thumb">
                                </div>
                            </div>
                            <div class="col-md-8">
                                <h4>
                                    <a class="post-title" href="{{ route('read_post', $post->slug) }}">
                                        {{ $post->title }}
                                    </a>
                                </h4>
                                <ul class="list-inline post-meta mb-2">
                                    <li class="list-inline-item"><i class="ti-user mr-2"></i><a
                                            href="{{ route('author_posts', $post->author->username) }}">{{ $post->author->name }}</a>
                                    </li>
                                    <li class="list-inline-item">{{ date_formatter($post->created_at) }}</li>
                                    <li class="list-inline-item">Kategorie : <a
                                            href="{{ route('category_posts', $post->post_category->slug) }}"
                                            class="ml-1">{{ $post->post_category->name }} </a>
                                    </li>
                                    <li class="list-inline-item"><i class="ti-timer mr-1"></i>
                                        {{ readDuration($post->title, $post->content) }} @choice('min|mins', readDuration($post->title, $post->content))
                                    </li>
                                </ul>
                                <p>
                                    {!! Str::ucfirst(words($post->content, 30)) !!}
                                </p>
                                <a href="{{ route('read_post', $post->slug) }}" class="btn btn-outline-primary">Mehr
                                    lesen...</a>
                            </div>
                        </article>
                    @endforeach
                @endif
            </section>


        </div>
        <aside class="col-lg-4">
            <!-- Search -->
            <x-sidebar-search></x-sidebar-search>
            <!-- categories -->
            <x-sidebar-categories></x-sidebar-categories>
            <!-- tags -->
            <x-sidebar-tags></x-sidebar-tags>
            <!-- latest post -->
            <div class="widget">
                <h5 class="widget-title"><span>Letzte Post</span></h5>
                <!-- post-item -->
                @foreach (sidebar_latest_posts(4) as $item)
                    <ul class="list-unstyled widget-list">
                        <li class="media widget-post align-items-center">
                            <a href="{{ route('read_post', $item->slug) }}">
                                <img loading="lazy" class="mr-3" alt="post-thumb"
                                    src="/images/posts/resized/thumb_{{ $item->featured_image }}">
                            </a>
                            <div class="media-body">
                                <h6 class="mb-0">
                                    <a href="{{ route('read_post', $item->slug) }}">{{ $item->title }}</a>
                                </h6>
                                <small>{{ date_formatter($item->created_at) }}</small>
                            </div>
                        </li>
                    </ul>
                @endforeach

            </div>
            <a href="https://www.checkout-ds24.com/product/614053?aff=MagicPotter"
                class="ad-banner d-flex align-items-center justify-content-center">
                <span class="ad-text">Jetzt klicken</span>
            </a>
        </aside>
    </div>
@endsection
