libra/resources/views/livewire/pages/posts/show.blade.php

40 lines
1.1 KiB
PHP

<?php
use App\Enums\PostStatus;
use App\Models\Post;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;
new #[Layout('components.layouts.public')] class extends Component
{
public Post $post;
public function mount(Post $post): void
{
// Only show published posts
abort_unless($post->status === PostStatus::Published, 404);
$this->post = $post;
}
}; ?>
<article class="max-w-3xl mx-auto">
<header class="mb-8">
<flux:heading size="xl" class="text-body">{{ $post->getTitle() }}</flux:heading>
<time class="text-body/70 mt-2 block">
{{ $post->published_at?->translatedFormat('l, d F Y') ?? $post->created_at->translatedFormat('l, d F Y') }}
</time>
</header>
<div class="prose prose-lg prose-brand max-w-none">
{!! $post->getBody() !!}
</div>
<footer class="mt-12 pt-6 border-t border-accent/20">
<a href="{{ route('posts.index') }}" class="text-primary hover:underline" wire:navigate>
&larr; {{ __('posts.back_to_posts') }}
</a>
</footer>
</article>