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

@@ -144,6 +144,7 @@ export const APIMethod = ({
noResult ? "" : `const ${resultVariable} = ` noResult ? "" : `const ${resultVariable} = `
}await auth.api.${functionName}(${serverBody});${code_suffix}`} }await auth.api.${functionName}(${serverBody});${code_suffix}`}
lang="ts" lang="ts"
allowCopy={!isClientOnly}
/> />
); );
@@ -243,6 +244,7 @@ export const APIMethod = ({
}, error } = ` }, error } = `
}await authClient.${authClientMethodPath}(${clientBody});${code_suffix}`} }await authClient.${authClientMethodPath}(${clientBody});${code_suffix}`}
lang="ts" lang="ts"
allowCopy={!isServerOnly}
/> />
{isServerOnly ? ( {isServerOnly ? (
<div className="flex absolute inset-0 justify-center items-center w-full h-full rounded-lg border backdrop-brightness-50 backdrop-blur-xs border-border"> <div className="flex absolute inset-0 justify-center items-center w-full h-full rounded-lg border backdrop-brightness-50 backdrop-blur-xs border-border">

View File

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