@@ -9,6 +9,7 @@ import BlockQuote from './block-quote';
9
9
import CodeBlock from './code-block' ;
10
10
import MarkdownImage from './markdown-image' ;
11
11
import Paragraph from './paragraph' ;
12
+ import AnchorHeader from './anchor-header' ;
12
13
13
14
interface MarkdownRendererProps {
14
15
className ?: string ;
@@ -54,33 +55,37 @@ const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({
54
55
} }
55
56
/>
56
57
) ,
57
- h1 : ( props ) => (
58
- < h1
59
- { ...props }
60
- style = { {
61
- marginTop : '3.0rem' ,
62
- marginBottom : '2.0rem' ,
63
- } }
64
- />
65
- ) ,
66
- h2 : ( props ) => (
67
- < h2
68
- { ...props }
69
- style = { {
70
- marginTop : '2.5rem' ,
71
- marginBottom : '1.5rem' ,
72
- } }
73
- />
74
- ) ,
75
- h3 : ( props ) => (
76
- < h3
77
- { ...props }
78
- style = { {
79
- marginTop : '2.0rem' ,
80
- marginBottom : '1.0rem' ,
81
- } }
82
- />
83
- ) ,
58
+ // h1: (props) => (
59
+ // <h1
60
+ // {...props}
61
+ // style={{
62
+ // marginTop: '3.0rem',
63
+ // marginBottom: '2.0rem',
64
+ // }}
65
+ // />
66
+ // ),
67
+ // h2: (props) => (
68
+ // <h2
69
+ // {...props}
70
+ // style={{
71
+ // marginTop: '2.5rem',
72
+ // marginBottom: '1.5rem',
73
+ // }}
74
+ // />
75
+ // ),
76
+ // h3: (props) => (
77
+ // <h3
78
+ // {...props}
79
+ // style={{
80
+ // marginTop: '2.0rem',
81
+ // marginBottom: '1.0rem',
82
+ // }}
83
+ // />
84
+ // ),
85
+ // Usage:
86
+ h1 : ( { children, ...props } ) => < AnchorHeader level = { 1 } { ...props } > { children } </ AnchorHeader > ,
87
+ h2 : ( { children, ...props } ) => < AnchorHeader level = { 2 } { ...props } > { children } </ AnchorHeader > ,
88
+ h3 : ( { children, ...props } ) => < AnchorHeader level = { 3 } { ...props } > { children } </ AnchorHeader > ,
84
89
blockquote : ( props ) => < BlockQuote { ...props } > { props . children } </ BlockQuote > ,
85
90
code ( { node, inline, className, children, ...props } : any ) {
86
91
const match = / l a n g u a g e - ( \w + ) / . exec ( className || '' ) ;
0 commit comments