✨ Configurable post page
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using DysonNetwork.Zone.Customization;
|
||||
using DysonNetwork.Zone.Pages.Dynamic;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -76,6 +78,18 @@ public class PublicationSiteMiddleware(RequestDelegate next)
|
||||
when page.Config.TryGetValue("target", out var tgt) && tgt is JsonElement redirectUrl:
|
||||
context.Response.Redirect(redirectUrl.ToString());
|
||||
return;
|
||||
case PublicationPageType.PostPage:
|
||||
PostPageFilterConfig? filterConfig = null;
|
||||
if (page.Config.TryGetValue("filter", out var filter) && filter is JsonElement filterJson)
|
||||
filterConfig = filterJson.Deserialize<PostPageFilterConfig>(GrpcTypeHelper.SerializerOptions);
|
||||
PostPageLayoutConfig? layoutConfig = null;
|
||||
if (page.Config.TryGetValue("layout", out var layout) && layout is JsonElement layoutJson)
|
||||
layoutConfig = layoutJson.Deserialize<PostPageLayoutConfig>(GrpcTypeHelper.SerializerOptions);
|
||||
context.Items["PostPage_LayoutConfig"] = layoutConfig;
|
||||
context.Items["PostPage_FilterConfig"] = filterConfig;
|
||||
context.Request.Path = "/Posts";
|
||||
await next(context);
|
||||
return;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user