@extends('theme::layout')

@section('content')
    <div class="post-list">
        @forelse($articles as $article)
            <article class="post-item">
                @if($article->hasCover() && ($coverUrl = $article->coverUrl()))
                    <a class="post-item__cover" href="{{ url('/show-'.$article->id.'.shtml') }}">
                        <img src="{{ $coverUrl }}" alt="{{ $article->title }}" loading="lazy">
                    </a>
                @endif
                <h2><a href="{{ url('/show-'.$article->id.'.shtml') }}">{{ $article->title }}</a></h2>
                <p class="meta">
                    {{ optional($article->published_at)->format('Y-m-d') }}
                    @if($article->category) · {{ $article->category->name }} @endif
                    · {{ strtoupper($article->content_format) }}
                    @if($article->stick) · 置顶 @endif
                </p>
                <p class="excerpt">{{ app(\App\Domain\Blog\ArticleExcerpt::class)->forList($article) }}</p>
            </article>
        @empty
            <div class="panel">
                <h1 class="page-title">还没有文章</h1>
                <p class="meta">去后台发布第一篇，或运行 <code>php artisan db:seed</code> 载入演示内容。</p>
            </div>
        @endforelse
    </div>
    <div class="pagination">{{ $articles->links() }}</div>
@endsection
