Add cross-site improvements across three phases

Phase 1 — Quick wins:
- Image lazy-loading on series/resource cards
- Newsletter signup added to Episodes page (before highlights)
- Per-route meta tags via usePageMeta hook (title, og:title, og:description)
- Breadcrumbs on study index, section, and notes pages
- SVG completion checkmark badges on study section list
- Analytics time-range filter (7d / 30d / 90d) in admin panel

Phase 2 — Medium features:
- Related episodes on archived series detail pages
- Resource library two-tier filter (type + tag chips)
- Global search (Fuse.js) moved below sticky header as full-width bar
- Q&A anonymous upvoting with localStorage dedup + admin pin/unpin
- Study enrollment funnel tracking (firstVisitAt, firstCompletionAt) with funnel chart in analytics

Phase 3 — Larger features:
- Study section comments (auto-approve for enrolled users, admin moderation panel)
- Study completion certificate (canvas render, PNG download, shareable public URL)
- Episode script full-text search (mammoth docx extraction, server-side search, admin upload UI)
- Reflection questions renamed from Discussion Questions; quiz answers can be shared to section discussion
- Public certificate route at /certificate/:token with og meta tags
- Comment moderation panel added to admin under Manage > Study Comments

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmert
2026-06-09 09:10:29 -04:00
parent 9ad24df626
commit c4645e3475
24 changed files with 2991 additions and 76 deletions
+45 -1
View File
@@ -12,7 +12,14 @@ function ensureDraftQuestions() {
export function register(app) {
app.get('/api/questions', (_req, res) => {
const sourceQuestions = state.draftQuestions ?? state.questions
const publicQuestions = sourceQuestions.filter(q => q.isApproved === true && q.answer && q.answer.trim().length > 0)
const publicQuestions = sourceQuestions
.filter(q => q.isApproved === true && q.answer && q.answer.trim().length > 0)
.sort((a, b) => {
// Pinned questions always float to top
if (a.pinned && !b.pinned) return -1
if (!a.pinned && b.pinned) return 1
return 0
})
res.json({ questions: publicQuestions })
})
@@ -113,4 +120,41 @@ export function register(app) {
res.json({ ok: true })
})
// Anonymous upvote — no auth required, lightweight increment
app.post('/api/questions/:id/upvote', (req, res) => {
const { id } = req.params
// Look in live questions first, then draft
const liveQ = state.questions.find(q => q.id === id && q.isApproved === true)
const draftQ = state.draftQuestions ? state.draftQuestions.find(q => q.id === id) : null
const question = liveQ ?? draftQ
if (!question) {
res.status(404).json({ message: 'Question not found.' }); return
}
question.upvotes = ((question.upvotes ?? 0) + 1)
if (liveQ) queueQuestionsWrite()
if (draftQ) queueDraftQuestionsWrite()
res.json({ ok: true, upvotes: question.upvotes })
})
// Admin: pin / unpin a question
app.post('/api/admin-questions/:id/pin', requireAdminAuth, (req, res) => {
const { id } = req.params
ensureDraftQuestions()
const question = state.draftQuestions.find(q => q.id === id)
if (!question) { res.status(404).json({ message: 'Question not found.' }); return }
question.pinned = true
queueDraftQuestionsWrite()
res.json({ ok: true, question })
})
app.delete('/api/admin-questions/:id/pin', requireAdminAuth, (req, res) => {
const { id } = req.params
ensureDraftQuestions()
const question = state.draftQuestions.find(q => q.id === id)
if (!question) { res.status(404).json({ message: 'Question not found.' }); return }
question.pinned = false
queueDraftQuestionsWrite()
res.json({ ok: true, question })
})
}