Skip to content

Commit

Permalink
OpenGraph readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vinicius73 committed Mar 5, 2015
1 parent 63c0ab1 commit f59503b
Showing 1 changed file with 73 additions and 4 deletions.
77 changes: 73 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ In order to use the `SEOMeta` facade, you need to register it on the `config/app
// file START ommited
'aliases' => [
// other Facades ommited
'SEOMeta' => 'Artesaos\SEOTools\Facades\SEOMeta',
'SEOMeta' => 'Artesaos\SEOTools\Facades\SEOMeta',
'OpenGraph' => 'Artesaos\SEOTools\Facades\OpenGraph',
],
// file END ommited
```
## Usage
### 1 - Metatags Generator
## 4 - Usage
### Meta tags Generator
With **SEOMeta** you can create meta tags to the `head`

### Opengraph tags Generator
With **OpenGraph** you can create opengraph tags to the `head`

#### In your controller
```php
use SEOMeta;
Expand All @@ -66,6 +72,11 @@ class CommomController extends Controller
{
SEOMeta::setTitle('Home');
SEOMeta::setDescription('This is my page description');

OpenGraph::setDescription('This is my page description');
OpenGraph::setTitle('Home');
OpenGraph::setUrl('http://current.url.com');
OpenGraph::addProperty('type', 'articles');

$posts = Post::all();

Expand All @@ -84,18 +95,30 @@ class CommomController extends Controller
SEOMeta::addMeta('article:published_time', $post->published_date->toW3CString(), 'property');
SEOMeta::addMeta('article:section', $post->category, 'property');
SEOMeta::addKeyword(['key1', 'key2', 'key3']);

OpenGraph::setDescription($post->title);
OpenGraph::setTitle($post->resume);
OpenGraph::setUrl('http://current.url.com');
OpenGraph::addProperty('type', 'article');
OpenGraph::addProperty('locale', 'pt-br');
OpenGraph::addProperty('locale:alternate', ['pt-pt', 'en-us']);

OpenGraph::addImage($post->cover->url);
OpenGraph::addImage($post->images->list('url));
OpenGraph::addImage(['url' => 'http://image.url.com/cover.jpg', 'size' => 300]);

return view('myshow', compact('post'));
}
}
```

#### In Your View
### In Your View

```html
<html>
<head>
{!! SEOMeta::generate() !!}
{!! OpenGraph::generate() !!}
</head>
<body>

Expand All @@ -111,13 +134,36 @@ class CommomController extends Controller
<meta name='keywords' content='key1, key2, key3' />
<meta property='article:published_time' content='2015-01-31T20:30:11-02:00' />
<meta property='article:section' content='news' />

<meta property="og:description"content="description..." />
<meta property="og:title"content="Title" />
<meta property="og:url"content="http://current.url.com" />
<meta property="og:type"content="article" />
<meta property="og:locale"content="pt-br" />
<meta property="og:locale:alternate"content="pt-pt" />
<meta property="og:locale:alternate"content="en-us" />
<meta property="og:site_name"content="name" />
<meta property="og:image"content="http://image.url.com/cover.jpg" />
<meta property="og:image"content="http://image.url.com/img1.jpg" />
<meta property="og:image"content="http://image.url.com/img2.jpg" />
<meta property="og:image"content="http://image.url.com/img3.jpg" />
<meta property="og:image:url"content="http://image.url.com/cover.jpg" />
<meta property="og:image:size"content="300" />
</head>
<body>

</body>
</html>
```

#### Configuration
In `seotools.php` configuration file you can determine the properties of the default values and some behaviors.
- meta
- **defaults** - What values are displayed if not specified any value for the page display. If the value is `false`, nothing is displayed.
- **webmaster** - Are the settings of tags values for major webmaster tools. If you are `null` nothing is displayed.
- opengraph
- **defaults** - Are the properties that will always be displayed and when no other value is set instead. **You can add additional tags** that are not included in the original configuration file.

#### API (SEOMeta)
```php
SEOMeta::setTitle($title);
Expand All @@ -142,3 +188,26 @@ SEOMeta::reset();

SEOMeta::generate();
```

#### API (OpenGraph)
```php
OpenGraph::addProperty($key, $value); // value can be string or array
OpenGraph::addImage($url); // add image url
OpenGraph::addImages($url); // add an array of url images
OpenGraph::setTitle($title); // define title
OpenGraph::setDescription($description); // define description
OpenGraph::setUrl($url); // define url
OpenGraph::setSiteName($name); //define site_name

// You can concatenate methods
OpenGraph::addProperty($key, $value)
->addImage($url)
->addImages($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSiteName($name);

// Generate html tags
OpenGraph::generate();
```

0 comments on commit f59503b

Please sign in to comment.