docs: remove copy button from disabled code blocks (#4516)

This commit is contained in:
KinfeMichael Tariku
2025-09-08 19:15:49 +03:00
committed by GitHub
parent a7eaa049e4
commit 6e60de4205
2 changed files with 12 additions and 1 deletions

View File

@@ -34,6 +34,12 @@ export interface DynamicCodeblockProps {
* @defaultValue true
*/
wrapInSuspense?: boolean;
/**
* Allow to copy code with copy button
*
* @defaultValue true
*/
allowCopy?: boolean;
options?: Omit<HighlightOptionsCommon, "lang"> & HighlightOptionsThemes;
}
@@ -63,6 +69,7 @@ export function DynamicCodeBlock({
codeblock,
options,
wrapInSuspense = true,
allowCopy = true,
}: DynamicCodeblockProps) {
const shikiOptions = {
lang,
@@ -85,7 +92,9 @@ export function DynamicCodeBlock({
</Suspense>
);
return <PropsContext value={codeblock}>{children}</PropsContext>;
return (
<PropsContext value={{ ...codeblock, allowCopy }}>{children}</PropsContext>
);
}
function Placeholder({