Skip to content

Commit 3a0a234

Browse files
committed
Implement #4665
1 parent 3c94152 commit 3a0a234

File tree

1 file changed

+25
-3
lines changed
  • src/shared/components/MarkdownRenderer

1 file changed

+25
-3
lines changed

src/shared/components/MarkdownRenderer/index.jsx

+25-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*
66
* Support for additional components can be added to the above file.
77
*/
8+
import _ from 'lodash';
89
import PT from 'prop-types';
910
import React, { Fragment } from 'react';
11+
import { connect } from 'react-redux';
1012

1113
import md from 'utils/markdown';
1214

13-
export default class MarkdownRenderer extends React.Component {
15+
class MarkdownRenderer extends React.Component {
1416
constructor(props) {
1517
super(props);
1618
this.state = {
@@ -31,10 +33,17 @@ export default class MarkdownRenderer extends React.Component {
3133
}
3234

3335
renderElements(markdown) {
34-
const { preview, spaceName, environment } = this.props;
36+
const {
37+
preview,
38+
spaceName,
39+
environment,
40+
profile,
41+
} = this.props;
3542
if (markdown) {
43+
const compiled = _.template(markdown, { variable: 'profile' });
44+
const interpolated = compiled(profile);
3645
this.setState({
37-
elements: md(markdown, { preview, spaceName, environment }),
46+
elements: md(interpolated, { preview, spaceName, environment }),
3847
});
3948
}
4049
}
@@ -58,11 +67,24 @@ MarkdownRenderer.defaultProps = {
5867
preview: false,
5968
spaceName: null,
6069
environment: null,
70+
profile: {},
6171
};
6272

6373
MarkdownRenderer.propTypes = {
6474
markdown: PT.string,
6575
preview: PT.bool,
6676
spaceName: PT.string,
6777
environment: PT.string,
78+
profile: PT.shape(),
6879
};
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

Comments
 (0)