feat: quiz

This commit is contained in:
gosangam
2026-10-15 20:07:01 +05:30
parent 9f67da37a6
commit 6a6143ceb2
12 changed files with 982 additions and 16 deletions
+12
View File
@@ -28,6 +28,7 @@ import { useRouter, usePathname } from "next/navigation";
import { Check, Link2 } from "lucide-react";
import { cn } from "@/lib/utils";
import { SaveOfflineButton } from "@/components/layout/save-offline-button";
import { QuizButton } from "@/components/quiz/quiz-button";
import type { OfflineDescriptor } from "@/lib/offline";
const SEARCH_RETURN_KEY = "spsays_from_search";
@@ -71,6 +72,7 @@ export function PageHeader({
bare = false,
sticky = false,
offline,
quiz = true,
}: {
children: React.ReactNode;
/** Drop the bordered chrome — useful for pages that want flush title text. */
@@ -89,6 +91,13 @@ export function PageHeader({
* visible gap.
*/
sticky?: boolean;
/**
* Show this page's quiz button (if it has a published quiz) under the
* title. On by default for content pages; a page that places the button
* itself — the transcript, beside its audio player — turns this off so it
* never appears twice.
*/
quiz?: boolean;
className?: string;
}) {
const router = useRouter();
@@ -216,6 +225,9 @@ export function PageHeader({
{/* Page-level controls, anchored at the header's bottom. */}
<div className="mt-3 flex flex-wrap items-center gap-2">
{/* First, so it reads as belonging to the title above it. Renders
nothing on pages without a published quiz. */}
{quiz && isContentPath(pathname) ? <QuizButton path={pathname} /> : null}
<button
type="button"
onClick={copyPageLink}