From f59503bb38cbbaa2040dde82e43c0a917e5c4e9a Mon Sep 17 00:00:00 2001 From: Vinicius Reis Date: Thu, 5 Mar 2015 00:21:03 -0300 Subject: [PATCH] OpenGraph readme --- README.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7feef32..815f753 100644 --- a/README.md +++ b/README.md @@ -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; @@ -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(); @@ -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 {!! SEOMeta::generate() !!} + {!! OpenGraph::generate() !!} @@ -111,6 +134,21 @@ class CommomController extends Controller + + + + + + + + + + + + + + + @@ -118,6 +156,14 @@ class CommomController extends Controller ``` +#### 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); @@ -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(); +``` \ No newline at end of file