53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\BlogPost;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
/**
|
|
* BlogController — /blog index + single post.
|
|
*/
|
|
final class BlogController extends Controller
|
|
{
|
|
public function index(Request $request): View
|
|
{
|
|
$posts = BlogPost::published()
|
|
->orderByDesc('published_at')
|
|
->paginate(12)
|
|
->withQueryString();
|
|
|
|
return view('web.blog.index', [
|
|
'posts' => $posts,
|
|
'page_title' => 'Blog — Skinbase',
|
|
'page_meta_description' => 'News, tutorials and community stories from the Skinbase team.',
|
|
'page_canonical' => url('/blog'),
|
|
'page_robots' => 'index,follow',
|
|
'breadcrumbs' => collect([
|
|
(object) ['name' => 'Blog', 'url' => '/blog'],
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public function show(string $slug): View
|
|
{
|
|
$post = BlogPost::published()->where('slug', $slug)->firstOrFail();
|
|
|
|
return view('web.blog.show', [
|
|
'post' => $post,
|
|
'page_title' => ($post->meta_title ?: $post->title) . ' — Skinbase Blog',
|
|
'page_meta_description' => $post->meta_description ?: $post->excerpt ?: '',
|
|
'page_canonical' => $post->url,
|
|
'page_robots' => 'index,follow',
|
|
'breadcrumbs' => collect([
|
|
(object) ['name' => 'Blog', 'url' => '/blog'],
|
|
(object) ['name' => $post->title, 'url' => $post->url],
|
|
]),
|
|
]);
|
|
}
|
|
}
|