/** * InstallSnippet — legacy JSX wrapper that renders an install command using * the same DOM contract as the Pagesmith markdown code renderer's frame chrome. * * The default `DocHome` layout no longer uses this component — it now * pre-renders the home `install` block through `processMarkdown` (see * `@pagesmith/docs/src/install.ts`) so the home snippet shares Shiki * highlighting, multi-line line numbers, frame chrome, and copy behavior with * `\`\`\`` blocks elsewhere on the site. * * This component is retained for downstream consumers that import it directly * and was extended to accept multi-line scripts and a configurable frame so * its visual contract can match the new pipeline output. */ import { h } from "@pagesmith/docs/jsx-runtime"; type Props = { command: string; title?: string; /** Defaults to `bash` so the legacy single-line install case stays a shell command. */ lang?: string; /** Defaults to `terminal` to preserve the legacy chrome — switch to `code` for non-shell snippets. */ frame?: "terminal" | "code" | "plain"; /** Defaults to `true` for multi-line scripts and `false` for single-line input. */ showLineNumbers?: boolean; }; const TERMINAL_ICON = ( ); const COPY_ICON = ( ); const COPIED_ICON = ( ); function splitLines(command: string): string[] { const normalized = command.replace(/\r\n/g, "\n").replace(/\s+$/, ""); return normalized.length > 0 ? normalized.split("\n") : [""]; } export function InstallSnippet({ command, title = "Terminal", lang = "bash", frame = "terminal", showLineNumbers, }: Props) { const lines = splitLines(command); const includeLineNumbers = showLineNumbers ?? lines.length > 1; const isTerminal = frame === "terminal"; return (
{isTerminal ? (
          
            {lines.map((line, index) => (
              
                {includeLineNumbers ? (
                  
                ) : null}
                {line}
              
            ))}
          
        
); }