From d14694f16218187debc09e0312afd84aee567554 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 27 Jul 2020 11:23:14 +0200 Subject: [PATCH 1/4] :sparkles: Ajoute le module SEO Pour #8 --- app/Http/Controllers/PublicController.php | 10 ++++ composer.json | 1 + composer.lock | 69 ++++++++++++++++++++++- config/app.php | 2 + config/seotools.php | 68 ++++++++++++++++++++++ resources/views/layouts/app.blade.php | 2 + 6 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 config/seotools.php diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php index 9919619..4e600a7 100644 --- a/app/Http/Controllers/PublicController.php +++ b/app/Http/Controllers/PublicController.php @@ -3,12 +3,22 @@ namespace App\Http\Controllers; use App\Home; +use Artesaos\SEOTools\Traits\SEOTools as SEOToolsTrait; class PublicController extends Controller { + use SEOToolsTrait; + public function show($slug) { $home = Home::where('slug', $slug)->firstOrFail(); + $this->seo() + ->setTitle($home->title) + ->setDescription($home->excerpt()) + ->addImages(array_map(static function($picture) { + return asset($picture); + }, $home->pictures)); + return view('public.view', ['home' => $home]); } } diff --git a/composer.json b/composer.json index a4a9eb7..5c890e5 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": "^7.2.5", "ext-json": "*", "absmoca/leboncoin": "dev-master", + "artesaos/seotools": "^0.18.0", "emanueleminotto/simple-html-dom": "^1.5", "fabpot/goutte": "^3.1", "fideloper/proxy": "^4.2", diff --git a/composer.lock b/composer.lock index 678827e..ccf10df 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "71386ccf87ea9b8b3be2921f40baca69", + "content-hash": "b1bb2469deb87a0a1452b8b376e64e1a", "packages": [ { "name": "absmoca/leboncoin", @@ -43,6 +43,73 @@ "description": "SDK du plus célèbre site entre particuliers en France", "time": "2019-01-06T10:00:50+00:00" }, + { + "name": "artesaos/seotools", + "version": "v0.18.0", + "source": { + "type": "git", + "url": "https://github.com/artesaos/seotools.git", + "reference": "91c9fc3ee18db01d220dd47708f303b8eff8078b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/artesaos/seotools/zipball/91c9fc3ee18db01d220dd47708f303b8eff8078b", + "reference": "91c9fc3ee18db01d220dd47708f303b8eff8078b", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/config": "5.8.* || ^6.0 || ^7.0", + "illuminate/support": "5.8.* || ^6.0 || ^7.0", + "php": ">=7.1" + }, + "require-dev": { + "orchestra/testbench": "~3.8.4 || ^4.0 || ^5.0", + "phpspec/phpspec": "~5.1.1 || ^6.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Artesaos\\SEOTools\\Providers\\SEOToolsServiceProvider" + ], + "aliases": { + "SEOMeta": "Artesaos\\SEOTools\\Facades\\SEOMeta", + "OpenGraph": "Artesaos\\SEOTools\\Facades\\OpenGraph", + "Twitter": "Artesaos\\SEOTools\\Facades\\TwitterCard", + "JsonLd": "Artesaos\\SEOTools\\Facades\\JsonLd", + "SEO": "Artesaos\\SEOTools\\Facades\\SEOTools" + } + } + }, + "autoload": { + "psr-4": { + "Artesaos\\SEOTools\\": "src/SEOTools/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Vinicius", + "email": "luiz.vinicius73@gmail.com" + } + ], + "description": "SEO Tools for Laravel and Lumen", + "keywords": [ + "JSON-LD", + "laravel", + "lumen", + "metatags", + "opengraph", + "seo", + "seotools", + "webmaster" + ], + "time": "2020-06-19T22:31:46+00:00" + }, { "name": "asm89/stack-cors", "version": "v2.0.1", diff --git a/config/app.php b/config/app.php index ae0804b..706dd01 100644 --- a/config/app.php +++ b/config/app.php @@ -165,6 +165,7 @@ return [ /* * Package Service Providers... */ + Artesaos\SEOTools\Providers\SEOToolsServiceProvider::class, /* * Application Service Providers... @@ -220,6 +221,7 @@ return [ 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, + 'SEO' => Artesaos\SEOTools\Facades\SEOTools::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'Str' => Illuminate\Support\Str::class, diff --git a/config/seotools.php b/config/seotools.php new file mode 100644 index 0000000..38d7c40 --- /dev/null +++ b/config/seotools.php @@ -0,0 +1,68 @@ + [ + /* + * The default configurations to be used by the meta generator. + */ + 'defaults' => [ + 'title' => 'Le projet Bretagne', // set false to total remove + 'titleBefore' => false, // Put defaults.title before page title, like 'It's Over 9000! - Dashboard' + 'description' => false, // set false to total remove + 'separator' => ' - ', + 'keywords' => ['immobilier'], + 'canonical' => false, // Set null for using Url::current(), set false to total remove + 'robots' => false, // Set to 'all', 'none' or any combination of index/noindex and follow/nofollow + ], + /* + * Webmaster tags are always added. + */ + 'webmaster_tags' => [ + 'google' => null, + 'bing' => null, + 'alexa' => null, + 'pinterest' => null, + 'yandex' => null, + 'norton' => null, + ], + + 'add_notranslate_class' => false, + ], + 'opengraph' => [ + /* + * The default configurations to be used by the opengraph generator. + */ + 'defaults' => [ + 'title' => 'Le projet Bretagne', // set false to total remove + 'description' => false, + 'url' => false, // Set null for using Url::current(), set false to total remove + 'type' => 'article', + 'site_name' => false, + 'images' => [], + ], + ], + 'twitter' => [ + /* + * The default values to be used by the twitter cards generator. + */ + 'defaults' => [ + 'card' => 'summary', + 'site' => '@shikiryu', + ], + ], + 'json-ld' => [ + /* + * The default configurations to be used by the json-ld generator. + */ + 'defaults' => [ + 'title' => 'Le projet Bretagne', // set false to total remove + 'description' => false, // set false to total remove + 'url' => false, // Set null for using Url::current(), set false to total remove + 'type' => 'WebPage', + 'images' => [], + ], + ], +]; diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index daee28a..c2df0b3 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -4,6 +4,8 @@ + {!! SEO::generate() !!} + -- 2.30.2 From 87b71213eb2e179e9bf2e5874340bac3745c695e Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 27 Jul 2020 11:50:54 +0200 Subject: [PATCH 2/4] :wrench: Ajoute la configuration OG Pour #8 --- app/Http/Controllers/PublicController.php | 5 +++++ config/seotools.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php index 4e600a7..e5deea7 100644 --- a/app/Http/Controllers/PublicController.php +++ b/app/Http/Controllers/PublicController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Home; use Artesaos\SEOTools\Traits\SEOTools as SEOToolsTrait; +use DateTime; class PublicController extends Controller { @@ -18,6 +19,10 @@ class PublicController extends Controller ->addImages(array_map(static function($picture) { return asset($picture); }, $home->pictures)); + $this->seo() + ->opengraph() + ->addProperty('article:published_time', $home->created_at->format(DateTime::ATOM)) + ->addProperty('article:author', 'Shikiryu'); return view('public.view', ['home' => $home]); } diff --git a/config/seotools.php b/config/seotools.php index 38d7c40..d56585a 100644 --- a/config/seotools.php +++ b/config/seotools.php @@ -40,7 +40,7 @@ return [ 'description' => false, 'url' => false, // Set null for using Url::current(), set false to total remove 'type' => 'article', - 'site_name' => false, + 'site_name' => 'Le projet Bretagne', 'images' => [], ], ], -- 2.30.2 From 6a835c4099fef4087c4903a0f659070112552f09 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 27 Jul 2020 11:57:18 +0200 Subject: [PATCH 3/4] =?UTF-8?q?:wrench:=20N'affiche=20les=20meta=20donn?= =?UTF-8?q?=C3=A9es=20qu'en=20guest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour #8 --- resources/views/layouts/app.blade.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index c2df0b3..0dffb9b 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -4,7 +4,9 @@ + @if(\Illuminate\Support\Facades\Auth::guest()) {!! SEO::generate() !!} + @endif -- 2.30.2 From 655c242d7a27313e9b9af4ec87d0c7c845cd0ca1 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 27 Jul 2020 12:00:47 +0200 Subject: [PATCH 4/4] :art: Utilise un alias --- resources/views/layouts/app.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 0dffb9b..ef24308 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -4,7 +4,7 @@ - @if(\Illuminate\Support\Facades\Auth::guest()) + @if(Auth::guest()) {!! SEO::generate() !!} @endif -- 2.30.2