Skip to content

Commit 2c11b05

Browse files
committed
Swap order of examples
1 parent 377a2ba commit 2c11b05

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

docs/advanced-features/navigation-api.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,15 @@ Create routed navigation items by providing either a `Route` instance or a route
182182

183183
```php
184184
// Using a Route instance will automatically fill in the label and priority from the route's connected page.
185-
$item = new NavigationItem(Routes::get('index'));
186-
// ['destination' => 'index.html', 'label' => 'Home', 'priority' => 0]
187-
188-
// Using a route key provides the same functionality as using a Route instance.
185+
// Using a route key provides the same functionality as using a Route instance, trading a bit of type safety for convenience.
189186
// Make sure the route exists otherwise it will be treated as a link.
190-
$item = new NavigationItem('index'); // Exactly the same as above, but without type safety.
187+
$item = new NavigationItem('index');
188+
189+
//
190+
$item = new NavigationItem(Routes::get('index'));
191191

192192
// Setting the label and/or priorities will override the page's data.
193-
$item = new NavigationItem(Routes::get('index'), 'Custom Label', 10);
194-
// ['destination' => 'index.html', 'label' => 'Custom Label', 'priority' => 10]
193+
$item = new NavigationItem(Routes::get('index'), 'Custom Label', 100);
195194
```
196195

197196
## NavigationGroup

packages/framework/tests/Feature/NavigationAPITest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public function testNavigationItems()
6161
// The constructors take three parameters: the destination, the label, and the optional priority.
6262
// The destination can be a Route instance, a route key string, or an external URL.
6363

64-
// Using a Route instance will automatically fill in the label and priority from the route's connected page.
65-
$item = new NavigationItem(Routes::get('index'));
66-
$this->assertData(['destination' => 'index.html', 'label' => 'Home', 'priority' => 0], $item);
67-
6864
// Using a route key provides the same functionality as using a Route instance.
6965
// Make sure the route exists otherwise it will be treated as a link.
7066
$item = new NavigationItem('index');
7167
$this->assertEquals(new NavigationItem(Routes::get('index')), $item);
7268

69+
// Using a Route instance will automatically fill in the label and priority from the route's connected page.
70+
$item = new NavigationItem(Routes::get('index'));
71+
$this->assertData(['destination' => 'index.html', 'label' => 'Home', 'priority' => 0], $item);
72+
7373
// Setting the label and/or priorities will override the page's data.
7474
$item = new NavigationItem(Routes::get('index'), 'Custom Label', 10);
7575
$this->assertData(['destination' => 'index.html', 'label' => 'Custom Label', 'priority' => 10], $item);

0 commit comments

Comments
 (0)