File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"private" : true ,
3
3
"name" : " blog" ,
4
- "version" : " 0.1.0 " ,
4
+ "version" : " 0.1.1 " ,
5
5
"license" : " MIT" ,
6
6
"scripts" : {
7
7
"start" : " per-env" ,
Original file line number Diff line number Diff line change @@ -2,12 +2,16 @@ import { h } from 'preact';
2
2
import { useState } from 'preact/hooks' ;
3
3
4
4
import { vs } from 'react-syntax-highlighter/dist/esm/styles/prism' ;
5
+ import style from './style.css' ;
5
6
6
7
export function FormattedCodeBlock ( props ) {
7
8
const [ component , setComponent ] = useState ( null ) ;
8
9
if ( component ) {
9
10
return component ;
10
11
}
12
+ if ( ! props . class ) {
13
+ return ( < code class = { style . inline } > { props . children } </ code > ) ;
14
+ }
11
15
throw new Promise ( resolve => {
12
16
let language = null ;
13
17
const highlighter = import ( 'react-syntax-highlighter/dist/esm/prism-light' ) ;
@@ -29,6 +33,10 @@ export function FormattedCodeBlock(props) {
29
33
language = 'typescript' ;
30
34
languageSyntax = import ( 'react-syntax-highlighter/dist/esm/languages/prism/typescript' ) ;
31
35
break ;
36
+ default :
37
+ language = 'markdown' ;
38
+ languageSyntax = import ( 'react-syntax-highlighter/dist/esm/languages/prism/markdown' ) ;
39
+ break ;
32
40
}
33
41
Promise . all ( [ highlighter , languageSyntax ] ) . then ( values => {
34
42
const [ SyntaxHighlighter , languageHighlighter ] = values . map ( m => m ? m . default : null ) ;
Original file line number Diff line number Diff line change 25
25
text-decoration : underline;
26
26
}
27
27
28
- .blogbody code {
28
+ .blogbody pre code {
29
29
display : block;
30
30
max-width : 100% ;
31
31
color : rgb (57 , 58 , 52 );
39
39
line-height : 1.2em ;
40
40
tab-size : 4 ;
41
41
hyphens : none;
42
+ overflow-x : scroll;
43
+ }
44
+
45
+ code .inline {
46
+ display : inline;
47
+ max-width : none;
48
+ background : # ddd ;
49
+ padding : 0px 4px ;
42
50
}
43
51
44
52
.blogbody pre pre {
You can’t perform that action at this time.
0 commit comments