@page "/"
@inject LinksClient Links

<h1>Latest links</h1>

@if (_links == null) {
  <p>Fetching links...</p>
} else if(_links.Length == 0) {
  <p>No links yet.</p>
} else {
  <ul>
    @foreach (var link in _links)
    {
        <li><LinkItem Item="@link" /></li>
    }
  </ul>
}

@code {
  private LinkDTO[] _links;

  protected override async Task OnInitializedAsync()
  {
    _links = (await Links.GetLatestAsync()).ToArray();
  }
}
