seotools icon indicating copy to clipboard operation
seotools copied to clipboard

Add support to macro

Open omarherri opened this issue 3 years ago • 4 comments

Support macro feature, so that we can use some of the code in multiple places.

This is an exemple of use case: Macro file:

SEO::macro('detail', function ($product) {
    SEO::jsonLd()->addValue('@graph', [
     '@type' => 'Product',
                '@id' => request()->url() . '#product',
                'name' => ucfirst($product->meta->name),
                'url' => request()->url(),
                'description' => ucfirst($product->meta->name)
                //....
    ]);
});

And in controller we can use this: SEO::detail($product);

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Tests pass? ✔️
Fixed issues comma-separated list of tickets # fixed by the PR, if any

omarherri avatar Sep 04 '21 17:09 omarherri

Can you provide some tests @omarname ?

vinicius73 avatar Sep 29 '21 14:09 vinicius73

@vinicius73 this doesn't need any testing cause i just added Macroable trait and there is no conflit with methods name.

omarherri avatar Oct 01 '21 20:10 omarherri

This would be useful in way that we don't have to duplicate the same code every where. This only add compatibility with Laravel macro.

omarherri avatar Oct 01 '21 20:10 omarherri

That sounds good @omarherri but we need at least a README.md update to keep this documented.

vinicius73 avatar Feb 06 '22 04:02 vinicius73