seotools
seotools copied to clipboard
Add support to macro
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 |
Can you provide some tests @omarname ?
@vinicius73 this doesn't need any testing cause i just added Macroable trait and there is no conflit with methods name.
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.
That sounds good @omarherri but we need at least a README.md update to keep this documented.