From 68939d8390e56e63563b21c4a2e6ca49e64d8a85 Mon Sep 17 00:00:00 2001 From: Florian BOUILLON Date: Wed, 31 Mar 2021 14:38:33 +0200 Subject: [PATCH] Fixed External link Signed-off-by: Florian BOUILLON --- src/dzeio/Link/index.tsx | 2 +- src/dzeio/Text/index.tsx | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/dzeio/Link/index.tsx b/src/dzeio/Link/index.tsx index e1ed69a..701a34c 100644 --- a/src/dzeio/Link/index.tsx +++ b/src/dzeio/Link/index.tsx @@ -24,7 +24,7 @@ interface Props { export default class Link extends React.Component { public render() { - const external = this.props.external ?? !this.props.href.startsWith('/') + const external = this.props.external ?? this.props.href.startsWith('http') if (external) { // external link return ( diff --git a/src/dzeio/Text/index.tsx b/src/dzeio/Text/index.tsx index d0fc939..25e5843 100644 --- a/src/dzeio/Text/index.tsx +++ b/src/dzeio/Text/index.tsx @@ -12,7 +12,6 @@ interface Props { export default class Text extends React.Component { - public render() { const classes = buildClassName( css.text, @@ -23,16 +22,10 @@ export default class Text extends React.Component { this.props.className ) - switch (this.props.type || 'p') { - case 'h1': return (

{this.props.children}

) - case 'h2': return (

{this.props.children}

) - case 'h3': return (

{this.props.children}

) - case 'h4': return (

{this.props.children}

) - case 'h5': return (
{this.props.children}
) - case 'h6': return (
{this.props.children}
) - case 'em': return (

{this.props.children}

) - case 'span': return ({this.props.children}) - default: return (

{this.props.children}

) + if (this.props.type === 'em') { + return (

{this.props.children}

) } + + return React.createElement(this.props.type || 'p', {className: classes}) } }