mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-09 06:12:28 +02:00
feat(v2): allow custom syntax highlighting theme (#1674)
This commit is contained in:
parent
0daed4abec
commit
2d6aaea069
5 changed files with 37 additions and 189 deletions
|
@ -10,9 +10,15 @@ import classnames from 'classnames';
|
|||
import Highlight, {defaultProps} from 'prism-react-renderer';
|
||||
import nightOwlTheme from 'prism-react-renderer/themes/nightOwl';
|
||||
import Clipboard from 'clipboard';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
export default ({children, className: languageClassName}) => {
|
||||
const {
|
||||
siteConfig: {
|
||||
themeConfig: {prismTheme},
|
||||
},
|
||||
} = useDocusaurusContext();
|
||||
const [showCopied, setShowCopied] = useState(false);
|
||||
const target = useRef(null);
|
||||
const button = useRef(null);
|
||||
|
@ -46,7 +52,7 @@ export default ({children, className: languageClassName}) => {
|
|||
return (
|
||||
<Highlight
|
||||
{...defaultProps}
|
||||
theme={nightOwlTheme}
|
||||
theme={prismTheme || nightOwlTheme}
|
||||
code={children.trim()}
|
||||
language={language}>
|
||||
{({className, style, tokens, getLineProps, getTokenProps}) => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue