mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 12:22:45 +02:00
refactor(v2): add useThemeConfig hook + cleanup useless theme default values (#3394)
* refactor(theme-classic): clean default or fallback values * refactor(theme-classic): fix announcementbar undefined error * refactor(theme-classic): fixed react hook warning error * refactor(theme-classic): revert prism destruct * create useThemeConfig and use it whenever possible * validateThemeConfig => add [] as default value for almost all arrays * fix tests Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
f5f2064656
commit
0951eef2d7
16 changed files with 154 additions and 142 deletions
|
@ -12,11 +12,11 @@ import clsx from 'clsx';
|
|||
import Highlight, {defaultProps} from 'prism-react-renderer';
|
||||
import copy from 'copy-text-to-clipboard';
|
||||
import rangeParser from 'parse-numeric-range';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import usePrismTheme from '@theme/hooks/usePrismTheme';
|
||||
import type {Props} from '@theme/CodeBlock';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
import useThemeConfig from '../../utils/useThemeConfig';
|
||||
|
||||
const highlightLinesRangeRegex = /{([\d,-]+)}/;
|
||||
const getHighlightDirectiveRegex = (
|
||||
|
@ -93,11 +93,7 @@ export default ({
|
|||
className: languageClassName,
|
||||
metastring,
|
||||
}: Props): JSX.Element => {
|
||||
const {
|
||||
siteConfig: {
|
||||
themeConfig: {prism = {}},
|
||||
},
|
||||
} = useDocusaurusContext();
|
||||
const {prism} = useThemeConfig();
|
||||
|
||||
const [showCopied, setShowCopied] = useState(false);
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue