feat: show comments count in post card

This commit is contained in:
DIYgod 2023-08-07 19:57:03 +01:00
parent 4128d8fcb9
commit 6748111ed6
No known key found for this signature in database
5 changed files with 30 additions and 9 deletions

View File

@ -181,16 +181,23 @@ const Card = ({
<span>{post.stat?.viewDetailCount}</span>
</span>
)}
<span className="xlog-post-word-count sm:inline-flex items-center hidden">
<i className="icon-[mingcute--sandglass-line] mr-[2px] text-sm" />
<span
style={{
wordSpacing: "-.2ch",
}}
>
{post.metadata?.content?.readingTime} {t("min")}
{post.stat?.commentsCount ? (
<span className="xlog-post-views inline-flex items-center">
<i className="icon-[mingcute--comment-line] mr-[2px] text-base" />
<span>{post.stat.commentsCount}</span>
</span>
</span>
) : (
<span className="xlog-post-word-count sm:inline-flex items-center hidden">
<i className="icon-[mingcute--sandglass-line] mr-[2px] text-sm" />
<span
style={{
wordSpacing: "-.2ch",
}}
>
{post.metadata?.content?.readingTime} {t("min")}
</span>
</span>
)}
</>
)}
</div>

View File

@ -112,6 +112,8 @@ export const expandCrossbellNote = async ({
)
).json()
expandedNote.stat = stat
} else if ((expandedNote as any)._count?.fromNotes) {
expandedNote.stat.commentsCount = (expandedNote as any)._count.fromNotes
}
}

View File

@ -103,6 +103,7 @@ export type ExpandedNote = NoteEntity & {
viewDetailCount?: number
hotScore?: number
portfolio?: PortfolioStats
commentsCount?: number
}
local?: boolean
}

View File

@ -538,6 +538,9 @@ export async function getFeed({
stat {
viewDetailCount
}
_count {
fromNotes
}
${resultFields}
}
}
@ -567,6 +570,7 @@ export async function getFeed({
const expand = await expandCrossbellNote({
note: page,
useHTML,
useStat: true,
})
return expand
},
@ -655,6 +659,9 @@ export async function getFeed({
stat {
viewDetailCount
}
_count {
fromNotes
}
${resultFields}
}
}
@ -683,6 +690,7 @@ export async function getFeed({
const expand = await expandCrossbellNote({
note: page,
useHTML,
useStat: true,
})
return expand
},

View File

@ -285,6 +285,9 @@ export async function getPagesBySite(input: {
stat {
viewDetailCount
}
_count {
fromNotes
}
`
: ""
}