Add comments count to Resource model and update logic for comment creation and deletion

This commit is contained in:
2025-06-26 21:12:53 +08:00
parent 5d0b201fde
commit 778ade8b6c
4 changed files with 20 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ export interface ResourceDetails {
author: User;
views: number;
downloads: number;
comments: number;
related: Resource[];
}

View File

@@ -245,6 +245,13 @@ export default function ResourcePage() {
/>
<MdOutlineComment className="text-xl mr-2" />
<span className="text-sm">{t("Comments")}</span>
{resource.comments ? (
<span
className={`px-1 py-0.5 ml-1 rounded-full text-xs ${page === 2 ? "bg-accent text-accent-content" : "text-base-content/60"}`}
>
{resource.comments}
</span>
) : null}
</label>
<div key={"comments"} className="tab-content p-2">
<Comments resourceId={resource.id} />