1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-22 11:34:21 +00:00

Add a default language context

This commit is contained in:
Steffo 2020-10-14 02:19:36 +02:00
parent 47ba3e42b1
commit d38c63da7e
2 changed files with 8 additions and 1 deletions

View file

@ -1,10 +1,14 @@
import SyntaxHighlighter from 'react-syntax-highlighter'
import {monokai} from "react-syntax-highlighter/dist/cjs/styles/hljs";
import stripTabs from "../../utils/stripTabs";
import {useContext} from "preact/hooks";
import CodeDefaultLanguage from "../../contexts/CodeDefaultLanguage";
export default function(props) {
const language = useContext(CodeDefaultLanguage)
return (
<SyntaxHighlighter language={props.language ? props.language : "plaintext"} style={monokai}>
<SyntaxHighlighter language={props.language ? props.language : language} style={monokai}>
{stripTabs(String(props.children))}
</SyntaxHighlighter>
)

View file

@ -0,0 +1,3 @@
import {createContext} from "preact";
export default createContext("plaintext");