💄 Updated the hosted site post page

This commit is contained in:
2025-11-22 13:09:57 +08:00
parent 92a4899e7c
commit 0b0598712e
6 changed files with 291 additions and 61 deletions

View File

@@ -0,0 +1,37 @@
using DysonNetwork.Shared.Models;
using DysonNetwork.Shared.Proto;
using DysonNetwork.Zone.Publication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace DysonNetwork.Zone.Pages.Posts;
public class DetailsModel(PostService.PostServiceClient postClient) : PageModel
{
[FromRoute] public string Slug { get; set; } = null!;
public SnPublicationSite? Site { get; set; }
public SnPost? Post { get; set; }
public async Task<IActionResult> OnGetAsync()
{
Site = HttpContext.Items[PublicationSiteMiddleware.SiteContextKey] as SnPublicationSite;
if (string.IsNullOrEmpty(Slug))
return NotFound();
var request = new GetPostRequest { PublisherId = Site!.PublisherId.ToString() };
if (Guid.TryParse(Slug, out var guid)) request.Id = guid.ToString();
else request.Slug = Slug;
var response = await postClient.GetPostAsync(request);
if (response == null)
{
return NotFound();
}
Post = SnPost.FromProtoValue(response);
return Page();
}
}