Skip to content

Commit e9ce4e3

Browse files
committed
refactor(theme-common, theme-live-codeblock): Use metaOptions for noInline
1 parent 3d483ec commit e9ce4e3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ export function parseCodeBlockMetaOptions(
433433

434434
// interactive code editor (theme-live-codeblock => Playground)
435435
parsedOptions.live = metastring?.split(' ').includes('live');
436-
// parsedOptions.noInline = TODO;
436+
parsedOptions.noInline = metastring?.includes('noInline');
437437

438438
return parsedOptions;
439439
}

packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ErrorBoundaryErrorMessageFallback,
1717
usePrismTheme,
1818
} from '@docusaurus/theme-common';
19+
import {parseCodeBlockMetaOptions} from '@docusaurus/theme-common/internal';
1920
import ErrorBoundary from '@docusaurus/ErrorBoundary';
2021

2122
import type {Props} from '@theme/Playground';
@@ -105,6 +106,8 @@ const DEFAULT_TRANSFORM_CODE = (code: string) => `${code};`;
105106
export default function Playground({
106107
children,
107108
transformCode,
109+
metastring,
110+
metaOptions: metaOptionsProp,
108111
...props
109112
}: Props): ReactNode {
110113
const {
@@ -115,7 +118,8 @@ export default function Playground({
115118
} = themeConfig as ThemeConfig;
116119
const prismTheme = usePrismTheme();
117120

118-
const noInline = props.metastring?.includes('noInline') ?? false;
121+
const metaOptions = parseCodeBlockMetaOptions(metastring, metaOptionsProp);
122+
const noInline = !!metaOptions.noInline;
119123

120124
return (
121125
<div className={styles.playgroundContainer}>

0 commit comments

Comments
 (0)