import type { ReactNode } from "react"; import { Info, AlertTriangle, Lightbulb, ArrowUpRight } from "lucide-react"; import { CodeBlock } from "@/components/mdx/code-block"; import { slugify } from "@/lib/utils"; function textOf(node: ReactNode): string { if (typeof node === "string" || typeof node === "number") return String(node); if (Array.isArray(node)) return node.map(textOf).join(""); if (node && typeof node === "object" && "props" in node) { return textOf((node as { props: { children?: ReactNode } }).props.children); } return ""; } // Heading ids match the outline built in lib/tutorials.ts function H2({ children }: { children?: ReactNode }) { return

{children}

; } function H3({ children }: { children?: ReactNode }) { return

{children}

; } // A tutorial video hosted on our own site and stored in Cloudflare R2. // `id` is the slug at airesourcepro.com/media/video// (served from R2 by cloudflare-worker.mjs). preload="none" keeps the // page light until someone presses play. export function OwnedVideo({ id, title = "Video", captions = false }: { id: string; title?: string; captions?: boolean }) { const base = `/media/video/${id}`; return (
); } // Blues and whites only, like the rest of the site const CALLOUTS = { note: { icon: Info, label: "Note", color: "var(--brand)" }, tip: { icon: Lightbulb, label: "Tip", color: "var(--sky)" }, warning: { icon: AlertTriangle, label: "Heads up", color: "var(--cobalt)" }, }; function Callout({ type = "note", children }: { type?: keyof typeof CALLOUTS; children: ReactNode }) { const { icon: Icon, label, color } = CALLOUTS[type]; return (

{label}

{children}
); } // Numbered steps on a timeline: wrap a run of blocks in function Steps({ children }: { children: ReactNode }) { return
    {children}
; } function Step({ title, children }: { title: string; children: ReactNode }) { return (
  • {title}

    {children}
  • ); } // Curated links to official material, as a grid of cards: wrap a run of blocks in . // `source` credits who wrote it; `kind` says what it is (Docs, Course, Video...); // `date` is only for one-off items like talks, so readers can see how recent they are. function Resources({ children }: { children: ReactNode }) { return
      {children}
    ; } function Resource({ title, href, source, kind, date, children, }: { title: string; href: string; source: string; kind: string; date?: string; children: ReactNode; }) { const host = new URL(href).hostname.replace(/^www\./, ""); return (
  • {kind} {source} {date && ( <> ยท {date} )} {title}
    {children}
    {host}
  • ); } export const mdxComponents = { h2: H2, h3: H3, pre: CodeBlock, OwnedVideo, Callout, Steps, Step, Resources, Resource, };