quiz seo image and authguard

This commit is contained in:
gosangam
2026-10-15 21:09:37 +05:30
parent 6a6143ceb2
commit 0e2e0d7300
8 changed files with 602 additions and 447 deletions
+6 -2
View File
@@ -5,6 +5,7 @@
*
* Asks the BFF whether this page has a published quiz and renders nothing if
* not, so it can sit on every content page without leaving an empty slot.
* Quizzes are for signed-in readers only, so signed out it never asks.
* Its label tracks progress: Take quiz → Continue quiz → View results.
*/
@@ -24,10 +25,12 @@ export function QuizButton({
className?: string;
}) {
const { user } = useAuth();
const userId = user?.id;
const [card, setCard] = useState<QuizCard | null>(null);
// Re-asked when the user changes, so progress appears right after sign-in.
useEffect(() => {
if (!userId) return;
let cancelled = false;
quiz
.forPath(path)
@@ -40,9 +43,10 @@ export function QuizButton({
return () => {
cancelled = true;
};
}, [path, user?.id]);
}, [path, userId]);
if (!card) return null;
// A card left over from before sign-out is ignored rather than cleared.
if (!card || !user) return null;
const done = card.my.state === "completed";
return (