|
| 1 | +@inject DocsPageState PageState |
| 2 | +@implements IDisposable |
1 | 3 | @using ShellDocs.Core |
2 | 4 |
|
3 | | -@if (Prev is not null || Next is not null) |
| 5 | +@{ |
| 6 | + var prev = Prev ?? PageState.Prev; |
| 7 | + var next = Next ?? PageState.Next; |
| 8 | +} |
| 9 | + |
| 10 | +@if (prev is not null || next is not null) |
4 | 11 | { |
5 | 12 | <nav class="prevnext" aria-label="Previous and next"> |
6 | | - @if (Prev is not null) |
| 13 | + @if (prev is not null) |
7 | 14 | { |
8 | | - <a class="prevnext-card prev" href="@Prev.Url"> |
| 15 | + <a class="prevnext-card prev" href="@prev.Url"> |
9 | 16 | <span class="prevnext-hint"> |
10 | 17 | <svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg> |
11 | | - <span>@Prev.Title</span> |
| 18 | + <span>@prev.Title</span> |
12 | 19 | </span> |
13 | | - @if (!string.IsNullOrEmpty(Prev.Description)) |
| 20 | + @if (!string.IsNullOrEmpty(prev.Description)) |
14 | 21 | { |
15 | | - <span class="prevnext-desc">@Prev.Description</span> |
| 22 | + <span class="prevnext-desc">@prev.Description</span> |
16 | 23 | } |
17 | 24 | </a> |
18 | 25 | } |
19 | 26 | else { <span class="prevnext-placeholder" aria-hidden="true"></span> } |
20 | 27 |
|
21 | | - @if (Next is not null) |
| 28 | + @if (next is not null) |
22 | 29 | { |
23 | | - <a class="prevnext-card next" href="@Next.Url"> |
| 30 | + <a class="prevnext-card next" href="@next.Url"> |
24 | 31 | <span class="prevnext-hint"> |
25 | | - <span>@Next.Title</span> |
| 32 | + <span>@next.Title</span> |
26 | 33 | <svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg> |
27 | 34 | </span> |
28 | | - @if (!string.IsNullOrEmpty(Next.Description)) |
| 35 | + @if (!string.IsNullOrEmpty(next.Description)) |
29 | 36 | { |
30 | | - <span class="prevnext-desc">@Next.Description</span> |
| 37 | + <span class="prevnext-desc">@next.Description</span> |
31 | 38 | } |
32 | 39 | </a> |
33 | 40 | } |
|
38 | 45 | @code { |
39 | 46 | [Parameter] public NavigationNode? Prev { get; set; } |
40 | 47 | [Parameter] public NavigationNode? Next { get; set; } |
| 48 | + |
| 49 | + protected override void OnInitialized() => PageState.OnChange += Rerender; |
| 50 | + private void Rerender() => InvokeAsync(StateHasChanged); |
| 51 | + public void Dispose() => PageState.OnChange -= Rerender; |
41 | 52 | } |
0 commit comments