<script>
	import Children from 'svelte-exmarkdown/renderer/Children.svelte';
  import FaExternalLinkAlt from 'svelte-icons/fa/FaExternalLinkAlt.svelte'
	export let children;
	export let properties;

  let isExternal = properties.href && properties.href.startsWith('http');
  let target = isExternal && "_blank"
</script>

<style>
  .icon {
    height: 1em;
    width: auto;
    display: inline-block;
    vertical-align: baseline;
  }
</style>

<!-- svelte-ignore a11y-missing-attribute -->
<a {...properties} {target}>
  <Children {children} />
  {#if isExternal}
  <span class="icon">
    <FaExternalLinkAlt/>
  </span>
  {/if}
</a>