Skip to content

Commit

Permalink
conditionable seo
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Sep 13, 2024
1 parent d081867 commit 683e80b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,16 @@ class HomeController extends Controller
public function __invoke()
{
// Using the helper
seo()->setTitle("Homepage")->setDescription("The homepage description");
seo()
->setTitle("Homepage")
->setDescription("The homepage description")
->when($condition, fn($seo) => $seo->noIndex());

// Using the facade
SeoManager::current()->setTitle("Homepage")->setDescription("The homepage description");
SeoManager::current()
->setTitle("Homepage")
->setDescription("The homepage description")
->when($condition, fn($seo) => $seo->noIndex());

return view('home');
}
Expand Down
3 changes: 3 additions & 0 deletions src/SeoManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
use Elegantly\Seo\Twitter\Cards\Card;
use Elegantly\Seo\Twitter\Cards\Summary;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Traits\Conditionable;
use Stringable;

class SeoManager implements Htmlable, Stringable, Taggable
{
use Conditionable;

/**
* @param null|Schema[] $schemas
*/
Expand Down

0 comments on commit 683e80b

Please sign in to comment.