-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SEO Pagination Meta Tags rel="next" / rel="prev" #79
Comments
Hi @mauricekindermann, I actually didn't know these pagination tags existed. I think it would be great to add. If you are willing to provide a PR, you could add a |
Hmm. I tried but failed. I couldn't get it working with the livewire sub compontent I am using. seoData recieves it but then loses it, my best guess is due to the livewire being overwritten by the main page controlling it is my guess. If you like I can PR my non-working code, but that might be more work than is worth it. I will try again in a few days. |
Actually here is the code, better than a PR since it doesn't work. seoData use Illuminate\Contracts\Pagination\LengthAwarePaginator;
//
public ?LengthAwarePaginator $paginator = null, TagCollection use RalphJSmit\Laravel\SEO\Support\PaginatorTagCollection;
///
PaginatorTagCollection::initialize($SEOData?->paginator), PaginatorTagCollection <?php
namespace RalphJSmit\Laravel\SEO\Support;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Support\Collection;
class PaginatorTagCollection extends Collection implements Renderable
{
public static function initialize(?LengthAwarePaginator $paginator): static
{
$collection = new static();
if ($paginator && $paginator->hasPages()) {
// I could not get this to return true.
}
return $collection;
}
public function render()
{
return $this->map(fn (LinkTag $tag) => $tag->render())->implode(PHP_EOL);
}
} And in my view I would return return view('livewire.x-component', [
'SEOData' => new SEOData(
paginator: $this->paginatedMethod(),
),
]); I'm still pretty new to laravel so it's a bit of a black box to me to understand how to debug it in a way that will help me get it working. |
If you could PR your wip code then I can take a look at that. |
Hey @mauricekindermann, I think the reason is that you're providing the SEOData parameter to the Livewire Blade component (so the actual Blade of the LW component), whilst the SEOData should be provided to the layout file. Does the paginator |
As far as I can see this package doesn't handle pagination SEO tags? I had to publish my pagination views to make them pretty, so for now I've just added them this way.
But if there is a nicer solution let me know.. Otherwise I can look to do a PR in the future.
The text was updated successfully, but these errors were encountered: