SPB Git

Repository Public

DeckSection.tsx 2.2 KB 25 lines tsx

1import { getDeck } from "@/lib/content";2import type { SessionView } from "@/modules/content-schema";3import { SlideDeck, type DeckSlide } from "./SlideDeck";45/**6 * The slide viewer of a session, when its deck is visible in the view the caller was given (public view:7 * published slides only). `base` prefixes addresses inside the studio's private preview.8 */9export async function DeckSection({ session, base = "", heading = "h2", id = "diapositives", lessonSlides }: { session: SessionView; base?: string; heading?: "h2" | "h3"; id?: string; /** Slides that have a step in the interactive lesson of the page: the viewer links back to it. */ lessonSlides?: string[] }) {10  const deck = await getDeck(session);11  if (!deck) return null;12  const url = (path: string) => `${base}/diapositives/${deck.dir}/${path}`;13  const slides: DeckSlide[] = deck.slides.map((s) => ({ n: s.n, id: s.id, kind: s.kind, title: s.title, section: s.section, text: s.text, figures: s.figures, dark: url(s.files.dark.path), light: url(s.files.light.path), thumbDark: url(s.files.thumbDark.path), thumbLight: url(s.files.thumbLight.path) }));14  // The PDF is offered only through the resource gate: a « slides » resource that is published, enabled and licensed.15  const pdf = session.resources.find((r) => r.kind === "slides" && r.downloadable);16  const Heading = heading;17  return (18    <section id={id} aria-labelledby={`${id}-titre`} data-testid="slides-section">19      <Heading id={`${id}-titre`} className={heading === "h2" ? "h-section" : "text-lg"}>{lessonSlides ? "Mode diapositives" : "Diapositives"}</Heading>20      <p className="mt-3 mb-5 text-muted">Les {deck.count} diapositives de la séance, à parcourir ici. Chaque diapositive a sa version texte, et un lien direct.{pdf ? "" : " Le fichier PDF n’est pas offert en téléchargement tant que la licence du cours n’est pas arrêtée."}</p>21      <SlideDeck sessionId={session.id} sessionTitle={session.title} slides={slides} path={`${base}/seances/${session.slug}`} ratio={deck.width / deck.height} lessonSlides={lessonSlides} pdfHref={pdf ? `${base}/telecharger/${session.id}/${pdf.id}` : null} heading={heading === "h2" ? "h3" : "h3"} />22    </section>23  );24}25
Files main
Menu

Theme