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
+44 -2
View File
@@ -8,6 +8,8 @@ interface PublicQuestion {
topic?: string
submittedAt?: string
answeredAt?: string
upvotes?: number
pinned?: boolean
}
interface DecoratedQuestion extends PublicQuestion {
@@ -390,6 +392,12 @@ export default function QASection() {
const [copiedQuestionId, setCopiedQuestionId] = useState<string | null>(null)
const [copiedFacebookCaptionId, setCopiedFacebookCaptionId] = useState<string | null>(null)
const [loading, setLoading] = useState(true)
const [votedIds, setVotedIds] = useState<Set<string>>(() => {
try {
const raw = localStorage.getItem('qa-voted-ids-v1')
return new Set(raw ? JSON.parse(raw) as string[] : [])
} catch { return new Set() }
})
const resultsTopRef = useRef<HTMLDivElement | null>(null)
useEffect(() => {
@@ -404,6 +412,22 @@ export default function QASection() {
})
}, [])
async function handleUpvote(id: string) {
if (votedIds.has(id)) return
try {
const res = await fetch(`/api/questions/${encodeURIComponent(id)}/upvote`, { method: 'POST' })
if (!res.ok) return
const data = await res.json() as { upvotes: number }
setQuestions(prev => prev.map(q => q.id === id ? { ...q, upvotes: data.upvotes } : q))
setVotedIds(prev => {
const next = new Set(prev)
next.add(id)
localStorage.setItem('qa-voted-ids-v1', JSON.stringify([...next]))
return next
})
} catch { /* ignore */ }
}
useEffect(() => {
setEngagement(readEngagementFromStorage())
}, [])
@@ -839,22 +863,40 @@ export default function QASection() {
: question.answer
return (
<article key={question.id} id={`qa-${question.id}`} className={`qa-card-scene${isFocused ? ' qa-card-scene--focused' : ''}`}>
<article key={question.id} id={`qa-${question.id}`} className={`qa-card-scene${isFocused ? ' qa-card-scene--focused' : ''}${question.pinned ? ' qa-card-scene--pinned' : ''}`}>
<div className="qa-question-header">
<span className="qa-face-label">Q</span>
<span className="qa-question-main">
<span className="qa-question-text">{renderHighlightedText(question.question, normalizedSearch)}</span>
<span className="qa-question-text">
{question.pinned && (
<span className="qa-pinned-badge" aria-label="Pinned question">📌 </span>
)}
{renderHighlightedText(question.question, normalizedSearch)}
</span>
<span className="qa-question-meta">
<span className="qa-topic-pill">{question._topic}</span>
{formatDate(question.answeredAt ?? question.submittedAt) && (
<span>{formatDate(question.answeredAt ?? question.submittedAt)}</span>
)}
{question._helpful > 0 && <span>{question._helpful} helpful</span>}
{(question.upvotes ?? 0) > 0 && (
<span>👍 {question.upvotes}</span>
)}
</span>
</span>
</div>
<div className="qa-card-actions">
<button
type="button"
aria-label={votedIds.has(question.id) ? 'Already upvoted' : 'Upvote this question'}
className={`qa-upvote-btn${votedIds.has(question.id) ? ' qa-upvote-btn--voted' : ''}`}
onClick={() => handleUpvote(question.id)}
disabled={votedIds.has(question.id)}
>
<svg viewBox="0 0 16 16" aria-hidden="true" fill="currentColor" width="13" height="13"><path d="M8 2L2 9h4v5h4V9h4z"/></svg>
<span>{votedIds.has(question.id) ? 'Upvoted' : 'Upvote'}{(question.upvotes ?? 0) > 0 ? ` · ${question.upvotes}` : ''}</span>
</button>
<button
type="button"
aria-label="Share on X"