Skip to content

Commit dbe7cb1

Browse files
authored
fix(Story Element): Replaced all Anchor tags to open in new tab (#65)
* Fix(Story Element): Replaced all Anchor tags to open in new tab * fix(Story Element): Shorten code * Fix(Story Element): Quote change
1 parent dc1f9c6 commit dbe7cb1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/story-element.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ import Polltype from './story-elements/polltype';
77
import {Table} from './story-elements/table';
88
import { Link } from './link';
99

10-
function StoryElementText({element}) {
11-
return React.createElement("div", {dangerouslySetInnerHTML: {__html: element.text}});
10+
function StoryElementText({element = {},externalLink}) {
11+
let text = element.text || '';
12+
if(externalLink){
13+
text = element.text.replace(/<a/g,'<a target="_blank"');
14+
}
15+
return React.createElement("div", {dangerouslySetInnerHTML: {__html: text}});
1216
}
1317

1418
function StoryElementAlsoRead({element, story}) {

0 commit comments

Comments
 (0)