laravel seo hook for js frameworks
simple hook for adding meta tags to
for js frameworks inertia:react,vue, etc...-
in app/Meta.php put Meta.php code from repo.
-
in your main blade file (example: app.blade.php) add this
{!! \App\Meta::baseRender() !!}
- in app/Providers/EventServiceProvider.php add this (also you need to install laravel/octane) composer require laravel/octane
use App\Meta;
use Illuminate\Support\Facades\Event;
use Laravel\Octane\Events\RequestReceived;
public function boot()
{
Event::listen(function (RequestReceived $_) {
Meta::cleanup();
});
}
- finally in your controller you can do this
use App\Meta;
public function index() {
Meta::addBaseMeta('My Awesome Title ');
return Inertia::render('Dashboard');
}