Add blog navigation

This commit is contained in:
Robert Marshall 2020-01-03 16:44:40 +00:00
parent 3d00f28657
commit 9fd9beb860
5 changed files with 42 additions and 12 deletions

View 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);
}
}
}