Files
laralog/resources/views/partials/post-card.blade.php
T
gouki 6adfacc4e5
Build and Deploy / verify (push) Failing after 39m48s
Build and Deploy / deploy (push) Skipped
feat(frontend): enable Livewire SPA navigation (wire:navigate)
2026-10-12 12:30:58 +00:00

42 lines
1.9 KiB
PHP

@php
$viewMode = $homeViewMode ?? \App\Blog\Support\HomeViewMode::LIST;
$showFull = $viewMode === \App\Blog\Support\HomeViewMode::FULL
&& blank($post->read_password)
&& empty(($post->meta ?? [])['members_only']);
@endphp
<article class="post-card {{ $post->isPinned() ? 'sticky' : '' }} post-card-{{ $viewMode }}">
@if($url = $post->coverImageUrl())
<a wire:navigate href="{{ route('posts.show', $post->id) }}" class="post-cover">
<img src="{{ $url }}" alt="{{ $post->title }}" loading="lazy">
</a>
@endif
<h2 class="post-title">
@if($label = $post->stickyLabel())<span class="badge">{{ $label }}</span>@endif
<a wire:navigate href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a>
</h2>
<div class="post-meta">
<time datetime="{{ $post->published_at->toIso8601String() }}">{{ $post->published_at->format(blog_setting('normaltime', 'Y-m-d H:i')) }}</time>
@if($post->category)
<span>·</span>
<a wire:navigate href="{{ route('category.show', $post->category->id) }}">{{ $post->category->name }}</a>
@endif
<span>· 阅读 {{ $post->views }}</span>
<span>· 评论 {{ $post->comment_count }}</span>
</div>
@if($showFull)
<div class="post-content">
{!! app(\App\Blog\Services\PostContentRenderer::class)->render($post) !!}
</div>
@else
<div class="post-excerpt">
{{ \Illuminate\Support\Str::limit($post->excerpt_or_fallback, 200) }}
</div>
@endif
<div class="post-footer">
<a wire:navigate href="{{ route('posts.show', $post->id) }}" class="read-more">阅读全文 &raquo;</a>
@foreach($post->tags as $tag)
<a wire:navigate href="{{ route('tags.show', $tag->name) }}" class="tag-link">#{{ $tag->name }}</a>
@endforeach
</div>
</article>