import { CopyButton } from '@duck-docs/components/copy-button' import { cn } from '@gentleduck/libs/cn' import { ShellCommand } from './shell-command' import type { ICodeBlockProps } from './types' // `@gentleduck/md` (the duck-md compiler, "dmc") emits `
` two ways:
// 1. css-vars (default): a single `` carrying `--dmc-{mode}` vars
// for every theme. No `data-theme`. Theme switching happens in CSS
// via `var(--dmc-{active})`.
// 2. split: one `` per theme. The
// `data-theme` is preserved on the wrapper for theme-aware show/hide.
export function PreBlock({
className,
__dmcRaw__,
npm,
yarn,
pnpm,
bun,
__dmcMeta__,
__dmcEvent__,
children,
...props
}: ICodeBlockProps) {
const theme = props['data-theme']
if (npm && yarn && pnpm && bun) {
return
}
const inner = (
<>
{__dmcRaw__ && (
)}
{children}
>
)
return theme ? {inner} : inner
}