Skip to content

Commit 5fc0b51

Browse files
Fix server-render crash with remarkable in tutorials
1 parent 80623ad commit 5fc0b51

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

site/jekyll/tutorials/aspnet4.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,9 +1036,18 @@ class CommentBox extends React.Component {
10361036
We also need to update the `Comment` component to use `Remarkable` from either `global` or `window`, due to a bug in Remarkable:
10371037

10381038
```javascript{3}
1039+
function createRemarkable() {
1040+
var remarkable =
1041+
'undefined' != typeof global && global.Remarkable
1042+
? global.Remarkable
1043+
: window.Remarkable;
1044+
1045+
return new remarkable();
1046+
}
1047+
10391048
class Comment extends React.Component {
10401049
rawMarkup() {
1041-
const md = new (global.Remarkable || window.Remarkable)();
1050+
const md = createRemarkable();
10421051
const rawMarkup = md.render(this.props.children.toString());
10431052
return { __html: rawMarkup };
10441053
}

site/jekyll/tutorials/aspnetcore.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,9 +1020,18 @@ class CommentBox extends React.Component {
10201020
We also need to update the `Comment` component to use `Remarkable` from either `global` or `window`, due to a bug in Remarkable:
10211021

10221022
```javascript{3}
1023+
function createRemarkable() {
1024+
var remarkable =
1025+
'undefined' != typeof global && global.Remarkable
1026+
? global.Remarkable
1027+
: window.Remarkable;
1028+
1029+
return new remarkable();
1030+
}
1031+
10231032
class Comment extends React.Component {
10241033
rawMarkup() {
1025-
const md = new (global.Remarkable || window.Remarkable)();
1034+
const md = createRemarkable();
10261035
const rawMarkup = md.render(this.props.children.toString());
10271036
return { __html: rawMarkup };
10281037
}

0 commit comments

Comments
 (0)