1
0
Fork 0

feat(lab): Draft view pretty ok now

This commit is contained in:
Joost De Cock 2022-01-28 16:57:07 +01:00
parent 73163f5676
commit 929822b249
15 changed files with 327 additions and 29 deletions

View file

@ -4,14 +4,23 @@ const names = {
js: 'javascript',
bash: 'bash',
sh: 'shell',
json: 'JSON',
yaml: 'YAML',
}
const Highlight = (props) => {
const language = props.children
const language = props.language
? props.language
: props.children
? props.children.props.className.split('-').pop()
: 'txt'
const preProps = {
className: `language-${language} hljs text-base lg:text-lg whitespace-pre-wrap break-words`
}
if (props.raw) preProps.dangerouslySetInnerHTML = { __html: props.raw }
return (
<div className="hljs my-4">
<div className={`
@ -24,7 +33,7 @@ const Highlight = (props) => {
<span>{names[language] ? names[language] : language}</span>
<CopyToClipboard content={props.children} />
</div>
<pre className={`language-${language} hljs text-base lg:text-lg whitespace-pre-wrap break-words`}>
<pre {...preProps}>
{props.children}
</pre>
</div>