diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js index a89260e68b59..930a98e185c7 100644 --- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js +++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js @@ -13,7 +13,7 @@ import Clipboard from 'clipboard'; import rangeParser from 'parse-numeric-range'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import useTheme from '@theme/hooks/useTheme'; -import useEventBus from '@docusaurus/useEventBus'; +import useEventBus from '@theme/hooks/useEventBus'; import styles from './styles.module.css'; const highlightLinesRangeRegex = /{([\d,-]+)}/; @@ -29,11 +29,12 @@ export default ({children, className: languageClassName, metastring}) => { const button = useRef(null); let highlightLines = []; const [theme] = useTheme(); - const [prismTheme, setPrismTheme] = useState(defaultTheme); + const lightThemePrism = prism.theme || defaultTheme; + const [prismTheme, setPrismTheme] = useState(lightThemePrism); const changePrismTheme = newTheme => prism.darkTheme && newTheme === 'dark' ? setPrismTheme(prism.darkTheme) - : setPrismTheme(defaultTheme); + : setPrismTheme(lightThemePrism); if (metastring && highlightLinesRangeRegex.test(metastring)) { const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1]; diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js index 286bbbe48910..d18bbf8adfa3 100644 --- a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js @@ -9,7 +9,6 @@ import React, {useCallback, useState} from 'react'; import Link from '@docusaurus/Link'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import useBaseUrl from '@docusaurus/useBaseUrl'; -import {dispatch} from '@docusaurus/useEventBus'; import SearchBar from '@theme/SearchBar'; import Toggle from '@theme/Toggle'; @@ -18,6 +17,7 @@ import classnames from 'classnames'; import useTheme from '@theme/hooks/useTheme'; import useHideableNavbar from '@theme/hooks/useHideableNavbar'; +import {dispatch} from '@theme/hooks/useEventBus'; import styles from './styles.module.css'; diff --git a/packages/docusaurus/src/client/exports/useEventBus.js b/packages/docusaurus-theme-classic/src/theme/hooks/useEventBus.js similarity index 100% rename from packages/docusaurus/src/client/exports/useEventBus.js rename to packages/docusaurus-theme-classic/src/theme/hooks/useEventBus.js diff --git a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js index 68dafe63dce9..20b36a02dd1c 100644 --- a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js +++ b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js @@ -13,7 +13,7 @@ import Clipboard from 'clipboard'; import rangeParser from 'parse-numeric-range'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import useTheme from '@theme/hooks/useTheme'; -import useEventBus from '@docusaurus/useEventBus'; +import useEventBus from '@theme/hooks/useEventBus'; import Playground from '@theme/Playground'; import styles from './styles.module.css'; @@ -36,11 +36,12 @@ export default ({ const button = useRef(null); let highlightLines = []; const [theme] = useTheme(); - const [prismTheme, setPrismTheme] = useState(defaultTheme); + const lightThemePrism = prism.theme || defaultTheme; + const [prismTheme, setPrismTheme] = useState(lightThemePrism); const changePrismTheme = newTheme => prism.darkTheme && newTheme === 'dark' ? setPrismTheme(prism.darkTheme) - : setPrismTheme(defaultTheme); + : setPrismTheme(lightThemePrism); if (metastring && highlightLinesRangeRegex.test(metastring)) { const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1]; diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 1ac955259680..5f125b20aeea 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -60,6 +60,7 @@ module.exports = { ], themeConfig: { prism: { + theme: require('prism-react-renderer/themes/github'), darkTheme: require('prism-react-renderer/themes/dracula'), }, image: 'img/docusaurus.png',