BlogService now fetches from Media.JoshHeaps.Net API via HttpClient with in-memory caching (5-min TTL) and stale cache fallback. Removed Markdig/YamlDotNet dependencies. All page models now async. Co-Authored-By: Claude Opus 4.6 <[email protected]>
27 lines
650 B
C#
27 lines
650 B
C#
using JoshHeaps.Net.Models;
|
|
using JoshHeaps.Net.Services.Interfaces;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace JoshHeaps.Net.Pages;
|
|
|
|
public class BlogModel : PageModel
|
|
{
|
|
private readonly IBlogService _blogService;
|
|
|
|
public List<BlogPost> Posts { get; set; } = [];
|
|
public string? ActiveTag { get; set; }
|
|
|
|
public BlogModel(IBlogService blogService)
|
|
{
|
|
_blogService = blogService;
|
|
}
|
|
|
|
public async Task OnGetAsync(string? tag)
|
|
{
|
|
ActiveTag = tag;
|
|
Posts = tag is not null
|
|
? await _blogService.GetPostsByTagAsync(tag)
|
|
: await _blogService.GetAllPostsAsync();
|
|
}
|
|
}
|