import { Button } from "@rspress/core/theme-original" import { arr, str, type CallToActionLink, type ContactCode } from "./types" /** * Closing call-to-action band: one or more buttons, optionally alongside a * scannable contact code (a WeChat QR, for instance). * * `Button` renders its own `` (routed through the theme's `Link`), so it * must be given `href` directly rather than being wrapped in an anchor. */ export function CallToAction({ actions, code, }: { actions?: CallToActionLink[] code?: ContactCode }) { const links = (arr(actions) ?? []).filter( (action) => str(action?.text) && str(action?.link) ) const codeSrc = str(code?.src) const codeCaption = str(code?.caption) if (links.length === 0 && !codeSrc) return null return (
{links.length > 0 && (
{links.map((action, index) => ( ))}
)} {codeSrc && (
{/* The white frame is not decoration. A QR code needs a quiet zone of blank space around it to scan reliably, and the exported image has almost none — the pattern runs close to its edges. */}
{codeCaption
{codeCaption && (
{codeCaption}
)}
)}
) }