In this episode, we get hands-on with bringing article data onto the page using Livewire. We start by creating a new Livewire component for listing articles (the Article Index) and set it up on our dashboard. Then, we jump into the component logic to fetch all articles, order them from latest to oldest, and finally pass them through to our Blade view.
We walk step-by-step through rendering this data with a simple @foreach
loop, so every article's title, ID, and teaser are shown. This approach makes it easy to visually confirm everything is appearing in the correct order, especially when preparing for infinite scroll.
Once we’ve got all 100 articles flooding the page (which we definitely don’t want long term!), we tackle pagination next. The magic comes in by adding Livewire’s WithPagination
trait and tweaking the component so only 10 articles appear per page. We discuss how to keep track of which page the user is on, and why, for infinite scroll, we wouldn’t want to reflect that page number in the URL.
By the end of this episode, we’ve got a page showing just the first 10 articles, ready to be extended. Next up: we’ll wire up a “load more” button and set the stage for true infinite scrolling with Intersection Observer. Stick around, we’re almost there!