@model MyAwesomeBlog.Web.Site.Models.Posts.ArchiveViewModel
@{
    ViewData["Title"] = "Archive";
}

<div class="container-fluid">
    <h1>All post</h1>
    <div class="row">
        @foreach (var post in Model.Posts)
        {
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-text">@post.Title</h5>
                        <h6 class="card-subtitle mb-2 text-muted">@post.PublishDate.ToShortDateString()</h6>
                        <a asp-action="Detail" asp-controller="Posts" asp-route-id="@post.Id" asp-route-slug="@post.Slug">Read</a>
                    </div>
                </div>
            </div>
        }
    </div>
    <div class="row">
        <div class="col-md-12">
            <span>
                page @Model.CurrentPage of @Model.PageCount
            </span>
            <a class="ml-3" asp-action="Archive" asp-controller="Posts" asp-route-page="@(Model.CurrentPage == 1 ? 1 : Model.CurrentPage - 1)">[< Previous]</a>
            <a class="ml-3" asp-action="Archive" asp-controller="Posts" asp-route-page="@(Model.CurrentPage >= Model.PageCount ? Model.PageCount : Model.CurrentPage + 1)">[Next >]</a>
        </div>
    </div>
</div>
