madskristensen/Miniblog.Core

How to set default page in aspnetcore app with miniblogcore added

ayinn opened this issue · 2 comments

ayinn commented

Is there a way to keep the home/index as the default opening page, when using miniblogcore in the website? Thank you for this blog app. I need help in using it in aspnetcore. How would I include a categories view in the home/index page, but not a post? Is there a forum to ask questions?

you cloud be trying this code in layout.cshtml.

@{
    List<string> allCats = ViewData["AllCats"] as List<string> ?? new List<string>();
    allCats.Sort();
}
@foreach (var item in allCats)
{
    <a asp-controller="Blog" asp-action="category"
       asp-route-category="@item" asp-route-page="">@item</a>
}

and query Categories in Index Action

public async Task<IActionResult> Index()
{
	//...
    ViewData["AllCats"] = (await _blog.GetCategories()).ToList();
    //...
}
ayinn commented

Thank you for your help. I could not make that work. It may be me.

How does one display the feed?