Add blog post preview

This commit is contained in:
Robert Marshall 2019-04-28 11:20:06 +01:00
parent a47f18533b
commit fa143f5ab4
4 changed files with 20 additions and 5 deletions

View file

@ -22,7 +22,7 @@ namespace Website.Controllers
public async Task<IActionResult> Page(int page)
{
var offset = (page - 1) * MaxPostsPerPage;
var posts = (await _repo.GetLatestPostsAsync(MaxPostsPerPage, offset)).Select(p => new BlogPostViewModel(p));
var posts = (await _repo.GetLatestPostsAsync(MaxPostsPerPage, offset)).Select(p => new BlogPostPreviewViewModel(p));
var maxPages = (await _repo.GetCountAsync()) / MaxPostsPerPage;
var model = new BlogViewModel(posts, page, maxPages);
return View(model);