Restore tree-structured comments in Blog Details

The $.psc.blogcomment widget (from the removed wwwroot/js/comment.js)
provided reply-to-comment nesting. Rewrite Details.cshtml to drive the
same /api/v1/blogcomments endpoint with ParentId, delegating reply
clicks so they work across the whole nested tree.

Render comment metadata server-side in the Comment view component
template (the widget used to add it client-side) and Include Author so
nested comments get their author instead of relying on the request-scoped
identity map.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Paul Schneider 2026-09-21 11:21:33 +01:00
commit 1455ba5187
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
3 changed files with 233 additions and 87 deletions

View file

@ -1,16 +1,30 @@
@model Comment
<div data-type="blogcomment" data-id="@Model.Id" data-receiver-id="@Model.ReceiverId" data-allow-edit="@(User.GetUserId()==Model.AuthorId?"true":"false")"
data-allow-moderate="@ViewBag.moderatoFlag" data-date="@Model.DateCreated.ToString("yyyy-MM-dd hh:mm:ss")" data-username="@Model.Author.UserName" >
<div class="blogcomment" data-type="blogcomment"
data-id="@Model.Id"
data-receiver-id="@Model.ReceiverId"
data-allow-edit="@(User.GetUserId()==Model.AuthorId?"true":"false")"
data-allow-moderate="@ViewBag.moderatoFlag"
data-date="@Model.DateCreated.ToString("yyyy-MM-dd hh:mm:ss")"
data-username="@(Model.Author?.UserName)">
<div class="comment-body">
<markdown>@Model.Article</markdown>
@if (Model.Children!=null) {
<div class="subcomments">
@foreach (var comment in Model.Children)
{
@await this.Component.InvokeAsync("Comment", new { id = comment.Id});
}
</div>
}
</div>
<span class="commentmeta">
— @(Model.Author?.UserName ?? "Anonyme"),
posté le @Model.DateCreated.ToString("dddd d MMM yyyy à H:mm")
</span>
@if (User.GetUserId() != null)
{
<button type="button" class="btn btn-link btn-sm reply-btn">Répondre</button>
}
<div class="subcomments">
@if (Model.Children != null)
{
foreach (var comment in Model.Children)
{
@await this.Component.InvokeAsync("Comment", new { id = comment.Id })
}
}
</div>
</div>