5
5
*
6
6
* Support for additional components can be added to the above file.
7
7
*/
8
+ import _ from 'lodash' ;
8
9
import PT from 'prop-types' ;
9
10
import React , { Fragment } from 'react' ;
11
+ import { connect } from 'react-redux' ;
10
12
11
13
import md from 'utils/markdown' ;
12
14
13
- export default class MarkdownRenderer extends React . Component {
15
+ class MarkdownRenderer extends React . Component {
14
16
constructor ( props ) {
15
17
super ( props ) ;
16
18
this . state = {
@@ -31,10 +33,17 @@ export default class MarkdownRenderer extends React.Component {
31
33
}
32
34
33
35
renderElements ( markdown ) {
34
- const { preview, spaceName, environment } = this . props ;
36
+ const {
37
+ preview,
38
+ spaceName,
39
+ environment,
40
+ profile,
41
+ } = this . props ;
35
42
if ( markdown ) {
43
+ const compiled = _ . template ( markdown , { variable : 'profile' } ) ;
44
+ const interpolated = compiled ( profile ) ;
36
45
this . setState ( {
37
- elements : md ( markdown , { preview, spaceName, environment } ) ,
46
+ elements : md ( interpolated , { preview, spaceName, environment } ) ,
38
47
} ) ;
39
48
}
40
49
}
@@ -58,11 +67,24 @@ MarkdownRenderer.defaultProps = {
58
67
preview : false ,
59
68
spaceName : null ,
60
69
environment : null ,
70
+ profile : { } ,
61
71
} ;
62
72
63
73
MarkdownRenderer . propTypes = {
64
74
markdown : PT . string ,
65
75
preview : PT . bool ,
66
76
spaceName : PT . string ,
67
77
environment : PT . string ,
78
+ profile : PT . shape ( ) ,
68
79
} ;
80
+
81
+ function mapStateToProps ( state ) {
82
+ const profile = state . auth && state . auth . profile ? { ...state . auth . profile } : { } ;
83
+ return { profile } ;
84
+ }
85
+
86
+ const MarkdownRendererContainer = connect (
87
+ mapStateToProps ,
88
+ ) ( MarkdownRenderer ) ;
89
+
90
+ export default MarkdownRendererContainer ;
0 commit comments