, (*1)
Install
Via Composer, (*2)
``` bash
$ composer require arrounded/metadata, (*3)
## Usage
First add the module's service provider and facade to `config/app.php`:
```php
Arrounded\Metadata\ServiceProvider::class,
'Metadata' => Arrounded\Metadata\Facades\Metadata::class,
Then somewhere in your service provider, define your application's metadata. Either by passing it an array:, (*4)
$this->app['arrounded.metadata']->setMetadata([
['url' => 'foo.com', 'title' => Homepage', 'description' => 'foobar'],
]);
Or by indicating it the path to a CSV file:, (*5)
metadata.csv, (*6)
url,title,description
foo.com,Homepage,foobar
$this->app['arrounded.metadata']->setMetadataFromFile('metadata.csv');
Then in your views call the render
method on the facade. It'll look at the current URL and find the correct metadata for the page.
You can also pass it an array of additional metadata:, (*7)
{{ Metadata.render() }}
{{ Metadata.render({image: 'foo.com/logo.png'}) }}
By default all properties (except core ones such as title, description etc) are also wrapped in Twitter/Facebook graph metadata.
You can disable this behavior by setting which properties should not be wrapped:, (*8)
$this->app['arrounded.metadata']->setMetadataFromFile('metadata.csv');
$this->app['arrounded.metadata']->setUnwrapped(['property', 'other_property']);
Testing
bash
$ composer test
, (*9)
License
The MIT License (MIT). Please see License File for more information., (*10)