Q&A: pinned questions are featured on the home page, home cards link to the full answer, newest answer first; v2.22.1
Publish Container / build (push) Successful in 16m39s
Publish Container / build (push) Successful in 16m39s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
960ee41375
commit
4a7c3cc967
6 files changed
+21
-7
No files matched your search
@@ -76,10 +76,12 @@ export function register(app) {
|
||||
const publicQuestions = sourceQuestions
|
||||
.filter(q => q.isApproved === true && q.answer && q.answer.trim().length > 0)
|
||||
.sort((a, b) => {
|
||||
// Pinned questions always float to top
|
||||
// Pinned first (they are also the ones featured on the home page), then newest answer first
|
||||
if (a.pinned && !b.pinned) return -1
|
||||
if (!a.pinned && b.pinned) return 1
|
||||
return 0
|
||||
const at = new Date(a.answeredAt ?? a.submittedAt ?? 0).getTime() || 0
|
||||
const bt = new Date(b.answeredAt ?? b.submittedAt ?? 0).getTime() || 0
|
||||
return bt - at
|
||||
})
|
||||
res.json({ questions: publicQuestions.map(toPublicQuestion) })
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user