diff --git a/src/StaticCaching/NoCache/Session.php b/src/StaticCaching/NoCache/Session.php index f60f9c6b25..cf727fdcba 100644 --- a/src/StaticCaching/NoCache/Session.php +++ b/src/StaticCaching/NoCache/Session.php @@ -2,8 +2,10 @@ namespace Statamic\StaticCaching\NoCache; +use Illuminate\Pagination\AbstractPaginator; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Str; use Statamic\Facades\Cascade; use Statamic\Facades\Data; @@ -113,6 +115,8 @@ public function restore() $this->regions = $this->regions->merge($session['regions'] ?? []); $this->cascade = $this->restoreCascade(); + $this->resolvePageAndPathForPagination(); + return $this; } @@ -124,6 +128,15 @@ private function restoreCascade() ->toArray(); } + private function resolvePageAndPathForPagination(): void + { + AbstractPaginator::currentPathResolver(fn () => Str::before($this->url, '?')); + + AbstractPaginator::currentPageResolver(function () { + return Str::of($this->url)->after('page=')->before('&')->__toString(); + }); + } + private function cacheRegion(Region $region) { Cache::forever('nocache::region.'.$region->key(), $region); diff --git a/src/Tags/Concerns/OutputsItems.php b/src/Tags/Concerns/OutputsItems.php index 000b3de6cf..c4a743dd8d 100644 --- a/src/Tags/Concerns/OutputsItems.php +++ b/src/Tags/Concerns/OutputsItems.php @@ -60,7 +60,7 @@ protected function getPaginationData($paginator) 'current_page' => $paginator->currentPage(), 'prev_page' => $paginator->previousPageUrl(), 'next_page' => $paginator->nextPageUrl(), - 'auto_links' => $paginator->render('pagination::default'), + 'auto_links' => (string) $paginator->render('pagination::default'), 'links' => $paginator->renderArray(), ]; }