This repository was archived by the owner on Oct 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +48
-0
lines changed Expand file tree Collapse file tree 5 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ @extends (' layout' )
2+
3+ @section (' content' )
4+
5+ SEODirectives
6+
7+ @seoTitle (' Custom Title' )
8+ @seoDescription (' Custom Description' )
9+ @seoKeywords ([' Custom' , ' Keywords' ] )
10+
11+ @endsection
Original file line number Diff line number Diff line change 233233 })->name ('rehydrateTwice ' );
234234
235235 Route::view ('script ' , 'script ' )->name ('script ' );
236+ Route::view ('seoDirectives ' , 'seoDirectives ' )->name ('seoDirectives ' );
236237
237238 Route::post ('state ' , function () {
238239 Splade::share ('info ' , 'This is invalid ' );
Original file line number Diff line number Diff line change @@ -61,4 +61,16 @@ public function it_updates_the_head_when_modals_are_opened_and_closed()
6161 ->assertTitle ('Modal Base ' );
6262 });
6363 }
64+
65+ /** @test */
66+ public function it_has_blade_directives_to_set_the_seo ()
67+ {
68+ $ this ->browse (function (Browser $ browser ) {
69+ $ browser ->visit ('/seoDirectives ' )
70+ ->waitForText ('SEODirectives ' )
71+ ->assertTitle ('Custom Title ' )
72+ ->assertMetaByName ('description ' , 'Custom Description ' )
73+ ->assertMetaByName ('keywords ' , 'Custom, Keywords ' );
74+ });
75+ }
6476}
Original file line number Diff line number Diff line change 6464 'component_prefix ' => 'splade ' ,
6565 'table_cell_directive ' => 'cell ' ,
6666 'escape_validation_messages ' => true ,
67+ 'seo_title_directive ' => 'seoTitle ' ,
68+ 'seo_description_directive ' => 'seoDescription ' ,
69+ 'seo_keywords_directive ' => 'seoKeywords ' ,
6770 ],
6871
6972 /**
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public function registerHandlers()
1919 Blade::directive ('spladeHead ' , [$ this , 'spladeHead ' ]);
2020 Blade::directive ('preserveScroll ' , [$ this , 'preserveScroll ' ]);
2121
22+ $ this ->registerSEODirectives ();
2223 $ this ->registerTableCellDirective ();
2324 }
2425
@@ -90,6 +91,26 @@ public static function parseTableCellDirectiveExpression(string $expression): ar
9091 return [$ name , $ function ];
9192 }
9293
94+ /**
95+ * Registers the Blade SEO directives.
96+ *
97+ * @return void
98+ */
99+ public function registerSEODirectives ()
100+ {
101+ Blade::directive (config ('splade.blade.seo_title_directive ' ), function ($ expression ) {
102+ return "<?php \ProtoneMedia\Splade\Facades\SEO::title( $ expression); ?> " ;
103+ });
104+
105+ Blade::directive (config ('splade.blade.seo_description_directive ' ), function ($ expression ) {
106+ return "<?php \ProtoneMedia\Splade\Facades\SEO::description( $ expression); ?> " ;
107+ });
108+
109+ Blade::directive (config ('splade.blade.seo_keywords_directive ' ), function ($ expression ) {
110+ return "<?php \ProtoneMedia\Splade\Facades\SEO::keywords( $ expression); ?> " ;
111+ });
112+ }
113+
93114 /**
94115 * Registers the Blade @cell directive.
95116 *
You can’t perform that action at this time.
0 commit comments