using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace zotanpw.Pages;

public class BlogPostModel : PageModel {
	public BlogModel.BlogPost? Post;

	public IActionResult OnGet() {
		if (string.IsNullOrWhiteSpace((string)RouteData.Values["post"]!))
			return NotFound();

		Post = BlogModel.Posts.FirstOrDefault(p => p.Shorthand == (string)RouteData.Values["post"]!);
		if (Post == null)
			return NotFound();

		return Page();
	}
}
