import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons'

const ExternalLink = (props) => {
  const isExternal = props.href.indexOf('http') === 0 && props.href.indexOf('wilw.dev') === -1;
  return (  
    <a {...props} href={props.href} target="_blank" rel="noopener noreferrer">{props.children} {isExternal && <FontAwesomeIcon icon={faExternalLinkAlt} />}</a>
  );
}

export default ExternalLink;
