Skip to content

Commit b2d5164

Browse files
authored
Added PageTitle reference
1 parent ffc9189 commit b2d5164

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/03-show-order-status.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ Now when you run the app, you'll be able to visit this page:
5656

5757
Also notice that this time, no full-page load occurs when you navigate, because the URL is matched entirely within the client-side SPA. As such, navigation is instantaneous.
5858

59+
## Adding a page title
60+
61+
In your browser, the title of the new page is listed as **Blazing Pizza** and it would be nice to update the title to reflect that this is the 'My Orders' page. We can use the new `PageTitle` component to update the title from the `MyOrders.razor` page:
62+
63+
```html
64+
@page "/myorders"
65+
66+
<PageTitle>Blazing Pizza - My Orders</PageTitle>
67+
68+
<div class="main">
69+
My orders will go here
70+
</div>
71+
```
72+
73+
This works because inside the `Program.cs` file is an entry that adds a `HeadOutlet` component to the HTML presenting the BlazingPizza application. Blazor uses this `HeadOutlet` to write content into the header of the HTML page.
74+
75+
```csharp
76+
builder.RootComponents.Add<HeadOutlet>("head::after");
77+
```
78+
5979
## Highlighting navigation position
6080

6181
Look closely at the top bar. Notice that when you're on "My orders", the link *isn't* highlighted in yellow. How can we highlight links when the user is on them? By using a `NavLink` component instead of a plain `<a>` tag. The only special thing a `NavLink` component does is toggle its own `active` CSS class depending on whether its `href` matches the current navigation state.

0 commit comments

Comments
 (0)