mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-11 15:22:29 +02:00
refactor(v2): move livecodeblock as plugin (#1566)
* refactor(v2): move livecodeblock as plugin * tweak from rebase * nits * nits * dep
This commit is contained in:
parent
a0777f7c57
commit
5362c2cda2
17 changed files with 208 additions and 72 deletions
|
@ -7,29 +7,11 @@
|
|||
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import LoadableVisibility from 'react-loadable-visibility/react-loadable';
|
||||
import Highlight, {defaultProps} from 'prism-react-renderer';
|
||||
import nightOwlTheme from 'prism-react-renderer/themes/nightOwl';
|
||||
import Loading from '@theme/Loading';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
/* Live playground is not small in size, lazy load it is better */
|
||||
const Playground = LoadableVisibility({
|
||||
loader: () => import('@theme/Playground'),
|
||||
loading: Loading,
|
||||
});
|
||||
|
||||
export default ({children, className: languageClassName, live, ...props}) => {
|
||||
if (live) {
|
||||
return (
|
||||
<Playground
|
||||
scope={{...React}}
|
||||
code={children.trim()}
|
||||
theme={nightOwlTheme}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export default ({children, className: languageClassName}) => {
|
||||
const language =
|
||||
languageClassName && languageClassName.replace(/language-/, '');
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue