Add blog navigation
This commit is contained in:
parent
3d00f28657
commit
9fd9beb860
5 changed files with 42 additions and 12 deletions
18
Website/ViewComponents/BlogNavigationViewComponent.cs
Normal file
18
Website/ViewComponents/BlogNavigationViewComponent.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Website.Data;
|
||||
|
||||
namespace Website.ViewComponents {
|
||||
public class BlogNavigationViewComponent:ViewComponent {
|
||||
private readonly BlogRepository _repo;
|
||||
|
||||
public BlogNavigationViewComponent(BlogRepository repo) {
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
public async Task<IViewComponentResult> InvokeAsync() {
|
||||
var posts = await _repo.GetLatestPostsAsync(5);
|
||||
return View(posts);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue