quiz seo image and authguard
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user