Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
Open news links in web browser
Browse files Browse the repository at this point in the history
  • Loading branch information
axelchalon committed May 25, 2018
1 parent 2e48d91 commit 4f441e4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/views/Home/News/renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@

import { createElement } from 'react';

function createLink (props) {
const { children, href, title, style } = props;

return createElement('a', { href, title, style, target: '_blank' }, children);
}

export function createRenderers (tagStyles = {}) {
return Object
.keys(tagStyles)
.reduce((renderers, tag) => {
switch (tag) {
case 'a':
case 'link':
renderers['link'] = (mdProps) => {
const { children, href, title } = mdProps;
const style = tagStyles[tag];

return createElement('a', { href, title, style }, children);
};
renderers['link'] = (mdProps) => createLink({ ...mdProps, style: tagStyles[tag] });
break;
}

return renderers;
}, {});
}, { link: createLink });
}

0 comments on commit 4f441e4

Please sign in to comment.