2024, 'query' => 'design']) * The 'page' key is injected automatically; do not include it. * * Usage: * $year]); ?> * */ if (!isset($page, $totalPages) || $totalPages <= 1) { return; // nothing to render } $baseParams = isset($baseParams) && is_array($baseParams) ? $baseParams : []; /** Build a URL for a given target page, preserving all base params. */ $paginationUrl = static function(int $targetPage) use ($baseParams): string { return '?' . http_build_query(array_merge($baseParams, ['page' => $targetPage])); }; $atFirst = $page <= 1; $atLast = $page >= $totalPages; /** Build HTMX attributes for a non-disabled pagination link. */ $hxAttrs = static function(string $url): string { return 'hx-get="' . htmlspecialchars($url) . '"' . ' hx-target="#search-results"' . ' hx-swap="outerHTML"' . ' hx-push-url="' . htmlspecialchars($url) . '"'; }; ?>