ARCANEDEV / SEO-Helper

:mag: SEO Helper is a package that provides tools and helpers for SEO (Search Engine Optimization).
MIT License
322 stars 49 forks source link

Extend Laravel support for custom meta and link tags #40

Closed bridgeport closed 6 years ago

bridgeport commented 6 years ago

Description:

Thanks for this package. Do you have any plans to extend the Laravel Trait to support the full range of capabilities this package has, such as being able to do the following:

class PostController extends Controller
{
    public function list()
    {
        $this->seo()->addMeta('prev', url('/page-1')); // Or 'addLink()' if more appropriate.
        $this->seo()->addMeta('next', url('/page-3'));
        $this->seo()->addMeta('robots', 'follow, noindex');
    }
}
arcanedev-maroc commented 6 years ago

You can do this:

$this->seo()->meta()->addMeta('prev', url('/page-1'));
$this->seo()->meta()->addMeta('next', url('/page-3'));
$this->seo()->meta()->addMeta('robots', 'follow, noindex');

// OR
$this->seo()->meta()->addMeta('prev', url('/page-1'))
                    ->addMeta('next', url('/page-3'))
                    ->addMeta('robots', 'follow, noindex');

// OR
$this->seo()->meta()->addMetas([
    'prev'   => url('/page-1'),
    'next'   => url('/page-3'),
    'robots' => 'follow, noindex',
]);

For the addLink(), you can make a PR to add this feature in the SeoMeta class if you want.

Hope this helps you :+1:

bridgeport commented 6 years ago

@arcanedev-maroc Thanks for pointing this out. It's exactly what I need.

I see there's no need for addLink() as your package already properly maps properties like prev and next to render with the link tag instead of meta tag.

Thanks again.