tv2regionerne / statamic-endless
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 1
pkg:composer/tv2regionerne/statamic-endless
Requires
- livewire/livewire: ^3.4
- statamic/cms: ^4.48 || ^5.0
This package is auto-updated.
Last update: 2025-10-29 03:33:05 UTC
README
Statamic Endless allows you to create infinite scroll lists that automatically or manually load new entries when you get to the end.
How to Install
You can search for this addon in the Tools > Addons section of the Statamic control panel and click install, or run the following command from your project root:
composer require tv2regionerne/statamic-endless
How to Use
Make sure Livewire v3 is installed, then use the collection:endless tag:
{{ collection:endless as="posts" from="blog" paginate="5" }}
<div x-ref="append">
{{ posts }}
{{ partial:blog/post }}
{{ /posts }}
</div>
<button x-on:click="trigger" x-show="paginate.has_more_pages">Load More</button>
{{ /collection:endless }}
Example with intersectors:
{{ collection:endless as="posts" from="blog" paginate="5" }}
<div x-ref="append">
{{ posts }}
{{ partial:blog/post }}
{{ /posts }}
</div>
<div
x-data="{
intersecting: false,
init() {
$watch('intersecting', () => this.check());
},
check() {
if (this.intersecting && paginate.has_more_pages) {
trigger().then(() => this.check());
}
},
}"
x-show="!loading && paginate.has_more_pages"
x-intersect:enter="intersecting = true"
x-intersect:leave="intersecting = false">
</div>
{{ /collection:endless }}
You must enable pagination.
The content will be wrapped in a Livewire/Alpine component:
- You should add an
x-refof eitherappendorprependto the element that contains your list. - You can call
triggerto load more entries usingx-intersectorx-on. - You can check the loading state with
loading.
On secondary loads variables from outside tag scope will only be avaliable if you list them in the context parameter (pipe delimited). These variables must be serializable.