File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ private function setupTagHooks()
181181 });
182182
183183 Tags \Nav::hook ('init ' , function ($ value , $ next ) use ($ self ) {
184- $ handle = 'nav: ' .$ this ->params ->get ('handle ' , ' collection::pages ' );
184+ $ handle = 'nav: ' .$ this ->params ->get ('handle ' , Str:: after ( $ this -> tag , ' nav: ' ) );
185185 $ self ->addContentTag ($ handle );
186186
187187 return $ next ($ value );
Original file line number Diff line number Diff line change @@ -41,6 +41,38 @@ public function it_tracks_nav_tag_with_explicit_handle()
4141 $ this ->assertContains ('nav:footer ' , $ tags );
4242 }
4343
44+ #[Test]
45+ public function it_tracks_nav_tag_with_shorthand_handle ()
46+ {
47+ // Create a navigation structure
48+ Facades \Nav::make ('footer ' )
49+ ->title ('Footer ' )
50+ ->expectsRoot (true )
51+ ->collections (['pages ' ])
52+ ->save ();
53+
54+ $ view = <<<'BLADE'
55+ {{ nav:footer }}
56+ {{ title }}
57+ {{ /nav:footer }}
58+ BLADE;
59+
60+ file_put_contents ($ this ->viewPath ('nav-test.antlers.html ' ), $ view );
61+
62+ Facades \Entry::make ()
63+ ->id ('nav-test-page ' )
64+ ->slug ('nav-test ' )
65+ ->collection ('pages ' )
66+ ->data (['template ' => 'nav-test ' ])
67+ ->save ();
68+
69+ $ this ->get ('/nav-test ' );
70+
71+ $ tags = collect (Tracker::all ())->first ()['tags ' ] ?? [];
72+
73+ $ this ->assertContains ('nav:footer ' , $ tags );
74+ }
75+
4476 #[Test]
4577 public function it_tracks_nav_tag_without_handle_using_default ()
4678 {
You can’t perform that action at this time.
0 commit comments