Newsbot.Portal/Newsbot.Portal.Blazor.Server/Pages/Articles/Newest.razor

34 lines
1010 B
Plaintext

@page "/articles/newest"
@using Newsbot.Collector.Client
@using Newsbot.Collector.Client.Domain.Dto
<h3>List Articles</h3>
<div class="container">
<div class="row">
@foreach (var item in Data ??= new List<ArticlesDto>())
{
<div class="col-sm">
<div class="card" style="width: 18rem;">
<img src="@item.Thumbnail" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">@item.Title</h5>
<p class="card-text">@item.Description</p>
<a href="@item.Url" class="btn btn-primary" target="_blank">View</a>
</div>
</div>
</div>
}
</div>
</div>
@code {
List<ArticlesDto>? Data { get; set; }
protected override async Task OnInitializedAsync()
{
var c = new ArticlesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
var items = await c.ListArticlesAsync();
Data = items;
}
}