mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-14 00:32:47 +02:00
refactor(v2): add @theme-init alias to give access to initial components (#2464)
This commit is contained in:
parent
d145f03ea8
commit
d910ff118e
7 changed files with 55 additions and 339 deletions
|
@ -10,11 +10,10 @@
|
|||
import React, {useEffect, useState, useRef} from 'react';
|
||||
import classnames from 'classnames';
|
||||
import Highlight, {defaultProps} from 'prism-react-renderer';
|
||||
import defaultTheme from 'prism-react-renderer/themes/palenight';
|
||||
import Clipboard from 'clipboard';
|
||||
import rangeParser from 'parse-numeric-range';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import usePrismTheme from '@theme/hooks/usePrismTheme';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
|
@ -113,10 +112,7 @@ export default ({children, className: languageClassName, metastring}) => {
|
|||
let highlightLines = [];
|
||||
let codeBlockTitle = '';
|
||||
|
||||
const {isDarkTheme} = useThemeContext();
|
||||
const lightModeTheme = prism.theme || defaultTheme;
|
||||
const darkModeTheme = prism.darkTheme || lightModeTheme;
|
||||
const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme;
|
||||
const prismTheme = usePrismTheme();
|
||||
|
||||
if (metastring && highlightLinesRangeRegex.test(metastring)) {
|
||||
const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue