c6digital/filament-og-manager

Manage your site's Open Graph tags inside of Filament.

v0.1.2 2024-10-01 15:13 UTC

This package is auto-updated.

Last update: 2024-10-31 15:22:01 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.