paginate news

This commit is contained in:
HolgerHatGarKeineNode
2023-03-16 17:22:50 +01:00
parent ab451eb74b
commit 47e5d9ea58
2 changed files with 26 additions and 1 deletions

View File

@@ -13,12 +13,19 @@ class ArticleOverview extends Component
use Actions; use Actions;
use NostrTrait; use NostrTrait;
public $perPage = 9;
public array $filters = []; public array $filters = [];
protected $queryString = [ protected $queryString = [
'filters' => ['except' => ''], 'filters' => ['except' => ''],
]; ];
public function loadMore()
{
$this->perPage += 9;
}
public function nostr($id) public function nostr($id)
{ {
$libraryItem = LibraryItem::query() $libraryItem = LibraryItem::query()
@@ -84,7 +91,7 @@ class ArticleOverview extends Component
->where('type', 'markdown_article') ->where('type', 'markdown_article')
->where('news', true) ->where('news', true)
->orderByDesc('created_at') ->orderByDesc('created_at')
->get(), ->paginate($this->perPage),
])->layout('layouts.app', [ ])->layout('layouts.app', [
'SEOData' => new SEOData( 'SEOData' => new SEOData(
title: __('News'), title: __('News'),

View File

@@ -173,6 +173,24 @@
@endif @endif
@endforeach @endforeach
<div
x-data="{
observe () {
let observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
@this.call('loadMore')
}
})
}, {
root: null
})
observer.observe(this.$el)
}
}"
x-init="observe"
></div>
</div> </div>
</div> </div>
</div> </div>