File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
LinkDotNet.Blog.Web/Pages Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 1
1
@page " /"
2
+ @page " /{page:int}"
2
3
@using Markdig
3
4
@using X .PagedList
4
5
@using LinkDotNet .Blog .Web .Shared .Services
27
28
<ShortBlogPost BlogPost =" context" UseAlternativeStyle =" @(currentLine++ % 2 != 0)" ></ShortBlogPost >
28
29
</Virtualize >
29
30
</div >
30
- <BlogPostNavigation CurrentPage =" @currentPage" OnPageChanged =" @GetPage " ></BlogPostNavigation >
31
+ <BlogPostNavigation CurrentPage =" @currentPage" OnPageChanged =" @SetPageNumber " ></BlogPostNavigation >
31
32
</section >
32
33
33
34
@code {
35
+ [Parameter ]
36
+ public int ? Page { get ; set ; }
37
+
34
38
private IPagedList <BlogPost > currentPage = new PagedList <BlogPost >(null , 1 , 1 );
35
39
private int currentLine ;
36
40
37
41
private string ImageUrl => appConfiguration .Introduction .BackgroundUrl .ToAbsoluteUrl (navigationManager .BaseUri );
38
42
39
- protected override async Task OnInitializedAsync ()
43
+ protected override async Task OnParametersSetAsync ()
40
44
{
41
- currentPage = await blogPostRepository .GetAllAsync (
45
+ currentPage = await blogPostRepository .GetAllAsync (
42
46
p => p .IsPublished ,
43
47
b => b .UpdatedDate ,
44
- pageSize : appConfiguration .BlogPostsPerPage );
48
+ pageSize : appConfiguration .BlogPostsPerPage ,
49
+ page : Page ?? 1 );
45
50
}
46
51
47
52
protected override async Task OnAfterRenderAsync (bool firstRender )
52
57
}
53
58
}
54
59
55
- private async Task GetPage (int newPage )
60
+ private void SetPageNumber (int newPage )
56
61
{
57
- currentPage = await blogPostRepository .GetAllAsync (
58
- p => p .IsPublished ,
59
- b => b .UpdatedDate ,
60
- pageSize : appConfiguration .BlogPostsPerPage ,
61
- page : newPage );
62
+ navigationManager .NavigateTo ($" /{newPage }" );
62
63
}
63
64
}
You can’t perform that action at this time.
0 commit comments