File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
resources/views/components Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 33namespace App \Http \Controllers ;
44
55use App \Models \Article ;
6+ use Artesaos \SEOTools \Facades \SEOTools ;
67
78class ShowBlogController extends Controller
89{
@@ -21,6 +22,19 @@ public function show(Article $article)
2122 {
2223 abort_unless ($ article ->isPublished () || auth ()->user ()?->isAdmin(), 404 );
2324
25+ // Set SEO metadata for the article
26+ SEOTools::setTitle ($ article ->title . ' - Blog ' );
27+ SEOTools::setDescription ($ article ->excerpt ?: 'Read this article on the NativePHP blog. ' );
28+
29+ // Set OpenGraph metadata
30+ SEOTools::opengraph ()->setTitle ($ article ->title );
31+ SEOTools::opengraph ()->setDescription ($ article ->excerpt ?: 'Read this article on the NativePHP blog. ' );
32+ SEOTools::opengraph ()->setType ('article ' );
33+
34+ // Set Twitter Card metadata
35+ SEOTools::twitter ()->setTitle ($ article ->title );
36+ SEOTools::twitter ()->setDescription ($ article ->excerpt ?: 'Read this article on the NativePHP blog. ' );
37+
2438 return view ('article ' , [
2539 'article ' => $ article ,
2640 ]);
Original file line number Diff line number Diff line change 5555 $defaultSeoTitle = config (' seotools.meta.defaults.title' );
5656 @endphp
5757
58- @if ($seoTitle === $defaultSeoTitle || empty ( $seoTitle ) )
58+ @if ($seoTitle === $defaultSeoTitle )
5959 <title >{{ isset ($title ) ? $title . ' - ' : ' ' } } NativePHP</title >
6060 @endif
6161
You can’t perform that action at this time.
0 commit comments