feat: display ten most-recent articles on homepage

This commit is contained in:
Jonathan Nielson 2025-03-19 16:40:54 -05:00
parent e8188c28bb
commit 62a9279603
2 changed files with 16 additions and 1 deletions

View File

@ -7,4 +7,18 @@
<h1>{{ config('blog.publishing_name') }}<h1> <h1>{{ config('blog.publishing_name') }}<h1>
<p><i>{{ config('blog.subheading') }}</i></p> <p><i>{{ config('blog.subheading') }}</i></p>
</section> </section>
<section>
@forelse($articles as $article)
<article>
<h3>
Article: {{ $article->title }}
</h3>
<p>
{!! $article->body !!}
</p>
</article>
@empty
<div>No articles published yet. Check back soon!</div>
@endforelse
</section>
@endsection @endsection

View File

@ -16,7 +16,8 @@ use Illuminate\Support\Facades\Route;
*/ */
Route::get('/', function () { Route::get('/', function () {
return view('guest.home'); $articles = Article::latest()->limit(10)->get();
return view('guest.home', ['articles' => $articles]);
}); });
Route::get('/test-insert', function () { Route::get('/test-insert', function () {