c6digital / filament-og-manager
Manage your site's Open Graph tags inside of Filament.
Fund package maintenance!
c6digital
Requires
- php: ^8.1
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
README
This package provides a global SEO page that lets you manage Open Graph tags, as well as a set of fields to manage Open Graph tags for specific resources.
Installation
You can install the package via Composer:
composer require c6digital/filament-og-manager
Run the installation command for the package:
php artisan og-manager:install
This will publish and execute migrations.
Usage
Register the plugin:
use C6Digital\OgManager\OgManagerPlugin; $panel ->plugin( OgManagerPlugin::make() );
The global SEO page will be registered with your panel and automatically appear inside of the panel. Use this form to manage your site wide Open Graph tags.
Rendering meta tags
To render meta tags in your Blade templates, use the provided component:
<head> <x-og-manager::seo /> </head>
Model-specific tags
This package provides a custom group of fields that you can add to your own resource forms.
use C6Digital\OgManager\Components\SEO; public function form(Form $form): Form { return $form->schema([ SEO::make(), ]); }
You'll then need to add the HasOpenGraphMeta
trait to your model.
use C6Digital\OgManager\Concerns\HasOpenGraphMeta; class Post extends Model { use HasOpenGraphMeta; }
This registers a new openGraphMeta
relationship on your model which this field uses.
To render meta tags for a specific model, pass the model through to the Blade component using the for
prop.
<head> <x-og-manager::seo :for="$post" /> </head>
Changing the URL
This package defaults to using url()->current()
when rendering meta tags (og:url
, twitter:url
). If you want to change URL you can pass it through as a prop to the Blade component.
<x-og-manager::seo :url="route('posts.show', $post)" />
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.